Home > Software design >  helm: how to mount configMap if not supported by values.yaml?
helm: how to mount configMap if not supported by values.yaml?

Time:06-17

I am deploying authelia with their helm chart https://artifacthub.io/packages/helm/truecharts/authelia.

I need to mount a ConfigMap to a specific file in the authelia container, however this is not available as a templated value in the values.yaml.

I'm struggling to understand what is the recommended way of doing something like this... this could generalise to "how can I customise an helm deployment beyond what is allowed through the values.yaml?"

I can only think of getting all the yaml from the chart, make the change I need and deploy like that... It can't be the best way of doing this

CodePudding user response:

I would say you could try to use kubectl patch to mount the ConfigMap to the authelia container afterwards. Look here for more information.

So create a .yml file with Deployment, Replicaset or Statefulset and add the ConfigMap configuration (just check which Kubernetes object suits best for you according to the Helm deployment). After deploying the application using the Helm chart; run the command kubectl patch -f your-deployment-file.yml.

CodePudding user response:

Think of the helm package as it's a java package, you can't instantiate an object that has not been defined yet in that package and you are trying to do the same thing in helm.

If you are not familiar with helm, helm is a tool that helps you create abstraction on a specific k8s resources manifests and they are configured depending on you definition in values.yaml, each helm chart has its own deinition of templates, so If something you want to configure but isn't available yet in that chart you could either download the chart by running:

helm pull truecharts/authelia
# or 
helm fetch truecharts/authelia

extract the package then add your custom templates which as you said you are trying to refer to a configfile in your deployement so add a reference of that config in the deployment.yaml in the templates directory then if your definition and syntax are right you can add your specifications in the values.yaml.

Not sure how you want to bind your config but would that respong to your use case?

          envFrom:
          - configMapRef:
              name: {{ .Values.configmap }}

values.yaml

...
configmap: myconfigmap

make sure the configmap name specified exist so things work

make sure to read helm docs on how to create your own templates

  • Related