如果HELM模板中不存在命名空间,如何创建该命名空间 [英] How to create a namespace if it doesn't exists from HELM templates

查看:3126
本文介绍了如果HELM模板中不存在命名空间,如何创建该命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个kind: Namespace模板yaml,如下所示,

I have a kind: Namespace template yaml like follows,

apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.namespace }}
  namespace: ""

当且仅当以上命名空间({{ .Values.namespace }})在指定的kubernets集群中没有退出时,我如何使helm install创建上述命名空间({{ .Values.namespace }})

How do I make helm install create the above-given namespace ({{ .Values.namespace }}) if and only if above namespace ({{ .Values.namespace }}) doesn't exits in the pointed kubernets cluster

推荐答案

对于helm2,最好尽可能避免将名称空间创建为图表内容的一部分,并由helm管理.带有--namespace=<namespace_name>选项的helm install应该为您自动创建一个名称空间.您可以使用{{ .Release.Namespace }}在图表中引用该名称空间.当前只有一个在公共头盔/图表存储库中创建名称空间的示例,它使用

For helm2 it's best to avoiding creating the namespace as part of your chart content if at all possible and letting helm manage it. helm install with the --namespace=<namespace_name> option should create a namespace for you automatically. You can reference that namespace in your chart with {{ .Release.Namespace }}. There's currently only one example of creating a namespace in the public helm/charts repo and it uses a manual flag for checking whether to create it

由于helm3的功能已更改,因此存在与此相关的github问题

For helm3 functionality has changed and there's a github issue on this

这篇关于如果HELM模板中不存在命名空间,如何创建该命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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