Kubernetes HPA on AKS is failing with error 'missing request for cpu'
resources
appears twice in your pod spec.
resources: # once here requests: cpu: 250m limits: cpu: 500m ports: - containerPort: 80 resources: {} # another here, clearing it
This is typically related to the metrics server.
Make sure you are not seeing anything unusual about the metrics server installation:
# This should show you metrics (they come from the metrics server)$ kubectl top pods$ kubectl top nodes
or check the logs:
$ kubectl logs <metrics-server-pod>
Also, check your kube-controller-manager logs for HPA events related entries.
Furthermore, if you'd like to explore more on whether your pods have missing requests/limits you can simply see the full output of your running pod managed by the HPA:
$ kubectl get pod <pod-name> -o=yaml
Some other people have had luck deleting and renaming the HPA too.
I was able to resolve the issue by changing the following in my kubernetes manifest file from this:
resources: requests: cpu: 250m limits: cpu: 500m
to the following:
resources: requests: cpu: "250m" limits: cpu: "500m"
HPA worked after that. Following is the GitHub link which gave the solution:https://github.com/kubernetes-sigs/metrics-server/issues/237But I did not add any Internal IP address command or anything else.