Any tips or best practices for Kubernetes namespac...
# general
f
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
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
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
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
@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
thank you, exactly what I needed!
👍 1