Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a namespace if it doesn't exists from HELM templates?

I have a kind: Namespace template yaml, as per below:

apiVersion: v1 kind: Namespace metadata:   name: {{ .Values.namespace }}   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 Kubernetes cluster?

Thanks.

like image 988
Kasun Siyambalapitiya Avatar asked Aug 10 '18 09:08

Kasun Siyambalapitiya


People also ask

How do I find my Kubernetes namespace?

To list the existing namespaces in a cluster 'kubectl get namespace' command is used. After executing the command, the following output will be generated: Observe that the Kubernetes object starts with four initial namespaces: Default, kube-node-lease, kube-public, and kube-system.


1 Answers

This feature is implemented in helm >= 3.2 (Pull Request)

Use --create-namespace in addition to --namespace <namespace>

like image 134
Mathieu Avatar answered Sep 30 '22 13:09

Mathieu