Skip to content

[kube-state-metrics] Wrong apiVersion for PodDisruptionBudget #5131

Open
@cyrilgdn

Description

@cyrilgdn

Describe the bug a clear and concise description of what the bug is.

We enabled podDisruptionBudget in kube-state-metrics chart, when rendering the chart locally with helm template --kube-version 1.31.0, the apiVersion of the PodDisruptionBudget is wrongly set to policy/v1beta1 instead of policy/v1

$ helm template . --kube-version 1.31.0 | grep "apiVersion: policy"                                     
apiVersion: policy/v1beta1

What's your helm version?

version.BuildInfo{Version:"v3.16.3", GitCommit:"cfd07493f46efc9debd9cc1b02a0961186df7fdf", GitTreeState:"clean", GoVersion:"go1.22.7"}

What's your kubectl version?

Client Version: v1.31.4 Kustomize Version: v5.4.2 Server Version: v1.31.2-gke.1354000

Which chart?

kube-state-metrics

What's the chart version?

5.28.0 (tested on main too)

What happened?

When enabling the podDisprutionBudget, the generated apiVersion by helm template --kube-version 1.31.0 command is wrong (policy/v1beta1 instead of policy/v1 which was released many Kubernetes versions ago)

What you expected to happen?

By enabling podDisruptionBudget I expect the apiVersion of PodDisruptionBudget to be policy/v1 in the output of helm template --kube-version 1.31.0

Enter the changed values of values.yaml?

podDisruptionBudget:
  minAvailable: 1

Enter the command that you execute and failing/misfunctioning.

helm template . --kube-version 1.31.0 | grep "apiVersion: policy"                                     

Anything else we need to know?

It seems to be linked to this helm/helm#11809 but the conclusion is not clear to me 🤔

I don't know if it's proper fix but if we change this line:

{{ if $.Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" -}}

by:

{{ if $.Capabilities.APIVersions.Has "policy/v1" -}}

the apiVersion is properly set to policy/v1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions