fix: add standard labels to CRDs - #96
Conversation
Signed-off-by: Suhani <suhani4630@gmail.com>
There was a problem hiding this comment.
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.labelshelper to emit standardapp.kubernetes.io/*andhelm.sh/chartlabels by default. - Preserved support for user-defined
.Values.labelsvia templating (tpl) so custom labels can still be injected.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Suhani <suhani4630@gmail.com>
1bb88b5 to
d316ad4
Compare
|
@realshuting PTAL |
realshuting
left a comment
There was a problem hiding this comment.
And how is this wired to the Kyverno main chart https://github.com/kyverno/kyverno/blob/a4534389d6ce8cb12979dde56ba6c757a11691bf/charts/kyverno/Chart.yaml#L47?
| app.kubernetes.io/part-of: kyverno-api | ||
| {{- end }} | ||
| {{- if not (hasKey $customLabels "app.kubernetes.io/version") }} | ||
| app.kubernetes.io/version: {{ include "kyverno-api.chartVersion" . }} |
There was a problem hiding this comment.
This chart version needs to point to a kyverno-api released version, see https://github.com/kyverno/api/releases.
There was a problem hiding this comment.
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.
Signed-off-by: Suhani <suhani4630@gmail.com>
9df56b0 to
d2d763b
Compare
- name: kyverno-api
version: 0.0.1-alpha.2
repository: "https://kyverno.github.io/api"The chart_version: ${{ steps.semver.outputs.fullversion }}
app_version: ${{ steps.semver.outputs.fullversion }}With this change, |
|
@Suhani95 helm package charts/kyverno-api \
--version 0.0.1-alpha.3 \ # this can remain as the chart version normally
--app-version v1.19.0cc: @realshuting |
Signed-off-by: Suhani <suhani4630@gmail.com>
|
@aerosouund , I have addressed the requested change: • Please take a look when you get a chance. |
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/chartuses.Chart.Versionand tracks the Helm chart package version.app.kubernetes.io/versionuses.Chart.AppVersionand 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.
appVersionhas been added toChart.yamlso the application version is explicitly defined and updated with kyverno-api releases.Related issue
Fixes #71
Proposed Changes
kyverno-api.labelshelper..Chart.AppVersionforapp.kubernetes.io/versionso it reflects the kyverno-api release version.appVersiontoChart.yaml..Values.labelssupport for custom labels.Verification
Validated chart rendering with:
and linting with:
Verified that generated CRDs include the expected standard labels:
Also verified that custom labels provided through
.Values.labelscontinue to be preserved.Validated released chart metadata behavior by packaging the chart with a release version:
Rendered output confirms:
Checklist
Further Comments
N/A