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

thousands-london-78260

02/04/2020, 6:01 PM
👋 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

gorgeous-egg-16927

02/04/2020, 6:09 PM
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

thousands-london-78260

02/04/2020, 6:13 PM
#2 Was a Perfect solution! Thanks…should have know about that feature earlier…going to rewrite my whole infrastructure now 😛
😁 1
g

gorgeous-egg-16927

02/04/2020, 6:15 PM
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

thousands-london-78260

02/04/2020, 6:19 PM
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

gorgeous-egg-16927

02/04/2020, 6:27 PM
I can’t recall off the top of my head. I think so, but I’ve normally set it explicitly.
2 Views