https://pulumi.com logo
#general
Title
# general
l

lively-author-18255

01/11/2022, 9:03 PM
Hi, I am trying to migrate from helm charts to using kubernetes manifests directly. But I run into this issue. "some resources have the same name on kubernetes. Pulumi though thinks they are different but unrelated, so it attempts to create the new resources through, which fails as the resource already exists." I tried setting the createBeforeDelete option but it did not work, which I think makes sense since I am adding it to the ConfigFile resource and not the Chart one (which is removed). Any suggestions? Thanks!
b

billowy-army-68599

01/11/2022, 9:45 PM
can you share your code, or a sample?
l

lively-author-18255

01/11/2022, 10:10 PM
I replaced:
Copy code
pulumi_kubernetes.helm.v3.Chart(
        name,
        config=k8s.helm.v3.ChartOpts(....
with
Copy code
pulumi_kubernetes.yaml.ConfigFile(
        name,
        file=f"MyRepo.{environment}.yaml",
        transformations=[....
and the pulumi preview looks like this:
Copy code
pulumi:pulumi:Stack                      tracing-dev
     ├─ kubernetes:yaml:ConfigFile            refinery-dev
 +   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-dev             create
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-rules       create
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-config      create
 +   │  ├─ kubernetes:core/v1:Service         tracing/refinery-dev             create
 +   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-dev             create
     ├─ kubernetes:yaml:ConfigFile            refinery-prod
 +   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-prod            create
 +   │  ├─ kubernetes:core/v1:Service         tracing/refinery-prod            create
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-rules      create
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-config     create
 +   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-prod            create
     ├─ kubernetes:yaml:ConfigFile            refinery-staging
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-config  create
 +   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-staging         create
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-rules   create
 +   │  ├─ kubernetes:core/v1:Service         tracing/refinery-staging         create
 +   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-staging         create
 -   ├─ kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart>           refinery-dev                     delete
 -   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-dev             delete
 -   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-config      delete
 -   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-rules       delete
 -   │  ├─ kubernetes:core/v1:Service         tracing/refinery-dev             delete
 -   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-dev             delete
 -   ├─ kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart>           refinery-prod                    delete
 -   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-rules      delete
 -   │  ├─ kubernetes:core/v1:Service         tracing/refinery-prod            delete
 -   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-config     delete
 -   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-prod            delete
 -   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-prod            delete
 -   └─ kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart>           refinery-staging                 delete
 -      ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-config  delete
 -      ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-staging         delete
 -      ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-rules   delete
 -      ├─ kubernetes:core/v1:Service         tracing/refinery-staging         delete
 -      └─ kubernetes:apps/v1:Deployment      tracing/refinery-staging         delete
when I run pulumi up it complains: that the resources already exists:
Copy code
Type                                     Name                             Status                  Info
     pulumi:pulumi:Stack                      tracing-dev                      **failed**              1 error
     ├─ kubernetes:yaml:ConfigFile            refinery-dev
 +   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-dev             **creating failed**     1 error
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-config      **creating failed**     1 error
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-dev-rules       **creating failed**     1 error
 +   │  ├─ kubernetes:core/v1:Service         tracing/refinery-dev             **creating failed**     1 error
 +   │  └─ kubernetes:apps/v1:Deployment      tracing/refinery-dev             **creating failed**     1 error
     ├─ kubernetes:yaml:ConfigFile            refinery-prod
 +   │  ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-prod            **creating failed**     1 error
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-config     **creating failed**     1 error
 +   │  ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-prod-rules      **creating failed**     1 error
 +   │  └─ kubernetes:core/v1:Service         tracing/refinery-prod            **creating failed**     1 error
     └─ kubernetes:yaml:ConfigFile            refinery-staging
 +      ├─ kubernetes:core/v1:ServiceAccount  tracing/refinery-staging         **creating failed**     1 error
 +      ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-rules   **creating failed**     1 error
 +      ├─ kubernetes:core/v1:ConfigMap       tracing/refinery-staging-config  **creating failed**     1 error
 +      └─ kubernetes:core/v1:Service         tracing/refinery-staging         **creating failed**     1 error
b

billowy-army-68599

01/11/2022, 10:25 PM
you'll need to remove the helm code, run a
pulumi up
and then add the configfile code
the ConfigFile doesn't support createBeforeDelete because it's a component resource, you'd need to set it on all child resources
l

lively-author-18255

01/11/2022, 10:40 PM
I see, that makes sense, thanks a lot!
11 Views