Skip to content

AWS EKS Horizontal Pod Autoscaler (HPA) showing as API version 'autoscaling/v1' in the console but my manifest file is 'autoscaling/v2'

0

I deployed a HPA to a cluster earlier with the API version 'autoscaling/v2' this is to make use of using multiple metric types to autoscale pods on. I deployed this manifest on the cluster that looks like the following:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: php-apache
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 50
  behaviour:
    scaleup:
      stabalizationWindowSeconds: 300
    scaledown:
      stabalizationWindowSeconds: 300

When I go to the console I see that the HPA is only showing the CPU utilisation. When I view the HPA page in raw view I notice that the API version is 'autoscaling/v1' and the CPU utilisation has been changed to '"targetCPUUtilizationPercentage": 50' - a method only used in the v1 manifests. It has also not configured the scale behaviours as this is also a v2 feature.

I assumed that EKS must only support v1. However, If I then connect to the cluster and run kubectl describe hpa <name> I see that both the CPU and memory scaling are configured as is the scale behaviour.

Other info:

  • Cluster Kubernetes version 1.32 (latest)

Any help on this would be appreciated. Is this a bug?

1 Answer
0

This situation is not a bug, but rather a result of how Kubernetes handles different API versions and how the AWS EKS console displays HPA information.

The Horizontal Pod Autoscaler (HPA) in Kubernetes has evolved over time, with v2 offering more advanced features like multiple metrics and custom scaling behaviors. Your manifest file is correctly using the autoscaling/v2 API version, which is the recommended version for newer Kubernetes clusters.

When you deploy an HPA using the v2 API, Kubernetes internally stores and uses all the information you've provided, including multiple metrics and custom behaviors. This is why when you use kubectl to describe the HPA, you see all the details you've configured.

However, the AWS EKS console may be designed to display HPA information using the v1 API format for compatibility reasons. The v1 API is more limited and only supports CPU-based autoscaling, which explains why you're only seeing CPU utilization in the console.

This discrepancy doesn't mean that your HPA isn't working as intended. The full configuration, including memory scaling and custom behaviors, is still active and functional on your cluster. The EKS console is simply providing a simplified view of the HPA.

To get the full details of your HPA, it's best to use kubectl commands like 'kubectl describe hpa' or 'kubectl get hpa -o yaml' directly on your cluster. These will show you the complete configuration as it's actually implemented.

If you need to view or manage the full HPA configuration through a graphical interface, you might consider using other Kubernetes dashboard solutions that support the v2 API visualization, or rely on the kubectl CLI for the most accurate and complete information about your HPAs.
Sources
Node and Workload Efficiency - Amazon EKS
Scale pod deployments with Horizontal Pod Autoscaler - Amazon EKS

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.