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

magnificent-student-85498

02/11/2021, 4:20 PM
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

gorgeous-egg-16927

02/11/2021, 5:15 PM
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

magnificent-student-85498

02/11/2021, 5:19 PM
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

gorgeous-egg-16927

02/11/2021, 5:38 PM
m

magnificent-student-85498

02/11/2021, 5:40 PM
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

gorgeous-egg-16927

02/11/2021, 7:44 PM
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

magnificent-student-85498

02/12/2021, 7:27 AM
@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

gorgeous-egg-16927

02/12/2021, 5:27 PM
Just responded to the issue.
m

magnificent-student-85498

02/12/2021, 5:39 PM
@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

gorgeous-egg-16927

02/12/2021, 5:46 PM
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

magnificent-student-85498

02/12/2021, 5:53 PM
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

gorgeous-egg-16927

02/12/2021, 6:01 PM
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

magnificent-student-85498

02/12/2021, 6:14 PM
@gorgeous-egg-16927 Thanks for the help.
👍 1
5 Views