diff --git a/modules/nodes-cma-autoscaling-custom-trigger-workload.adoc b/modules/nodes-cma-autoscaling-custom-trigger-workload.adoc new file mode 100644 index 000000000000..af06d44bf739 --- /dev/null +++ b/modules/nodes-cma-autoscaling-custom-trigger-workload.adoc @@ -0,0 +1,41 @@ +// Module included in the following assemblies: +// +// * nodes/cma/nodes-cma-autoscaling-custom-trigger.adoc + +:_mod-docs-content-type: PROCEDURE +[id="nodes-cma-autoscaling-custom-trigger-workload_{context}"] += Understanding the Kubernetes workload trigger + +You can scale pods based on the number of pods matching a specific label selector. + +The Custom Metrics Autoscaler Operator tracks the number of pods with a specific label that are in the same namespace, then calculates a _relation_ based on the number of labeled pods to the pods for the scaled object. Using this relation, the Custom Metrics Autoscaler Operator scales the object according to the scaling policy in the `ScaledObject` or `ScaledJob` specification. + +The pod counts includes pods with a `Succeeded` or `Failed` phase. + +For example, if you have a `frontend` deployment and a `backend` deployment. You can use a `kubernetes-workload` trigger to scale the `backend` deployment based on the number of `frontend` pods. If number of `frontend` pods goes up, the Operator would scale the `backend` pods to maintain the specified ratio. In this example, if there are 10 pods with the `app=frontend` pod selector, the Operator scales the backend pods to 5 in order to maintain the `0.5` ratio set in the scaled object. + +.Example scaled object with a Kubernetes workload trigger +[source,yaml] +---- +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: workload-scaledobject + namespace: my-namespace +spec: + triggers: + - type: kubernetes-workload <1> + metadata: + podSelector: 'app=frontend' <2> + value: '0.5' <3> + activationValue: '3.1' <4> +---- +<1> Specifies a Kubernetes workload trigger. +<2> Specifies one or more pod selectors and/or set-based selectors, separated with commas, to use to get the pod count. +<3> Specifies the target relation between the scaled workload and the number of pods that match the selector. The relation is calculated following the following formula: ++ +---- +relation = (pods that match the selector) / (scaled workload pods) +---- ++ +<4> Optional: Specifies the target value for scaler activation phase. The default is `0`. diff --git a/nodes/cma/nodes-cma-autoscaling-custom-trigger.adoc b/nodes/cma/nodes-cma-autoscaling-custom-trigger.adoc index fc7393a796ce..1003e696d1ed 100644 --- a/nodes/cma/nodes-cma-autoscaling-custom-trigger.adoc +++ b/nodes/cma/nodes-cma-autoscaling-custom-trigger.adoc @@ -32,3 +32,4 @@ include::modules/nodes-cma-autoscaling-custom-trigger-cpu.adoc[leveloffset=+1] include::modules/nodes-cma-autoscaling-custom-trigger-memory.adoc[leveloffset=+1] include::modules/nodes-cma-autoscaling-custom-trigger-kafka.adoc[leveloffset=+1] include::modules/nodes-cma-autoscaling-custom-trigger-cron.adoc[leveloffset=+1] +include::modules/nodes-cma-autoscaling-custom-trigger-workload.adoc[leveloffset=+1]