MongoDB does not trigger scaling #6621
-
I've set up KEDA There appears to be no obvious issues in logs (happy to share more) but scaling isn't working. Here's the YAML I used for apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: mongodb-job
spec:
scaleTargetRef:
name: film-q-deployment
cooldownPeriod: 300
minReplicaCount: 1
maxReplicaCount: 3
triggers:
- type: mongodb
metadata:
connectionStringFromEnv: DATABASE_URI
dbName: "app-db"
collection: "job-queue"
query: '{ "status": "waiting" }'
queryValue: "1"
authenticationRef:
name: mongodb-trigger
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: mongodb-trigger
spec:
secretTargetRef:
- parameter: connectionString
name: env-secrets
key: DATABASE_URI Note that I'm using Not sure where I should look next to fix this. Can anyone advise? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I figured this out and I'd like to share what I learned. My confusion was with the I'm new to k8s and KEDA so missing the above context made the job confusing. Eventually, I came across a solution that involves using apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
...
spec:
...
+ advanced:
+ scalingModifiers:
+ formula: "(waitroom + 1)" # Modifies computed scaled value by adding +1
+ target: "1" # The final computed value matches 1 per replica
triggers:
- type: mongodb
+ name: waitroom
metadata:
connectionStringFromEnv: DATABASE_URI
...
query: '{ "status": "waiting" }'
queryValue: "1"
authenticationRef:
name: mongodb-trigger |
Beta Was this translation helpful? Give feedback.
I think I figured this out and I'd like to share what I learned.
My confusion was with the
queueValue
. My objective was to start scaling when the{ "status": "waiting" }
query in MongoDB returned one or more documents. However, it appears that KEDA looks at this value and starts scaling after the number of returned documents is greater thanqueueValue
(which, in this case, means 2 or greater). Also, unfortunately, settingqueryValue
to 0 does not work either, presumably because of how this value is used in calculations.I'm new to k8s and KEDA so missing the above context made the job confusing. Eventually, I came across a solution that involves using
scalingModifiers
to achieve what I wa…