Trying to replace values.yaml file for helm chart in Kustomize overlay

146 Views Asked by At

I'm using kustomize with helm via ArgoCD to manage my Kubernetes clusters, which requires some small changes to the values.yaml files between environments.

My folder structure is:

.
|-- base
|   |-- ns.yaml
|   |-- kustomization.yaml
|   `-- values.yaml
`-- overlay
    |-- kustomization.yaml
    `-- values.yaml

The helm chart is defined in base/kustomization.yaml, and overlay/kustomization.yaml loads the resources from ../base

I can't find a way to get kustomize to render the chart with the values file in the overlay directory. Is this possible?

I've tried using a HelmChartInflationGenerator resource and patching it - nothing happens

I've tried defining the helm chart again in overlay\kustomization.yaml - I get a duplicate resource conflict

1

There are 1 best solutions below

0
syed hyder On

I see a lot of discussions happening around this. As of now, there is no simple and straight forward way you can get around with this. But one thing what you can do is to patch the specific values that have been updated in your overlay layer.

So, the helm chart gets built in your base layer and can patch it with the values you want in the overlay layer.

You can see a detailed discussion around this at https://github.com/kubernetes-sigs/kustomize/issues/4658

In simple your folder structure may look something like this

.
|-- base
|   |-- ns.yaml
|   |-- kustomization.yaml
|   `-- values.yaml
`-- overlay
    |-- kustomization.yaml
    `-- patches
        |-- patch1.yaml
        `-- patch2.yaml

You will call you patch in overlay/kustomization.yaml as follows.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../base

patches:
- path: patches/patch1.yaml
  target:
    ...
- path: patches/patch2.yaml
  target:
    ...