https://pulumi.com logo
Title
v

victorious-wall-1075

02/15/2022, 2:47 PM
Hello all.. I am getting started with Pulumi for Kubernetes platform (python): I am trying to create a namespace in my automation program:
ns = Namespace(kwargs["namespace"], metadata={"name": kwargs["namespace"]})
This works when the namespace does not exist. It fails with “already exists” if the namespace exists.
+  pulumi:pulumi:Stack pulumi-iac-k8-deploy-heml-rmjbpcxuer creating
 +  kubernetes:core/v1:Namespace iac-test creating
 +  kubernetes:core/v1:Namespace iac-test creating Retry #0; creation failed: namespaces "iac-test" already exists
How do I change this code so that Namespace is created only if it doesn’t exist. ? I am looking at the docs but cannot find an option to do this.. Help appreciated..
any insight into this?
b

bored-table-20691

02/17/2022, 3:40 AM
If you've previously created the namespace outside of Pulumi, you should import it into Pulumi