舵图中的动态名称空间变量

Tho*_*mas 2 kubernetes kubernetes-helm

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

<namespace>.<app>.<k8sdomain>
Run Code Online (Sandbox Code Playgroud)

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

是否可以使用一些预定义的或动态的变量,这些变量将为入口的主机添加正确的名称空间?

还是有其他解决方案可以帮助我解决此问题?

谢谢。

Ann*_*ova 6

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 \
...
Run Code Online (Sandbox Code Playgroud)