当前位置: 首页 > 知识库问答 >
问题:

Azure功能,KEDA扩展不超过1个pod

桂阳文
2023-03-14

吊舱降到0,但旋转速度不会超过1个吊舱。即使订阅中的代码超过5mg,也会根据建议更新代码。

添加了TriggerAuthentication并使用connectionString作为身份验证。试图发送大约25条消息,但pod仍无法扩展。

只有一个pod在处理所有消息。我需要更新什么吗

apiVersion: keda.k8s.io/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-servicebus-auth
spec:
  secretTargetRef:
    - parameter: connection
      name: mdsp-secret-infra
      key: service_bus_conn_str
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xyz-test
  labels:
    app: xyz-test
spec:
  selector:
    matchLabels:
      app: xyz-test
  template:
    metadata:
      labels:
        app: xyz-test
    spec:
      initContainers:
        - name: mdsp-java-init
          image: aksacrname.azurecr.io/ops/mdsp-init-java:1.0
          imagePullPolicy: Always
          resources: {}
          volumeMounts:
            - name: azure
              mountPath: /mnt/azure
            - name: cert-storage
              mountPath: /certs
      volumes:
        - name: azure
          azureFile:
            shareName: certs
            secretName: mdsp-secret-iots-sa
            readOnly: true
        - name: cert-storage
          emptyDir: {}
        - name: "logging-volume-azure-file"
          persistentVolumeClaim:
            claimName: "pvc-azure-file-logging"
      containers:
        - name: xyz-test
          image: mdspaksdevacr.azurecr.io/iots/xyz-test:aksacrversion
          resources:
            limits:
              cpu: 3
              memory: 2Gi
            requests:
              cpu: 1
              memory: 1Gi
          imagePullPolicy: Always
          env:
            - name: mdsp_product_line
              value: "iiotservices"
            - name: mdsp_application_name
              value: "xyz-test"
            - name: eh_connection_string
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: LOGGING_EH_CON_STRING
            - name: log_base_path
              value: "/mnt/logging"
            - name: app.logging.console.enabled
              value: "true"
            - name: ai_instrumentation_key
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: APPINSIGHT_KEY
            - name: MDSP_HOST_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: MDSP_HOST_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: APPLICATION_NAME
              value: "xyz-test"
            - name: logging.level.com.siemens.mindsphere
              value: "INFO"
            - name: PRODUCTLINE_NAME
              value: "iiotServices"
            - name: environment
              value: "azEnvironment"
            - name: CONNECTION_TIMEOUT_MS
              value: "10000"
            - name: GATEWAY_URI
              value: "https://gateway.core.mindsphere.local"
            - name: UPDATES_SERVICE_BUS_TOPIC_NAME
              value: "internal-iiot-meta-data-updates-topic"
            - name: ASSET_CLIENTID
              value: asset
            - name: AM_BASE_URL
              value: "https://gateway.core.mindsphere.local/api/assetmanagement/v3"
            - name: CORE_AUTH_TOKEN_URL
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: OAUTH_TOKEN_URI
            - name: amServiceBusConnectionString
              valueFrom:
                secretKeyRef:
                  name: mdsp-iots-secret-infra
                  key: advs_servicebus_conn_str
            - name: feedbackServiceBusConnectionString
              value: "Endpoint=sb://iot-test-rc.servicebus.windows.net/;SharedAccessKeyName=Testkey;SharedAccessKey=test"
            - name: UPDATES_SERVICE_BUS_CONN_STR
              valueFrom:
                secretKeyRef:
                  name: mdsp-iots-secret-infra
                  key: iots_service_bus_conn_str
            - name: AZURE_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: KEYVAULT_CLIENT_ID
            - name: AZURE_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: KEYVAULT_CLIENT_KEY
            - name: AZURE_SUBSCRIPTION_ID
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: SUBSCRIPTION_ID
            - name: AZURE_TENANT_ID
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: TENANT_ID
            - name: KV_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: KEYVAULT_CLIENT_ID
            - name: KV_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-kv
                  key: KEYVAULT_CLIENT_KEY
            - name: JAVA_OPTS
              value: >-
                -Djavax.net.ssl.trustStore=/certs/cacerts
                -Xmx2500m
            - name: KEYVAULT_URI
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: IOTS_KEYVAULT_URI
            - name: COSMOS_URL
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: IOT_COSMOS_URI
            - name: default_key
              valueFrom:
                secretKeyRef:
                  name: mdsp-iots-secret-infra
                  key: iots_cosmos_db_conn_key
            - name: COSMOS_DB_NAME
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: IOT_COSMOS_DB_AM
            - name: COSMOS_CONTAINER_NAME
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: IOT_COSMOS_CON_AM
            - name: default_secret_name
              valueFrom:
                secretKeyRef:
                  name: mdsp-secret-iots-tu
                  key: iots_bulk_data_stream
            - name: MINDSPHERE_SECURITY_OAUTH2_CLIENT_ASSET_ACCESSTOKENURI
              valueFrom:
                configMapKeyRef:
                  name: mdsp-iots-configmap
                  key: OAUTH_TOKEN_URI
            - name: MINDSPHERE_SECURITY_OAUTH2_CLIENT_ASSET_ID
              value: "iottest"


          volumeMounts:
            - name: cert-storage
              mountPath: /certs
            - name: "logging-volume-azure-file"
              mountPath: "/mnt/logging"
      imagePullSecrets:
        - name: mdsp-secret-iots
      dnsPolicy: ClusterFirst
      terminationGracePeriodSeconds: 30
