简体   繁体   English

头盔图中的动态命名空间变量

[英]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. 我与四个团队合作,这些团队使用与kubernetes命名空间中设置的完全相同的环境。 I have created helm charts to install those environments. 我创建了helm图表来安装这些环境。 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. 问题是我想用kubectl改变上下文,然后运行这些图表,而不是编辑每一个values.yaml来更改命名空间变量。

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. 谢谢。

The namespace value can be derived either from --namespace parameter which is the same namespace where helm chart is deployed to. 命名空间值可以从--namespace参数派生, --namespace参数与部署helm图表的命名空间相同。 In the charts it should be accessed with {{.Release.Namespace}} then. 在图表中,应该使用{{.Release.Namespace}}访问它。 Or you can set these namespaces using --set when deploying helm chart with helm upgrade . 或者,您可以在使用helm upgrade部署helm chart时使用--set设置这些命名空间。 If there are few environments you can access them as aliases in values.yaml and then set namespaces values for them like this: 如果环境很少,您可以在values.yaml它们作为别名访问,然后为它们设置名称空间值,如下所示:

helm upgrade \
   <chart_name> \
      <path_to_the_chart> \
        --set <environment_one>.namespace=namespace1 \
        --set <environment_two>.namespace=namespace2 \
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM