Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm 3: Chart with dependencies fails to deploy #1017

Closed
moconno opened this issue Mar 3, 2020 · 2 comments
Closed

Helm 3: Chart with dependencies fails to deploy #1017

moconno opened this issue Mar 3, 2020 · 2 comments
Assignees
Milestone

Comments

@moconno
Copy link

moconno commented Mar 3, 2020

Problem description

I am deploying a helm chart with dependencies using pulumi helm. Pulumi preview fails with a duplicate urn error. I ran with debug and noticed a service account was being created twice.

  • Other:

To verify this was an issue with subcharts, I ran pulumi preview on each chart independently and pulumi preview passed.

Chart dependency:

Errors & Logs

kubernetes:core:ServiceAccount dev/kong-chart-kong create 
 +  kubernetes:core:ConfigMap kong-chart-kong-default-custom-server-blocks create 
 +  kubernetes:core:Service kong-chart-kong-manager create 
 +  kubernetes:core:ServiceAccount dev/kong-chart-kong create error: Duplicate resource URN 'urn:pulumi:dev-gcloud-us-east4::kong::kubernetes:helm.sh/v2:Chart$kubernetes:core/v1:ServiceAccount::dev/kong-chart-kong'; try giving it a unique name

debug: Registering resource: t=kubernetes:core/v1:ServiceAccount, name=dev/w2g-kong-chart-kong, custom=true
    debug: Registering resource: t=kubernetes:core/v1:ServiceAccount, name=dev/w2g-kong-chart-kong, custom=true
@lblackstone lblackstone self-assigned this Mar 3, 2020
@lblackstone
Copy link
Member

I initially thought the problem was related to using a subchart, but that turned out to be a red herring.

The actual problem here is that the kong chart includes the ServiceAccount twice:

  1. kong/templates/migrations-pre-upgrade.yaml
  2. kong/templates/controller-service-account.yaml

The migrations one includes Helm hooks, which we don't currently support (#555), but you can work around this by removing that resource with a transformation:

const chartName = "kong-chart";
new k8s.helm.v2.Chart(chartName, {
    chart: "kong/kong",
    version: "1.1.0",
    transformations: [
        (obj: any) => {
            if (obj.kind === "ServiceAccount" && obj.metadata.name === `${chartName}-kong`) {
                // Omit this resource (https://github.com/pulumi/pulumi-kubernetes/issues/486#issuecomment-527958122)
                obj.apiVersion = "v1"
                obj.kind = "List"
                obj.items = [];
            }
        }
    ]
});

Closing out this issue now, but let me know if this doesn't solve your problem.

@lblackstone lblackstone added this to the 0.32 milestone Mar 3, 2020
@moconno
Copy link
Author

moconno commented Mar 3, 2020

Thanks @lblackstone. I'll give that a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants