Problem with HPA on AKS 1.28.9

Jörg Lang 120 Reputation points
2024-07-04T10:53:26.38+00:00

I have deployed a hello world app to test HPA on our AKS Cluster.

The HPA shows some warnings relateded to metrics

failed to get memory utilization: unable to get metrics for resource memory: no metrics returned from resource metrics API failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API

The deployment has been configured with requests and limits

    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 100m
        memory: 128Mi

The metric pods are also running

metrics-server-5cd44496f4-7h8ph 2/2 Running 0 41m metrics-server-5cd44496f4-wpc2w 2/2 Running 0 40m

Command kubectl top pod -A` returns Pods with Values for CPU and Memory, but not for my pod on CPU

NAME CPU(cores) MEMORY(bytes)
testchart-65bfc5f956-gthp5 0m 4Mi

What I'm doing wrong?
Many thanks

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,992 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 23,131 Reputation points
    2024-07-08T08:51:50.3666667+00:00

    Hello Jörg Lang,

    Thank you for reaching out to the Microsoft Q&A platform.

    It looks like the Horizontal Pod Autoscaler (HPA) is unable to get metrics for resource memory and CPU, which is causing the warnings you're seeing. This could be due to a few different reasons:

    The metrics server is not running or is not properly configured. The metrics server is responsible for collecting resource utilization data from the Kubernetes API server and making it available to other components, such as the HPA. You can check if the metrics server is running by running the command kubectl get pods -n kube-system | grep metrics-server.

    The HPA is not properly configured to use the metrics server. You can check the HPA configuration by running the command kubectl describe hpa <hpa-name>.

    There is not enough load on the application to trigger the HPA. The HPA will only scale up or down the number of replicas based on the resource utilization metrics it receives. If the application is not under enough load to trigger the HPA, it will not receive any metrics and the HPA will not scale the replicas.

    Regarding your deployment configuration, it looks like you have set resource requests and limits for CPU and memory. This is a good practice to ensure that your application has enough resources to run properly and to prevent resource contention with other applications running on the same node. However, it does not directly affect the HPA's ability to get metrics for resource utilization.

    I hope this helps you troubleshoot the issue. Let me know if you have any further questions or if there's anything else I can help you with.

    Please Accept Answer and hit Yes for "was this answer helpful" if this helps

    0 comments No comments