我有一个 Keda Scaledjob 配置为每条消息生成 1 个作业,在 RabbitMQ 中具有“就绪”状态。
它的最大副本数设置为 70。
观察到的:
当队列中有很多消息时,比如 300 条,Keda 正确地创建新作业以达到最大副本数限制 => 所以有 70 个正在运行的作业,每个作业消耗队列中的 1 条消息。
当队列中的消息很少时,比如 1 个 Ready 和 1 个 Unacked,即使集群中有足够的资源,Keda 也拒绝创建新作业。这就像等到当前正在运行的作业完成以生成新作业一样。
这是我的科达配置:
---
# Reference - https://keda.sh/docs/2.0/concepts/scaling-jobs/
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: scaledjob-puppeteer
labels:
environment: development
app: puppeteer-display
spec:
jobTargetRef:
parallelism: 1 # [max number of desired pods](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#controlling-parallelism)
completions: 1 # [desired number of successfully finished pods](https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#controlling-parallelism)
activeDeadlineSeconds: 7200 # (2 hours) Specifies the duration in seconds relative to the startTime that the job may be active before the system tries to terminate it; value must be positive integer
backoffLimit: 2 # Specifies the number of retries before marking this job failed. Defaults to 6
template:
spec:
volumes:
...
containers:
...
pollingInterval: 10
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 0
maxReplicaCount: 75
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: tasks
mode: QueueLength
value: "1"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
---
每当队列有 >= 1 条消息时,如何让 Keda 创建作业?
编辑:似乎在创建新作业之前至少要等待 1 小时。