I try to modify the default namespace in my kubern...
# kubernetes
w
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
@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
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
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
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
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
what do you mean by "adopt" the resource? I guess you mean that pulumi should be the one that created it, correct?
c
no I mean that pulumi can manage a resource that already exists if you adopt it.
g
@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
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
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.