舵图中的动态名称空间变量 [英] Dynamic namespace variable in helm chart

查看:95
本文介绍了舵图中的动态名称空间变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与四个使用kubernetes命名空间中设置的完全相同环境的团队合作. 我已经创建了头盔图来安装这些环境.一切正常,但由于主机名中的以下格式,我必须手动创建入口:

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>

问题是,我只想使用kubectl更改上下文,然后运行这些图表,而不是编辑每个单独的值.yaml来更改名称空间变量.

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?

谢谢.

推荐答案

名称空间值可以从--namespace参数派生,该参数与部署舵图的名称空间相同.在图表中,然后应使用{{.Release.Namespace}}对其进行访问. 或者,当使用helm upgrade部署头盔图表时,可以使用--set设置这些命名空间.如果环境很少,则可以在values.yaml中作为别名访问它们,然后像​​这样为它们设置名称空间值:

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

这篇关于舵图中的动态名称空间变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