https://pulumi.com logo
#kubernetes
Title
# kubernetes
w

wet-noon-14291

05/22/2020, 9:03 PM
I try to modify the default namespace in my kubernetes cluster using
ConfigFile
and an actual manifest. Running the manifest with
kubectl apply -f
works, but it fails through pulumi. The error message is: error: resource default was not successfully created by the Kubernetes API server : namespaces "default" already exists So I guess pulumi does something else than
kubectl apply
. Is there a way to run a manifest that updates a namespace? The part in the code I have now looks like this (F#)
Copy code
ConfigFile("proxy_inject",
        ConfigFileArgs(
            File = input "manifests/proxy_inject.yaml"
        )) |> ignore
c

creamy-potato-29402

05/22/2020, 11:05 PM
@wet-noon-14291 that error is saying that you’re trying to create a namespace called “default”. pulumi actually does do the equivalent of `kubectl apply`—and I would be very very surprised if there was a bug that caused pulumi to spuriously try to create a namespace called default.
the default namespace not only can’t be created, it also can’t be deleted. the only way you could delete it is to manually go delete the entry in etcd.
w

wet-noon-14291

05/23/2020, 8:37 PM
Thanks for explaining @creamy-potato-29402. But why does it work to do the modification when I run
kubectl apply -f <file>
but it doesn't work when running through pulumi.
c

creamy-potato-29402

05/24/2020, 6:48 PM
kubectl is vastly more permissive?
are you creating the default namespace in this file? you should not do that.
kubectl generally is not... good. I would not use it as a reference for what is good behavior. if it doesn't complain about claiming to create the default namespace (and I expect it wouldn't) then it's doing something that is bad. :)
w

wet-noon-14291

05/25/2020, 12:31 PM
Kubectl doesn’t object, it just modifies the default namespace adding the annotation that I wanted. I’m by no means an expert so can’t tell if they do it right or not. Anyhow, I guess the correct approach is to create a new namespace.
c

creamy-potato-29402

05/25/2020, 5:32 PM
to modify it in pulumi you'll have to adopt the resource. I'm on my phone so I can't find it for you but if you search the docs it should come to.
w

wet-noon-14291

05/26/2020, 6:57 AM
what do you mean by "adopt" the resource? I guess you mean that pulumi should be the one that created it, correct?
c

creamy-potato-29402

05/26/2020, 6:05 PM
no I mean that pulumi can manage a resource that already exists if you adopt it.
g

gentle-diamond-70147

05/26/2020, 7:28 PM
@creamy-potato-29402 is referring to the ability to
import
pre-existing resources, such that you can manage them in your Pulumi app. There is a guide on this at https://www.pulumi.com/docs/guides/adopting/import/.
Though if the default namespace cannot be deleted, you might get into a weird "state" if you adopt the default namespace and then do
pulumi destroy
.
w

wet-noon-14291

05/26/2020, 7:29 PM
Yeah, I found that yesterday. But thanks. In my case I think the right thing is to not use the default namespace, but knowing about
import
is really valuable.
c

creamy-potato-29402

05/27/2020, 4:09 AM
yeah, I tend not to tell people not to do stuff like that, but generally you want to steer clear of messing with the default namespace.
3 Views