https://pulumi.com logo
Title
h

high-diamond-73999

05/05/2021, 2:50 PM
Hi everyone, I have a noob question about deploying to Kubernetes. How do I set the namespace and cluster to deploy into? Pulumi keeps trying to deploy in the "default" namespace, which I don't have permissions on. Setting my namespace like so didn't seem to do anything:
metadata=ObjectMetaArgs(labels=app_labels, namespace="mynamespace")
Thanks a lot in advance!
b

bumpy-summer-9075

05/05/2021, 2:56 PM
are you using the default provider?
if so, you can configure it in, well, your config something like
pulumi config set kubernetes:namespace foo
Otherwise if you create a provider programatically, it's one of the arguments: https://www.pulumi.com/docs/reference/pkg/kubernetes/provider/#namespace_nodejs
h

high-diamond-73999

05/05/2021, 2:59 PM
Thank you very much @bumpy-summer-9075!
pulumi config set kubernetes:namespace foo
did the trick! I'm using the default provider and had set my context via
kubectl config use-context
and
pulumi config set kubernetes:context
but for some reason it kept using the "default" context.
b

bumpy-summer-9075

05/05/2021, 2:59 PM
De rien ­čÖé
I'm keeping my eye on https://github.com/pulumi/pulumi/issues/2059 I really don't like that the default provider uses my local
kubectl
­čĹÇ 1
h

high-diamond-73999

05/05/2021, 3:04 PM
Thanks for the hint, I'll gladly join watching that one! I've just started using Pulumi this week and am working through one of the tutorials in the official docs. It makes using the local kubeconfig look super simple but with the info in the GitHub issue and my experience that Pulumi does not even read the current context correctly from kubeconfig, working with explicitly configured providers seems to be the way to go in any case.
b

billowy-army-68599

05/05/2021, 4:32 PM
can you sharw your full code @high-diamond-73999? setting the namespace via objectmetaargs should work
­čĹŹ 1
ÔśŁ´ŞĆ 1
h

high-diamond-73999

05/06/2021, 3:41 PM
@billowy-army-68599 Thanks for your interest! I'll share my code asap :)
Hi @billowy-army-68599 sorry for the delay - I was on vacation. Here is my main.py: https://pastebin.com/jVD86zDR If you need further files, let me know!
As mentioned above, I unsuccessfully tried the following on line 16 before:
metadata=ObjectMetaArgs(labels=app_labels, namespace="mynamespace")