Dynamic namespace variable in helm chart

情到浓时终转凉″ 提交于 2020-02-04 01:54:10

问题


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.


回答1:


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 \
...


来源:https://stackoverflow.com/questions/55376368/dynamic-namespace-variable-in-helm-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!