Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kustomize labels property #794

Open
merusso opened this issue Oct 13, 2023 · 0 comments
Open

Support Kustomize labels property #794

merusso opened this issue Oct 13, 2023 · 0 comments

Comments

@merusso
Copy link

merusso commented Oct 13, 2023

I'd like to use Kustomize labels to set k8s labels across all objects in a Helm release.

According to the docs, HelmRelease.spec.postRenderers.kustomize doesn't expose this labels property.

For example, I want to set the labels foo: foo1 and bar: bar1 on all Helm objects. If I could use the Kustomize labels property, I could do the following:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
spec:
  postRenderers:
  - kustomize:
      labels:
        - pairs:
            foo: foo1
            bar: bar1
      includeTemplates: true

Otherwise, I would need to perform some kind of patch, which is harder and has some tricky edge cases. Example:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
spec:
  postRenderers:
  - kustomize:
      patchesJson6902:
      # Patch all objects
      # Note: This fails if a Helm template is missing metadata.labels property
      - patch:
        - op: add
          path: /metadata/labels/foo
          value: foo1
        - op: add
          path: /metadata/labels/bar
          value: bar1
        target:
          name: .*
      # Patch Deployment's Pod template
      - patch:
        - op: add
          path: /spec/template/metadata/labels/foo
          value: foo1
        - op: add
          path: /spec/template/metadata/labels/bar
          value: bar1
        target:
          kind: Deployment
          name: .*

Originally posted by @merusso in fluxcd/flux2#3687

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

No branches or pull requests

1 participant