Warning
You are currently viewing v"2.14" of the documentation and it is not the latest. For the most recent documentation, kindly click here.
Notice:
- This scaler requires prerequisites. See the ‘Prerequisites’ section.
- This scaler can scale to 0 only when user defines at least one additional scaler which is not CPU or Memory (eg. Kafka + CPU, or Prometheus + CPU) and
minReplicaCount
is 0.- This scaler only applies to ScaledObject, not to Scaling Jobs.
KEDA uses standard cpu
and memory
metrics from the Kubernetes Metrics Server, which is not installed by default on certain Kubernetes deployments such as EKS on AWS. Additionally, the resources
section of the relevant Kubernetes Pods must include at least one of requests
or limits
.
resources
section with specified requests
(or limits
). See Resource Management for Pods and Containers. If the resources section is empty (resources: {}
or similar), KEDA checks if the defaultRequest
(or default
for limits) is set in LimitRange
for the Container
type in the same namespace. If defaultRequest
(or default
for limits) is missing too, the error missing request for {cpu/memory}
occurs.# a working example of resources with specified requests
spec:
containers:
- name: app
image: images.my-company.example/app:v4
resources:
requests:
memory: "128Mi"
cpu: "500m"
This specification describes the cpu
trigger that scales based on cpu metrics.
triggers:
- type: cpu
metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue'
metadata:
type: Utilization # Deprecated in favor of trigger.metricType; allowed types are 'Utilization' or 'AverageValue'
value: "60"
containerName: "" # Optional. You can use this to target a specific container in a pod
Parameter list:
type
- Type of metric to use. Options are Utilization
, or AverageValue
.value
- Value to trigger scaling actions for:
Utilization
, the target value is the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.AverageValue
, the target value is the target value of the average of the metric across all relevant pods (quantity).containerName
- Name of the specific container to scale based on its CPU, rather than the entire pod. Defaults to empty if not specified.💡 NOTE:
containerName
parameter requires Kubernetes cluster version 1.20 or higher withHPAContainerMetrics
feature enabled. Please see container resource metrics for more information.
💡 NOTE: The
type
parameter is deprecated in favor of the globalmetricType
and will be removed in a future release. Users are advised to usemetricType
instead.
The following example targets CPU utilization of entire pod. If the pod has multiple containers, it will be sum of all the containers in it.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: cpu-scaledobject
namespace: default
spec:
scaleTargetRef:
name: my-deployment
triggers:
- type: cpu
metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue'
metadata:
value: "50"
The following example targets CPU utilization of a specific container (foo
) in a pod.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: cpu-scaledobject
namespace: default
spec:
scaleTargetRef:
name: my-deployment
triggers:
- type: cpu
metricType: Utilization # Allowed types are 'Utilization' or 'AverageValue'
metadata:
value: "50"
containerName: "foo"