Search code examples
kuberneteshorizontalpodautoscaler

Why is there an error in Horizontal Pod Autoscaler Yaml?


2022-08-17T16:14:15.5682728Z error: error validating "deployment.yml": error validating data: ValidationError(HorizontalPodAutoscaler.spec.metrics[1].resource.target.averageUtilization): invalid type for io.k8s.api.autoscaling.v2.MetricTarget.averageUtilization: got "string", expected "integer"; if you choose to ignore these errors, turn validation off with --validate=false
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: hpa-xyz
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: StatefulSet
    name: XYZ
  minReplicas: ${MinRequestForwarderReplicas}
  maxReplicas: ${MaxRequestForwarderReplicas}
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 75
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 1500Mi

I tried the memory "averageUtilization" values with 1.5Gi and "1.5Gi" with double quotes. Can anyone check and let me know if I am missing something here?


Solution

  • averageUtilization: 
    

    is represented as a percent of requested memory. So you're wrong with Mi.

    It should be.

    averageUtilization: 65 
    

    Specify averageUtilization and a target average memory utilization over all the pods, represented as a percent of requested memory. The target pods must have memory requests configured.