我正试图基于RabbitMQ队列触发器创建一个KEDA扩展作业,但在pod根本不扩展时遇到了问题。
我创建了下面的Scaled作业,并在队列中排列了消息,但没有创建pod。我看到这条消息:由于触发器未激活,所以未执行缩放
是什么原因导致吊舱根本无法伸缩?谢谢你的帮助。
在科达日志中,我看到:
2021-12-29T13:50:19.738Z INFO scalemetrics Checking if ScaleJob Scalers are active {"ScaledJob": "celery-rabbitmq-scaledjob-2", "isActive": false, "maxValue": 0, "MultipleScalersCalculation": ""}
2021-12-29T13:50:19.738Z INFO scaleexecutor Scaling Jobs {"scaledJob.Name": "celery-rabbitmq-scaledjob-2", "scaledJob.Namespace": "sandbox-dev", "Number of running Jobs": 0}
2021-12-29T13:50:19.738Z INFO scaleexecutor Scaling Jobs {"scaledJob.Name": "celery-rabbitmq-scaledjob-2", "scaledJob.Namespace": "sandbox-dev", "Number of pending Jobs ": 0}
--
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"keda.sh/v1alpha1","kind":"ScaledJob","metadata":{"annotations":{},"name":"celery-rabbitmq-scaledjob-2","namespace":"sandbox-dev"},"spec":{"failedJobsHistoryLimit":5,"jobTargetRef":{"activeDeadlineSeconds":3600,"backoffLimit":6,"completions":1,"parallelism":5,"template":{"spec":{"containers":[{"command":["/bin/bash","-c","CELERY_BROKER_URL=amqp://$RABBITMQ_USERNAME:$RABBITMQ_PASSWORD@rabbitmq.sandbox-dev.svc.cluster.local:5672
celery worker -A test_data.tasks.all --loglevel=info -c 1 -n
worker.all"],"env":[{"name":"APP_CFG","value":"test_data.config.dev"},{"name":"C_FORCE_ROOT","value":"true"},{"name":"RABBITMQ_USERNAME","valueFrom":{"secretKeyRef":{"key":"rabbitmq-user","name":"develop"}}},{"name":"RABBITMQ_PASSWORD","valueFrom":{"secretKeyRef":{"key":"rabbitmq-pass","name":"develop"}}}],"image":"767487149142.dkr.ecr.us-east-1.amazonaws.com/test-data-celery:DEV-2021.12.27.0","imagePullPolicy":"IfNotPresent","lifecycle":{"postStart":{"exec":{"command":["/bin/sh","-c","echo
startup u003eu003e
/tmp/startup.log"]}},"preStop":{"exec":{"command":["/bin/sh","-c","echo
shutdown u003eu003e
/tmp/shutdown.log"]}}},"name":"celery-backend","resources":{"limits":{"cpu":"1700m","memory":"3328599654400m"},"requests":{"cpu":"1600m","memory":"3Gi"}},"securityContext":{"allowPrivilegeEscalation":false,"privileged":false,"readOnlyRootFilesystem":false},"terminationMessagePath":"/tmp/termmsg.log","terminationMessagePolicy":"File","volumeMounts":[{"mountPath":"/tmp","name":"temp"},{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"default-token-s7vl6","readOnly":true}]}]}}},"maxReplicaCount":100,"pollingInterval":5,"rolloutStrategy":"gradual","successfulJobsHistoryLimit":5,"triggers":[{"metadata":{"host":"amqp://guest:guest@rabbitmq.sandbox-dev.svc.cluster.local:5672/vhost","mode":"QueueLength","queueName":"celery","value":"1"},"type":"rabbitmq"}]}}
creationTimestamp: '2021-12-29T13:11:15Z'
finalizers:
- finalizer.keda.sh
generation: 3
managedFields:
- apiVersion: keda.sh/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:finalizers: {}
f:spec:
f:jobTargetRef:
f:template:
f:metadata:
.: {}
f:creationTimestamp: {}
f:scalingStrategy: {}
f:status:
.: {}
f:conditions: {}
manager: keda
operation: Update
time: '2021-12-29T13:11:15Z'
- apiVersion: keda.sh/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:spec:
.: {}
f:failedJobsHistoryLimit: {}
f:jobTargetRef:
.: {}
f:activeDeadlineSeconds: {}
f:backoffLimit: {}
f:completions: {}
f:template:
.: {}
f:spec:
.: {}
f:containers: {}
f:maxReplicaCount: {}
f:pollingInterval: {}
f:rolloutStrategy: {}
f:successfulJobsHistoryLimit: {}
f:triggers: {}
manager: kubectl-client-side-apply
operation: Update
time: '2021-12-29T13:11:15Z'
- apiVersion: keda.sh/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:jobTargetRef:
f:parallelism: {}
manager: node-fetch
operation: Update
time: '2021-12-29T13:37:11Z'
name: celery-rabbitmq-scaledjob-2
namespace: sandbox-dev
resourceVersion: '222981509'
selfLink: >-
/apis/keda.sh/v1alpha1/namespaces/sandbox-dev/scaledjobs/celery-rabbitmq-scaledjob-2
uid: 9013295a-6ace-48ba-96d3-8810efde1b35
status:
conditions:
- message: ScaledJob is defined correctly and is ready to scaling
reason: ScaledJobReady
status: 'True'
type: Ready
- message: Scaling is not performed because triggers are not active
reason: ScalerNotActive
status: 'False'
type: Active
- status: Unknown
type: Fallback
spec:
failedJobsHistoryLimit: 5
jobTargetRef:
activeDeadlineSeconds: 3600
backoffLimit: 6
completions: 1
parallelism: 1
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- /bin/bash
- '-c'
- >-
CELERY_BROKER_URL=amqp://$RABBITMQ_USERNAME:$RABBITMQ_PASSWORD@rabbitmq.sandbox-dev.svc.cluster.local:5672
celery worker -A test_data.tasks.all --loglevel=info -c 1
-n worker.all
env:
- name: APP_CFG
value: test_data.config.dev
- name: C_FORCE_ROOT
value: 'true'
- name: RABBITMQ_USERNAME
valueFrom:
secretKeyRef:
key: rabbitmq-user
name: develop
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
key: rabbitmq-pass
name: develop
image: >-
111.dkr.ecr.us-east-1.amazonaws.com/test-data-celery:DEV-2021.12.27.0
imagePullPolicy: IfNotPresent
lifecycle:
postStart:
exec:
command:
- /bin/sh
- '-c'
- echo startup >> /tmp/startup.log
preStop:
exec:
command:
- /bin/sh
- '-c'
- echo shutdown >> /tmp/shutdown.log
name: celery-backend
resources:
limits:
cpu: 1700m
memory: 3328599654400m
requests:
cpu: 1600m
memory: 3Gi
securityContext:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: false
terminationMessagePath: /tmp/termmsg.log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp
name: temp
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-s7vl6
readOnly: true
maxReplicaCount: 100
pollingInterval: 5
rolloutStrategy: gradual
scalingStrategy: {}
successfulJobsHistoryLimit: 5
triggers:
- metadata:
host: amqp://guest:guest@rabbitmq.sandbox-dev.svc.cluster.local:5672/vhost
mode: QueueLength
queueName: celery
value: '1'
type: rabbitmq
模式在某些情况下可能不起作用。
尝试更改
- metadata:
host: amqp://guest:guest@rabbitmq.sandbox-dev.svc.cluster.local:5672/vhost
mode: QueueLength
queueName: celery
value: '1'
至
- metadata:
host: amqp://guest:guest@rabbitmq.sandbox-dev.svc.cluster.local:5672/vhost
queueName: files
queueLength: '1'