1

我正在运行一个启用了 KEDA 的 k8s 集群,它带有存储队列 Azure 功能,它一次执行 2000 条消息,执行时间可变(在 30 秒到 10 分钟之间)。系统在一段时间内正常工作,但是当队列中的消息数量开始减少时,pod 的数量也开始减少。

问题:为什么运行的 pod 数量减少了,而队列中的消息数量仍然很高?

示例:最大副本数为 120,队列中的消息数约为 250。那么为什么 HPA 会缩减 pod。理想情况下,它仍应使用所有 120 个 pod 来完成队列中的所有消息。

补充问题:

  1. queueLength 会影响 HPA 的行为吗?
  2. 很少有消息没有完全执行。尽管 TerminationGracePeriodSeconds 是 10 分钟,但它们似乎在执行过程中突然关闭。任何意见?

以下是 scaledobject.yaml 文件:

apiVersion: v1
kind: Secret
metadata:
  name: queue-connection-secret
data:
  connection-string: ####
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-queue-auth
spec:
  secretTargetRef:
  - parameter: connection
    name: queue-connection-secret
    key: connection-string
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: queuetrigfuncscaledobject
spec:
  scaleTargetRef:
    name: queuetrigfuncdeployment
  minReplicaCount: 0
  maxReplicaCount: 120
  pollingInterval: 1
  cooldownPeriod: 900

  triggers:
  - type: azure-queue
    metadata:
      queueName: k8s-poc-queue
      queueLength: "1"
    authenticationRef:
        name: azure-queue-auth

Deployments.yaml 文件:

apiVersion : apps/v1
kind: Deployment
metadata:
  name: queuetrigfuncdeployment
  labels:
    app: queuetrigfuncpod
spec:
  selector:
    matchLabels:
      app: queuetrigfuncpod
  template:
    metadata:
      labels:
        app: queuetrigfuncpod
    spec:
      containers:
        - image: #######.azurecr.io/#######
          name: queuetrigcontainer
          ports:
          - containerPort: 80
          resources:
            requests:
              memory: "500Mi"
              cpu: "700m"
            limits:
              memory: "600Mi"
              cpu: "700m"
      nodeSelector:
        agentpool: testuserpool
      terminationGracePeriodSeconds: 600
      imagePullSecrets:
      - name: regcred
4

1 回答 1

0

该缩放器使用的是AverageValue 模式,因此计数除以 pod 的数量。您想要取而代之的是价值模式,但目前没有选项。

这是 Keda 的一个整体问题,我们一直打算在全球范围内解决这个问题,但没有人有时间。如果您提交 PR,请在 Slack 中联系我,我可以对其进行审核。

于 2021-06-08T08:34:20.813 回答