UNCLASSIFIED - NO CUI

HorizontalPodAutoscaler should support new API version: autoscaling/v2

Problem Description:

Kubernetes has removed autoscaling/v2beta2 in K8s 1.26.

Error:

Helm install failed: unable to build kubernetes objects from release manifest: resource mapping not found for name: "keycloak" namespace: "" from "": no matches for kind "HorizontalPodAutoscaler" in version "autoscaling/v2beta2"
ensure CRDs are installed first

Workaround:

Use the postRenderers on the Helm Release to patch the API version

postRenderers:
  - kustomize:
      patchesJson6902:
        - target:
            kind: HorizontalPodAutoscaler
            name: keycloak
          patch:
            - op: replace
              path: /apiVersion
              value: autoscaling/v2

Recommended solution:

Use Helm to query the available API versions in the cluster, then apply the appropriate API version.

Follow other upstream solutions for using version based on what's available, eg:

{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }}
apiVersion: autoscaling/v2
{{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2beta1
{{- end }}
Edited by Ryan Garcia