if i created a namespace without a `provider` set ...
# kubernetes
c
if i created a namespace without a
provider
set and then later want to set the provider, is there a way to do this without having to recreate the namespace? I've tried updating the statefile directly with the provider I want from the
pulumi preview
diff, but Pulumi does like my edits
r
I think what you want is to consider: importing the resource, so, will pulumi now manage this? or, using this resource, so basically .get() on that resource. Since you’re trying to add this stuff to your state, I imagine you want to import the resource. Check this: • https://www.pulumi.com/docs/guides/adopting/import/
c
the resource was already created by pulumi, but without setting the provider it used my default kube context, which turned out by coincidence to be the correct cluster. But now I want to just add a provider to the namespace resource without actually changing its state in the k8s cluster
side-question how do I import a k8s object? With AWS resources it's mostly obvious since it's the resource ID but what do we use for importing k8s resources? I can't find an example in the docs
r
To your side-question: You would import the k8s resource’s name.
Here’s an example:
Copy code
const ns = new k8s.core.v1.Namespace("test", {
    metadata: {
        name: name
    },
}, {
    provider,
    import: name
});
c
thanks!
👍 1