want yaml file of Horizontal pod autoscaler for CPU and Memory metrics

38 Views Asked by At

I got the command for hpa but it only for cpu metric. I want to configure hpa for cpu as well as memory metrics

I tried editing hpa file and make changes there itself but failed.

then tried this yaml file but still got error. enter image description here

1

There are 1 best solutions below

1
Navid_Shaikh On

I got the reason. In target section, Type must be there. it solved my error

apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: ph-prod-hpa namespace: default spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: ph-prod minReplicas: 1 maxReplicas: 5 metrics:

  • type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70
  • type: Resource resource: name: memory target: type: Utilization averageUtilization: 80