Search code examples
kuberneteskubernetes-helm

Include configmap with non-managed helm chart


I was wondering if it is possible to include a configmap with its own values.yml file with a helm chart repository that I am not managing locally. This way, I can uninstall the resource with the name of the chart.

Example:

I am using New Relics Helm chart repository and installing the helm charts using their repo name. I want to include a configmap used for infrastructure settings with the same helm deployment without having to use a kubectl apply to add it independently.

I also want to avoid having to manage the repo locally as I am pinning the version and other values separately from the help upgrade install set triggers.


Solution

  • What you could do is use Kustomize. Let me show you with an example that I use for my Prometheus installation.

    I'm using the kube-prometheus-stack helm chart, but add some more custom resources like a SecretProviderClass.

    kustomization.yaml:

    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    
    helmCharts:
      - name: kube-prometheus-stack
        repo: https://prometheus-community.github.io/helm-charts
        version: 39.11.0
        releaseName: prometheus
        namespace: prometheus
        valuesFile: values.yaml
        includeCRDs: true
    
    resources:
      - secretproviderclass.yaml
    
    

    I can then build the Kustomize yaml by running kustomize build . --enable-helm from within the same folder as where my kustomization.yaml file is.

    I use this with my gitops setup, but you can use this standalone as well.

    My folder structure would look something like this:

    .
    ├── kustomization.yaml
    ├── secretproviderclass.yaml
    └── values.yaml