Skip to content

fix: add standard labels to CRDs - #96

Open
Suhani95 wants to merge 5 commits into
kyverno:mainfrom
Suhani95:fix/crd-standard-labels-clean
Open

fix: add standard labels to CRDs#96
Suhani95 wants to merge 5 commits into
kyverno:mainfrom
Suhani95:fix/crd-standard-labels-clean

Conversation

@Suhani95

@Suhani95 Suhani95 commented Jun 6, 2026

Copy link
Copy Markdown

Explanation

This PR fixes an issue where CRDs generated by the kyverno-api Helm chart were rendered without standard Helm/Kubernetes labels when no custom labels were provided.

It adds the standard labels used across other Kyverno Helm charts while preserving support for user-defined labels through .Values.labels.

Label versioning

  • helm.sh/chart uses .Chart.Version and tracks the Helm chart package version.
  • app.kubernetes.io/version uses .Chart.AppVersion and tracks the kyverno-api release version.

This keeps the labels aligned with standard Helm conventions and allows the kyverno-api application version to be managed independently from the Helm chart package version.

appVersion has been added to Chart.yaml so the application version is explicitly defined and updated with kyverno-api releases.

Related issue

Fixes #71

Proposed Changes

  • Add standard Helm/Kubernetes labels to the kyverno-api.labels helper.
  • Use .Chart.AppVersion for app.kubernetes.io/version so it reflects the kyverno-api release version.
  • Add appVersion to Chart.yaml.
  • Preserve existing .Values.labels support for custom labels.
  • Ensure all generated CRDs receive consistent metadata labels.

Verification

Validated chart rendering with:

helm template test-release charts/kyverno-api

and linting with:

helm lint charts/kyverno-api

Verified that generated CRDs include the expected standard labels:

metadata:
  labels:
    helm.sh/chart: kyverno-api-v0.0.0
    app.kubernetes.io/component: kyverno-api
    app.kubernetes.io/instance: test-release
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: kyverno-api
    app.kubernetes.io/version: "v0.0.0"

Also verified that custom labels provided through .Values.labels continue to be preserved.

Validated released chart metadata behavior by packaging the chart with a release version:

helm package charts/kyverno-api \
  --version 0.0.1-alpha.3 \
  --app-version v0.0.1-alpha.3

Rendered output confirms:

helm.sh/chart: kyverno-api-0.0.1-alpha.3
app.kubernetes.io/version: "v0.0.1-alpha.3"

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

N/A

Signed-off-by: Suhani <suhani4630@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the kyverno-api Helm chart’s CRD templates so that generated CRDs include a consistent set of standard Helm/Kubernetes labels even when .Values.labels is empty, while still supporting user-provided custom labels.

Changes:

  • Updated the kyverno-api.labels helper to emit standard app.kubernetes.io/* and helm.sh/chart labels by default.
  • Preserved support for user-defined .Values.labels via templating (tpl) so custom labels can still be injected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread charts/kyverno-api/templates/_helpers.tpl Outdated
@Suhani95
Suhani95 requested a review from Copilot June 8, 2026 08:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread charts/kyverno-api/templates/_helpers.tpl
Comment thread charts/kyverno-api/templates/_helpers.tpl
Comment thread charts/kyverno-api/templates/_helpers.tpl
Signed-off-by: Suhani <suhani4630@gmail.com>
@Suhani95
Suhani95 force-pushed the fix/crd-standard-labels-clean branch from 1bb88b5 to d316ad4 Compare June 8, 2026 08:45
@Suhani95

Suhani95 commented Jul 8, 2026

Copy link
Copy Markdown
Author

@realshuting PTAL

@realshuting realshuting left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.kubernetes.io/part-of: kyverno-api
{{- end }}
{{- if not (hasKey $customLabels "app.kubernetes.io/version") }}
app.kubernetes.io/version: {{ include "kyverno-api.chartVersion" . }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chart version needs to point to a kyverno-api released version, see https://github.com/kyverno/api/releases.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated app.kubernetes.io/version to use .Chart.AppVersion instead of .Chart.Version. This label now tracks the kyverno-api release version, while the Helm chart version remains tracked separately through .Chart.Version. Added appVersion to Chart.yaml to manage the application version independently.

Comment thread charts/kyverno-api/templates/_helpers.tpl
@realshuting realshuting self-assigned this Jul 15, 2026
Signed-off-by: Suhani <suhani4630@gmail.com>
@Suhani95
Suhani95 force-pushed the fix/crd-standard-labels-clean branch from 9df56b0 to d2d763b Compare July 18, 2026 09:52
@Suhani95

Copy link
Copy Markdown
Author

And how is this wired to the Kyverno main chart https://github.com/kyverno/kyverno/blob/a4534389d6ce8cb12979dde56ba6c757a11691bf/charts/kyverno/Chart.yaml#L47?

kyverno-api is consumed by the Kyverno main chart as a Helm dependency:

- name: kyverno-api
  version: 0.0.1-alpha.2
  repository: "https://kyverno.github.io/api"

The kyverno-api chart is released independently. During the kyverno-api release workflow, both chart_version and app_version are populated from the release tag:

chart_version: ${{ steps.semver.outputs.fullversion }}
app_version: ${{ steps.semver.outputs.fullversion }}

With this change, app.kubernetes.io/version uses .Chart.AppVersion, so the rendered CRDs from the released kyverno-api chart reflect the kyverno-api release version.

@Suhani95
Suhani95 requested a review from realshuting July 18, 2026 10:30
@aerosouund

aerosouund commented Aug 19, 2026

Copy link
Copy Markdown
Member

@Suhani95
Currently, app-version points to the kyverno api chart's app version. I think it would be more helpful if it pointed to the corresponding kyverno version in which this api chart was released. e.g

helm package charts/kyverno-api \
  --version 0.0.1-alpha.3 \  # this can remain as the chart version normally
  --app-version v1.19.0

cc: @realshuting

Signed-off-by: Suhani <suhani4630@gmail.com>
@Suhani95

Copy link
Copy Markdown
Author

@aerosouund , I have addressed the requested change:

appVersion now points to the Kyverno v1.19.0 release
• Removed app_version from the workflow
• Kept chart_version driven by the API tag
• Updated the README badge according

Please take a look when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] helm chart: Add standard labels to resources like other kyverno charts do

4 participants