https://pulumi.com logo
#general
Title
# general
f

flat-guitar-86436

09/12/2019, 8:29 PM
Any tips or best practices for Kubernetes namespaces vs Pulumi’s stacks? I’m reading the docs right now, not sure if I saw something about it
maybe pulumi should be managing the namespaces?
in the examples, e.g. deploying a helm chart, I assume the default namespace is used https://www.pulumi.com/docs/guides/crosswalk/aws/eks/#deploying-existing-helm-charts-to-your-eks-cluster
g

gorgeous-egg-16927

09/12/2019, 8:43 PM
I don’t quite understand the question. The namespace isn’t tied to Pulumi stacks at all, and you can set whatever namespace you want for each resource.
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/kubernetes/helm/v2/#ChartOpts-namespace can be used to set the namespace for Helm charts, although some charts don’t support this correctly yet
r

rhythmic-finland-36256

09/13/2019, 2:35 PM
This is heavily depending on how you treat your clusters. We separate kubernetes clusters and don’t deploy prod and test on the same cluster, so we are able to use kind of fixed namespaces over the stages. But in some cases we also deploy two stacks to the same cluster (e.g. when having two different test-setups). You need to be careful to handle namespaces explicitly because there is the easy fallback to the current namespace that is set in the provider (using the kubeconfig for example). We don’t want to rely on such an ambient config. If you are using helm, have a look at the
transformations
as this provider does local templating only and some charts don’t set the namespace (because it usually is managed by tiller).
👍 1
f

flat-guitar-86436

09/13/2019, 4:41 PM
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/kubernetes/helm/v2/#ChartOpts-namespace can be used to set the namespace for Helm charts, although some charts don’t support this correctly yet (edited)
when I used the
namespace
option, with the hashicorp Vault helm chart, deploy would fail since the namespace did not exist, any thoughts on that? can I create the namespace with pulumi or this is something that should be handled by helm?
@rhythmic-finland-36256 thanks for the insight, really what I needed to know from others
g

gorgeous-egg-16927

09/13/2019, 5:13 PM
@flat-guitar-86436 You have to create the namespace yourself. Here’s an example where I’m creating the namespace and then referencing it in the Chart. (This particular chart doesn’t support the namespace flag correctly, so I’m setting it with a transformation here) - https://github.com/pulumi/pulumi-kubernetes/blob/master/tests/examples/helm/index.ts#L18-L58
👍 2
f

flat-guitar-86436

09/13/2019, 5:14 PM
thank you, exactly what I needed!
👍 1