1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/nodes-cma-autoscaling-custom-trigger-workload.adoc
2025-09-25 18:13:37 -04:00

42 lines
2.1 KiB
Plaintext

// 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`.