---

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: xyz-test-scaler-dev
  labels:
    app: xyz-test
    deploymentName: xyz-test
spec:
  scaleTargetRef:
    deploymentName: xyz-test
  minReplicaCount: 0
  maxReplicaCount: 3
  pollingInterval: 1
  triggers:
  - type: azure-servicebus
    metadata:
      # Required
      topicName: am-removal-test
      subscriptionName: am-subs
      namespace: iot-sbus-rc
      # Optional, can use TriggerAuthentication as well
      connection: feedbackServiceBusConnectionString
      # This must be a connection string for a queue itself, and not a namespace level (e.g. RootAccessPolicy) connection string [#215](https://github.com/kedacore/keda/issues/215)
      # Optional
      queueLength: "2"
    authenticationRef:
      name: azure-servicebus-auth
---

获取错误:

Conditions:
  Type           Status  Reason                   Message
  ----           ------  ------                   -------
  AbleToScale    True    SucceededGetScale        the HPA controller was able to get the target's current scale
  ScalingActive  False   FailedGetExternalMetric  the HPA was unable to compute the replica count: unable to get external metric iots-dev/queueLength/&LabelSelector{MatchLabels:map[string]string{deploymentName: xyz,},MatchExpressions:[]LabelSelectorRequirement{},}: unable to fetch metrics from external metrics API: the server is currently unable to handle the request (get queueLength.external.metrics.k8s.io)
Events:
  Type     Reason                   Age                       From                       Message
  ----     ------                   ----                      ----                       -------
  Warning  FailedGetExternalMetric  2m17s (x2591 over 5h53m)  horizontal-pod-autoscaler  unable to get external metric iots-dev/queueLength/&LabelSelector{MatchLabels:map[string]string{deploymentName: xyz,},MatchExpressions:[]LabelSelectorRequirement{},}: unable to fetch metrics from external metrics API: the server is currently unable to handle the request (get queueLength.external.metrics.k8s.io)

运行命令后:

