Hey, I am getting error of duplicate resource ```k...
# kubernetes
m
Hey, I am getting error of duplicate resource
Copy code
kubernetes:core/v1:ConfigMap redis-configuration create replacement [diff: ~metadata]; error: Duplicate resource URN 'urn:pulumi:staging::kubernetes-deployment::kubernetes:core/v1:ConfigMap::redis-configuration'; try giving it a uniqu
e name
Why URN doesn’t have namespace in it? Is it a bug ?
g
Normally, you can work around that kind of error with the
resourcePrefix
option. https://www.pulumi.com/docs/reference/pkg/kubernetes/yaml/configgroup/#resourceprefix_nodejs This most often happens if you are deploying the same manifest to multiple clusters in the same stack.
m
I only have one cluster but i have multiple namespaces. I am creating configmap with same namespace
Copy code
redis_config = Path("./redis-config").read_text()
        redis_configmap = f"redis-config-{tenant_name}"
        ConfigMap(
            redis_configmap,
            metadata={"name": redis_configmap, "namespace": namespace},
            data={"redis-config": redis_config},
        )
namespace are different but name is same
g
m
Yes that variable is right. I checked that and when i add unique name then it works fine with same variable
namespace: str = f"ns-{tenant_name}"
@gorgeous-egg-16927 any help. I tested it again and namespace is right. One more thing issue is consisted when i tried with same service name in different namespace. And i got same error
g
Sorry, I’m not sure what the problem is. If you file an issue with all of the relevant code, we can take a closer look. https://github.com/pulumi/pulumi-kubernetes/issues/new
m
@gorgeous-egg-16927 did you get a chance to take a look on my issue ? Did you need more information ? For now i added a prefix.
g
Just responded to the issue.
m
@gorgeous-egg-16927 thanks for your response. We can close the issue. But i have question. Can you tell why we have that restriction ? Why can’t we add namespace in all resource’s URN
g
That’s the way URNs currently work across all Pulumi resources (specifically CustomResources). I do think there is a case to be made for including the namespace in k8s resource URNs by default, but I’d have to think more about the implications for changing it.
m
I am purposing it because namespace is a differentiator for resources in k8s. You can have same name of the resources in two different ns. They are not same resource and k8s doesn’t enforce us to have unique name then why pulumi works in a different way. URN exist in state for defining uniqueness then why are you consider name for uniqueness for some resources. Q : Where can i get the list of resource who works like configmap ? Can we open the issue until you are investigating and discussing internally.
g
Where can i get the list of resource who works like configmap ?
For k8s, every resource except for
yaml
,
helm
, and
kustomize
, which are
ComponentResource
types.
👍 1
m
@gorgeous-egg-16927 Thanks for the help.
👍 1