We recently started upgrading our EKS clusters from 1.18 version to 1.19. One change that we did was to change our HPA manifest files to have apiVersion as autoscaling/v2beta2. I can see all three api versions are available in my cluster
kubectl api-versions | grep autoscaling
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
once the HPA file is applied autoscaling/v2beta2 is changed to autoscaling/v1. In the annotation block, I see the last applied changes showing, apiversion as autoscaling/v2beta2. Autoscaling is working fine and I don't see any errors in events. I am getting edgy to see the apiversion getting changed automatically and don't see any document explaining why is this happening and if this is expected behavior. Any inputs or explanation of this will be appreciated
This is working as intended. v1 is the default version of HPA so that's what you get if you don't request a specific version. You can get autoscaling/v2beta1 representation of your HPA by running kubectl get hpa.v2beta1.autoscaling -o yaml hpa-demo
A bit of explanaition: Internally all HPA objects are stored in the same way, regardless which version of API you used to create them. When you get HPA Kubernetes API server converts this internal representation to the version you requested.
https://github.com/kubernetes/kubernetes/issues/71556#issuecomment-442854276