:wave: friens. I'm creating a k8s deployment that ...
# general
t
👋 friens. I'm creating a k8s deployment that needs a Persistent Volume Claim (but would be equivalent in other cloud providers). As such the Deployment dependsOn the PVC, but the disk can only be mounted for Read/Write once...how would I go about making sure a new PVC is created if the Deployment is updated so that I don't have the old deployment keeping a lock on the PVC, while the new deployment is trying to get a lock to spin up? The PVC is created before the Deployment (so that I know it's name to give to the deployment spec)
g
You have a couple options here: 1. If you want to reuse the same PVC, you can force a delete-before-replace on the Deployment. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#CustomResourceOptions-deleteBeforeReplace 2. You could create a
ComponentResource
that wraps the PVC + Deployment so that they’re treated as a unit.
❤️ 1
t
#2 Was a Perfect solution! Thanks…should have know about that feature earlier…going to rewrite my whole infrastructure now 😛
😁 1
g
That’s one of the primary advantages of using real programming languages with Pulumi — this type of thing is pretty straightforward to express with classes or functions. 🙂
t
Yeah, I’m from React world…so I had done everything as stateless helper functions. But classes makes way more sense here
One more question @gorgeous-egg-16927, if I do the ComponentResource, and I pass a provider to the super() constructor…does that then set a default provider for any resource that I parent to
this
?
👍 1
g
I can’t recall off the top of my head. I think so, but I’ve normally set it explicitly.