Kubernetes version: 1.25
Cloud being used: Azure
Host OS: Ubuntu
Hi, We are testing out Kubernetes 1.25 upgrade and as part of the upgrade we have been trying to update APIVersion for HorizontalPodAutoscaler from autoscaling/v2beta1 to autoscaling/v2. I haven’t changed anything on the helm chart but get the following error. The pod also fails to come up.
kube:W1123 19:00:26.932508 1253848 warnings.go:70] unknown field "spec.metrics[0].resource.targetAverageUtilization"
kube:Error: HorizontalPodAutoscaler.autoscaling "electrode-example-vzmyba" is invalid: [spec.metrics[0].resource.target.type: Required value: must specify a metric target type, spec.metrics[0].resource.target.type: Invalid value: "": must be either Utilization, Value, or AverageValue, spec.metrics[0].resource.target.averageUtilization: Required value: must set either a target raw value or a target utilization]
kube:helm.go:84: [debug] HorizontalPodAutoscaler.autoscaling "electrode-example-vzmyba" is invalid: [spec.metrics[0].resource.target.type: Required value: must specify a metric target type, spec.metrics[0].resource.target.type: Invalid value: "": must be either Utilization, Value, or AverageValue, spec.metrics[0].resource.target.averageUtilization: Required value: must set either a target raw value or a target utilization]
targetAverageUtilization field already existed with the current helm chart autoscaling/v2beta1. The Kubernetes spec for 1.25 mentions that nothing else needs to be changed except the APIVersion.
It seems that the targetAverageUtilization field does not exist in v2 version. There is a target object instead.
spec.metrics[0].resource.target.type is marked as required.
kubectl explain hpa.spec.metrics.resource --recursive --api-version=autoscaling/v2
GROUP: autoscaling
KIND: HorizontalPodAutoscaler
VERSION: v2
FIELD: resource <ResourceMetricSource>
DESCRIPTION:
resource refers to a resource metric (such as those specified in requests
and limits) known to Kubernetes describing each pod in the current scale
target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and
have special scaling options on top of those available to normal per-pod
metrics using the "pods" source.
ResourceMetricSource indicates how to scale on a resource metric known to
Kubernetes, as specified in requests and limits, describing each pod in the
current scale target (e.g. CPU or memory). The values will be averaged
together before being compared to the target. Such metrics are built in to
Kubernetes, and have special scaling options on top of those available to
normal per-pod metrics using the "pods" source. Only one "target" type
should be set.
FIELDS:
name <string> -required-
target <MetricTarget> -required-
averageUtilization <integer>
averageValue <Quantity>
type <string> -required-
value <Quantity>