Using pulumi on python and leveraging the kubernet...
# general
c
Using pulumi on python and leveraging the kubernetes and aws libraries. I'm looking for a way to teardown a resource before creating a different resource. My team originally leveraged
pulumi_kubernetes
to create the deployment, daemonset, and other resources for the EbsCsiDriver, however we're looking to leverage
pulumi_aws.Addon()
. When I run
pulumi up
on an EKS cluster utilizing the component resource with the old code, pulumi will try to create the Addon before deleting the existing resources and then fail to update because the daemonset is using host_networking and holding onto the port it needs. I've looked around for options to force
pulumi up
to delete the existing resources first before attempting the create. • Adding deleteBeforeReplace and replaceOnChanges to individual resources won't work as the Addon and the resources it creates are functionally different resources than the ones that need to be deleted. • Using the CLI to
--target-replace <component-resource-urn> --target--dependents
on a component resource with
deleteBeforeReplace
will delete and replace itself, but not the underlying resources. I could in theory disable the component resource and do a pulumi up to tear down the existing resources, and then do a pulumi up with the Addon enabled, but it makes it harder to update clusters and down the line I'm looking move other resources to Addons, and having a longer stretch of time where the resources are completely missing is not ideal. Pulumi knows it needs to delete the daemonset, deployment, etc. However since the create happens first, it will fail.
Copy code
Type                                                 Name                                                Status                  Info
     pulumi:pulumi:Stack                                  k8s-<stack-name>                                        **failed**              1 error; 2 messages
     └─ ekscluster:cluster:cluster                        <stack-name>-preprod
        └─ <repo>:resources:cluster                       <stack-name>-preprod
           └─ aws:eks:Cluster                             <stack-name>-preprod
              └─ pulumi:providers:kubernetes              <stack-name>-preprod-k8s-provider
 +-              └─ ekscluster:cluster:ebscsidriver       ebscsidriver                                        replaced
 ~                  ├─ kubernetes:core/v1:ServiceAccount  <stack-name>-preprod-ebscsidriver-service-account  updated (1s)            [diff: ~metadata]
 +                  └─ aws:eks:Addon                      ebscsidriver                                        **creating failed**     1 error