https://pulumi.com logo
f

fast-dinner-32080

01/21/2020, 8:39 PM
Hello, I am looking into using Pulumi for our Kubernetes infra and wondered if there is a way to run a script when a node/vm resource is being destroyed? The idea is we would drain and cordon nodes before destroying. Then if possible run a command after the destroy to remove the node from kubernetes. Looking at the docs so far I cannot find any logic that can do this and am thinking it would have to be done manually which defeats one of the purposes 😕
w

white-balloon-205

01/21/2020, 8:50 PM
The best bet for this today is dynamic providers. These provide a way for you to define create,read,update,and delete behaviors for your own kind of resource. If that resource depends on the instance, it will have to be destroyed first, so your custom logic for delete can do whatever it needs to do. See https://www.pulumi.com/blog/dynamic-providers/ and https://www.pulumi.com/docs/intro/concepts/programming-model/#dynamicproviders.
g

gorgeous-egg-16927

01/21/2020, 8:51 PM
f

fast-dinner-32080

01/22/2020, 5:40 PM
Do you have any examples of this such as the pre destroy and then post destroy?
Seems like a lot of work where I would think it should be built in.