HPA configuration
Kruise workloads, such as CloneSet, Advanced StatefulSet, UnitedDeployment, are all implemented scale subresource, which means they allow systems like HorizontalPodAutoscaler and PodDisruptionBudget interact with these resources.
Examples use apiVersion: autoscaling/v2 (stable since Kubernetes 1.23). The older autoscaling/v2beta1 and autoscaling/v2beta2 APIs were removed in Kubernetes 1.25 and 1.26, respectively. For resource metrics, use resource.target.type: Utilization and averageUtilization instead of the deprecated targetAverageUtilization field.
Exampleâ
Just set the CloneSet's type and name into scaleTargetRef:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
# ...
spec:
scaleTargetRef:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
name: your-cloneset-name
Note that:
- The HPA's namespace should be same as the namespace of your CloneSet.
- The
apiVersioninscaleTargetRefshould be same as theapiVersionin your workload resource, such asapps.kruise.io/v1alpha1orapps.kruise.io/v1beta1. It depends on which version you are using for those workloads that have multiple versions, such as Advanced StatefulSet.