```

apiregistration.k8s.io/v1

166种类:APIService

167元数据:

168注释:

169 kubectl。库伯内特斯。io/上次应用的配置:|

170{“apiVersion”:“apiregistration.k8s.io/v1beta1”,“kind”:“APIService”,“metadata”:{“annotations”:{},“name”:“v1beta1.external.metrics.k8s.io”},“spec”:{“group”:“external.metrics.k8s.io”,“groupPriorityMinimum”:100,“insureskiplsverify”:true,“service”:{“name”:“custom metrics azure apiserver”,“namespace”:“custom metrics”},“version”:“v1beta1”,“versionPriority”:100}

171 creationTimestamp:“2020-09-15T15:48:18Z”

172名称:v1beta1.external.metrics.k8s.io

173资源版本:“13008780”

174自我链接: /apis/apiregistration.k8s.io/v1/apiservices/v1beta1.external.metrics.k8s.io

175 uid:a6a72678-001f-4378-ba10-cbff7d8c0ad2

176规格:

177组:外部。韵律学。k8s。io

178组优先级最小值:100

179不安全技巧验证:真

180服务:

181名称:自定义度量azure apiserver

182命名空间:自定义度量

183端口:443

184版本:v1beta1

185版本优先级:100

186状态:

187条件:

188-lastTrantionTime:"2020-10-27T12:19:19Z"

189消息:“自定义指标”中的服务/自定义指标-azure-apiserver不存在

190原因:ServiceNotFound

191状态:“错误”

192型:可用

共有1个答案

方献
2023-03-14

所以,我的KEDA自动缩放器与Rabbitmq的工作示例:

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: job-export-autoscaler
  namespace: thor
spec:
  scaleTargetRef:
    deploymentName: job-export
  pollingInterval: 5 # Time after each check
  minReplicaCount: 0   # Optional. Default: 0
  maxReplicaCount: 10 # Optional. Default: 100
  cooldownPeriod: 60 # Cooldown since last trigger to outoscale down
  triggers:
  - type: rabbitmq
    metadata:
      queueName: report-export
      queueLength: "1"
    authenticationRef:
      name: trigger-auth-rabbitmq

现在评论中提到的triggerAuth:

apiVersion: keda.k8s.io/v1alpha1
kind: TriggerAuthentication
metadata:
  name: trigger-auth-rabbitmq
  namespace: thor
spec:
  secretTargetRef:
  - parameter: host
    name: rabbitmq-host-secret
    key: rabbitmq-connectionstring
---
apiVersion: v1
kind: Secret
metadata:
  name: rabbitmq-host-secret
  namespace: thor
  labels:
    app: rabbitmq
data:
  rabbitmq-connectionstring: (base64 encoded rabbitmq connection string)

因此,对于使用Azure service bus:

文档:https://keda.sh/docs/1.4/scalers/azure-service-bus/#authentication-parameters

例子:

apiVersion: keda.k8s.io/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-servicebus-auth
spec:
  podIdentity:
    provider: azure
---
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: azure-servicebus-queue-scaledobject
  namespace: default
spec:
  scaleTargetRef:
    deploymentName: azure-servicebus-queue-function
  triggers:
  - type: azure-servicebus
    metadata:
      # Required: queueName OR topicName and subscriptionName
      queueName: functions-sbqueue
      # or
      topicName: functions-sbtopic
      subscriptionName: sbtopic-sub1
      # Required: Define what Azure Service Bus to authenticate to with Managed Identity
      namespace: service-bus-namespace
      # Optional
      queueLength: "5" # default 5
    authenticationRef:
        name: azure-servicebus-auth # authenticationRef would need either podIdentity or define a connection parameter

因此,您缺少带有连接字符串的TriggerAuthentication对象

 类似资料:
  • Azure函数的缩放文档对Azure函数如何决定何时添加更多应用程序实例的详细信息有点了解。 例如,我有一个由Github网络钩子触发的函数。10,000人同时提交到Github repo(没有合并冲突;)),Github在很短的时间内调用我的函数10,000次。 我能期待发生什么?具体来说, Azure函数会限制webhook调用吗?i、 例如,如果我的函数应用程序处于高负载状态,Azure函数

  • 超媒体点击事件的监听 超媒体消息的点击事件包括:点击打开链接url和点击打开app的原生页面;其中点击打开url链接使用setOnHyperUrlListener接口,方法如下: Ntalker.getInstance().setOnHyperUrlListener(new OnHyperUrlListener() { @Override public void OnOpenHyp

  • SDK对外开放了一个可自定义的协议NtalkerChatDelegate,如果客户想进行自定义实现接口,必须遵守此协议,初始化小能类的时候设置其delagate为实现代理接口方法的类,然后实现相应的接口。其中提供了以下几个接口: 深度自定义控件接口,详细调用细节,请参照demo。 一、自定义消息发送 二、查询历史咨询列表 三、设置超媒体自定义参数 四、+号功能区的扩展功能 五、商品条自定义 六、设

  • 一、发送文本消息到聊窗内 二、返回按钮的点击监听 三、结束会话按钮的点击监听 四、超媒体点击事件的监听 五、+号功能区的扩展功能 六、商品条自定义 七、导航栏自定义

  • QueyList是完全模块化的设计,拥有强大的可扩展性。 使用bind()方法绑定一个功能函数到QueryList对象,实现轻量级的功能扩展。bind()方法的第一个参数是绑定的函数名,第二个参数是一个匿名的功能函数,这个功能函数的$this对象指向的是当前的QueryList实例对象,所以在这个功能函数中可以直接通过$this来调用QueryList的方法。 例子 注册一个自定义的http网络操

  • 自定义引擎各个阶段 可以在测试脚本中或者基类中重写 ActsTestBase 提供的 API。 重写 prepare,execute,check,clear 等。可以通过在 super.prepare() 之前或者之后进行某些操作。 重写 process 方法,在 super.process() 之前或之后进行操作。可将整个脚本重新编排,例如在现有的清理 -> 准备 -> 执行 -> 校验流程中增