helm-controller icon indicating copy to clipboard operation
helm-controller copied to clipboard

can you add kustomization replacements as a part of flux postRenderer kustomize

Open alokhom opened this issue 2 years ago • 3 comments

Describe the bug

its a not a bug but a feature request. I use fluxCD with a mix of kustomization and helm. And kustomization has a feature called replacements that can seek values from a source manifest and replace on the target manifest. I was not able to use it in HelmRelease portRenderer kustomize.

Steps to reproduce

For example i want to execute this using a HelmRelease of a ingress-nginx chart, I plan to use postRenderers kustomize, but there is no feature to take the ca value in a kustomize VAR and patch it using patchesJson6902 so kustomize replacements works damn good but there is no feature in the postRenderers kustomize to add replacements.

Expected behavior

allow replacements of values using postRenderer

Screenshots and recordings

No response

OS / Distro

wsl 2 with kind cluster and flux v2

Flux version

v0.30.2

Flux check

► checking prerequisites ✗ flux 0.30.2 <0.31.0 (new version is available, please upgrade) ✔ Kubernetes 1.23.4 >=1.20.6-0 ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v0.21.0 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v0.25.0 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v0.23.5 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v0.24.4 ✔ all checks passed

Git provider

bitbucket.org

Container Registry provider

No response

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

alokhom avatar Jun 06 '22 22:06 alokhom

@alokhom I think you may be able to achieve this by combining Kustomization variable substitution with the HelmRelease post-renderers.

pjbgf avatar Jun 15 '22 12:06 pjbgf

@pjbgf

We have a Kustomization with substitutions that refers to a HelmRelease, but Variable substitution does not work inside "postRenderers", any ideas?

cheers flash ⚡

flash-me avatar Jan 02 '23 09:01 flash-me

I've also just ran into this, there are use cases which you can't accomplish just with patches and variable substitution.

For example I'm trying to add an environment variable to all Deployments, StatefulSets and Daemonsets created by a chart and for this patches do not suffice because the objects that need to be patched are in a list.

Example for the above problem that works with kustomize and helm, but doesn't with flux because of the lack of support for replacements.

replacements:
  - source:
      kind: ConfigMap
      name: environment
      namespace: flux-system
      fieldPath: data.EXAMPLE
    targets:
      - select:
          group: apps
          version: v1
        reject:
          - kind: ControllerRevision
            group: apps
            version: v1
        fieldPaths:
          - spec.template.spec.containers.*.env.[name=EXAMPLE].value
        options:
          create: true

andrasmaroy avatar Oct 20 '23 16:10 andrasmaroy