Skip to content

fix: omit empty CRD metadata in helm chart - #126

Open
pyd-07 wants to merge 1 commit into
kyverno:mainfrom
pyd-07:fix/omit-empty-crd-metadata
Open

fix: omit empty CRD metadata in helm chart#126
pyd-07 wants to merge 1 commit into
kyverno:mainfrom
pyd-07:fix/omit-empty-crd-metadata

Conversation

@pyd-07

@pyd-07 pyd-07 commented Aug 26, 2026

Copy link
Copy Markdown

Explanation

This PR fixes a bug in the kyverno-api Helm chart where CRDs were rendered with empty metadata.labels and metadata.annotations maps when no custom metadata was configured. These empty maps can cause Argo CD to continuously report the CRDs as OutOfSync even though there is no meaningful difference.

Related issue

Fixes kyverno/kyverno#17276

Proposed Changes

  • Make CRD labels and annotations conditional on .Values.labels and .Values.annotations.
  • Regenerate all kyverno-api CRD Helm templates with the corrected generation logic.
  • Preserve the existing behavior when users explicitly configure labels or annotations.
  • Add a make helm-test regression check covering both default and explicitly configured metadata.
  • Enable the Helm regression test in CI.

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

The issue was caused by the CRD generation step unconditionally injecting the labels and annotations template blocks. Since both chart values default to empty maps, Helm rendered them as {}.

The fix keeps the existing metadata configuration mechanism but only emits the fields when values are actually provided. The regression test verifies that the fields are omitted with default values and preserved when explicitly configured.

Signed-off-by: pyd-07 <piyush.24448@knit.ac.in>
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.

chart: kyverno-api CRDs render empty metadata.labels/annotations, causing permanent Argo CD OutOfSync

1 participant