Description
For an HPA Object metric, describedObject identifies the object being measured and scaleTargetRef identifies the workload to scale.
Potential impact
If the reference is incomplete or the adapter cannot supply the metric, the workload may fail to scale as load rises. A poorly chosen target can also produce too many or too few replicas.
Remediation
- Check the measured object’s name, kind and API version. Match the metric name, target type, value and units to the metric the adapter provides.
- Set
scaleTargetRefand the minimum and maximum replicas for the workload. Under load, check HPA conditions, events and the actual replica count.
Examples
Provide the Deployment, Ingress and an adapter for requests-per-second. Adjust the sample target of 10k and the range of 1–10 replicas to your load.
Before
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metric:
name: requests-per-second
target:
type: Value
value: 10k
describedObject:
apiVersion: networking.k8s.io/v1
kind: Ingress
The Ingress reference omits the name of the object to measure.
After
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metric:
name: requests-per-second
describedObject:
apiVersion: networking.k8s.io/v1
kind: Ingress
name: main-route
target:
type: Value
value: 10k
The HPA measures main-route and scales the php-apache Deployment.