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

colossal-australia-65039

05/07/2021, 10:55 PM
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

rich-farmer-40546

05/07/2021, 11:24 PM
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

colossal-australia-65039

05/07/2021, 11:29 PM
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

rich-farmer-40546

05/07/2021, 11:33 PM
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

colossal-australia-65039

05/07/2021, 11:36 PM
thanks!
👍 1
4 Views