Azure Kubernetes Service Horizontal Pod Autoscaling Issue Resolution

Issue: In my Azure Kubernetes Service cluster, the horizontal pod autoscaler is not working due to resource cpu on pods is unknown.

Horizontal Pod Autoscaling increases (and decreases) the number of replicas (or pods) on deployments based on cpu usage. I have come across this issue a number of times when setting up HPA.

HPA not working – Events:

  Type     Reason               Age                     From                       Message
  —-     ——               —-                    —-                       ——-
Warning  FailedGetPodsMetric  3m46s (x3719 over 15h)  horizontal-pod-autoscaler  unable to get metric packets-per-second: unable to fetch metrics from custom metrics API: no custom metrics API ( registered

Ignore the get metrics packets-per second metric as that is not relevant for basic HPA.

kubectl get deployments


details-v1       1/1     1            1           455d
productpage-v1   5/5     5            5           455d
ratings-v1       1/1     1            1           455d
reviews-v1       1/1     1            1           455d
reviews-v2       1/1     1            1           455d
reviews-v3       1/1     1            1           455d

Check that the metrics server is running. It is installed by default with an AKS cluster deployment.

kubectl get deploy,svc -n kube-system | egrep metrics-server

kubectl get –raw “/apis/” 

Data is returned from all nodes, so metrics server is working 

One observation is that the k8s deployment does not have any resources defined under containers. Resources 


Ensure to include 

        - name: tmp 
          emptyDir: {} 
        - name: productpage 
          image: '' 
            - containerPort: 9080 
              protocol: TCP 
              cpu: 100m 
              memory: 128Mi 
              cpu: 50m 
              memory: 64Mi


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s