Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic namespace variable in helm chart

I work with four teams that are using exactly the same environments that are set up in kubernetes namespaces. I have created helm charts to install those environments. Everything works fine but I have to create ingresses by hand because of the following format in hostname:

<namespace>.<app>.<k8sdomain>

The thing is I would like to just change context with kubectl and then run those charts instead of editing every single values.yaml to change namespace variable.

Is it possible to use some predefined or dynamic variable that would add the correct namespace to the host in ingress?

Or is there any other solution that would help me to solve this problem?

Thanks.

like image 905
Thomas Avatar asked Apr 19 '26 19:04

Thomas


1 Answers

The namespace value can be derived either from --namespace parameter which is the same namespace where helm chart is deployed to. In the charts it should be accessed with {{.Release.Namespace}} then. Or you can set these namespaces using --set when deploying helm chart with helm upgrade. If there are few environments you can access them as aliases in values.yaml and then set namespaces values for them like this:

helm upgrade \
   <chart_name> \
      <path_to_the_chart> \
        --set <environment_one>.namespace=namespace1 \
        --set <environment_two>.namespace=namespace2 \
...
like image 162
Anna Slastnikova Avatar answered Apr 23 '26 16:04

Anna Slastnikova



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!