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

agreeable-ram-97887

05/05/2021, 10:49 AM
Hi gang! I’m running into some trouble with a Pulumi project which manages multiple kubernetes clusters (via AWS EKS, in case it’s relevant). In short, I am trying to deploy a helm chart (metrics-server) into each cluster and am getting the error:
Copy code
Duplicate resource URN 'urn:pulumi:prod::submission_strategy::<kubernetes:helm.sh/v3:Chart$kubernetes:apiregistration.k8s.io/v1:APIService::v1beta1.metrics.k8s.io>'; try giving it a unique name
Note that I am already using the
resource_prefix
argument in my “ChartOpts” object to separate the resources URI’s for each cluster, and except for the one “APIService” resource this appears to work as expected. Looking into the docs, I don’t see a clear way to specify the “APIService” resource URN 😕. Anyone have any suggestions ?
here is the code I’m using:
Copy code
# Install "metrics-server"
for env in BUILD_ENVIRONMENTS:
    with open(path.join(FILE_DIR, "metrics_values.yaml")) as fin:
        metrics_values = yaml.load(fin)

    k8s.helm.v3.Chart(
        f"metrics-server",
        k8s.helm.v3.ChartOpts(
            chart="metrics-server",
            repo="bitnami",
            fetch_opts=k8s.helm.v3.FetchOpts(
                repo="<https://charts.bitnami.com/bitnami>",
                version="5.8.6",
            ),
            values=metrics_values,
            resource_prefix=env,
        ),
        opts=pulumi.ResourceOptions(
            provider=k8s_providers[env],
            depends_on=eks_node_groups[env],
        ),
    )
l

lemon-monkey-228

05/05/2021, 11:07 AM
resource_prefix
is for the k8s resources the Helm chart creates
The URN is Pulumi identifier built from the name you provide Pulumi
k8s.helm.v3.Chart
resource, which is
metrics-server
in this case
Try adding a unique suffix like
f"metrics-server-{env}"
a

agreeable-ram-97887

05/05/2021, 11:12 AM
thanks for the tip @lemon-monkey-228, although I’ve tried that one as well and it led to the same error (see the screen shot below)
l

lemon-monkey-228

05/05/2021, 11:12 AM
oh, is it trying to track each resource created by Helm?
a

agreeable-ram-97887

05/05/2021, 11:13 AM
I guess so. Isn’t that what we want Pulumi to do? 🤷
l

lemon-monkey-228

05/05/2021, 11:15 AM
I’ve mostly been using Pulumi for deploying Kubernetes resources/Helm charts without state tracking so far
In environments where I can just nuke it and redeploy
a

agreeable-ram-97887

05/05/2021, 11:16 AM
It’s interesting that the pulumi resource name is specified as “metrics-server-{env}“, but the URN is just specified as “…metrics.k8s.io”. Where does this come from 🤔
In environments where I can just nuke it and redeploy
Yeah, if I were only building one environment at a time, then this would work. But the issue is specifically something I’ve run into when trying to manage multiple environment stages in one project 🙈
I think this may be a bug, actually. Apparently the ApiService is optionally created by the helm chart (as in, it’s not something implicitly created by Pulumi) which means it shouldn’t be any different from the other resources created by the Chart. But nevertheless Pulumi doesn’t understand it as something which should have it’s URN updated against the
resource_prefix
input 🤔
l

lemon-monkey-228

05/05/2021, 12:05 PM
Why not use 1 project with multiple stacks?
One per environment
a

agreeable-ram-97887

05/05/2021, 12:14 PM
In this case Im trying to put them all into one stack because all of my k8s clusters are all apart of one “product”, which itself should have dev/test/prod environments. But, in the end, that might be the way to go 😅
But, generally speaking, I think Pulumi should nevertheless be able to manage multiple k8s clusters in a single project/stack. And up until encountering this issue, it can!
l

lemon-monkey-228

05/05/2021, 12:15 PM
makes sense if youre deploying them as a single unit
maybe file a bug report
6 Views