https://pulumi.com logo
g

glamorous-printer-66548

09/22/2018, 6:42 AM
is it possible to define some custom resource cleanup hooks or create sort of a wrapper which is able to do that? I have a k8s statefulset and would like to delete the PVCs of that statefulset after it’s being destroyed.
c

creamy-potato-29402

09/22/2018, 6:42 AM
Not right now, but you’re right that particular thing is pretty annoying.
I’ve thought about allowing users to specify it by adding annotations, for example.
I’d love to hear other ideas.
One problem is that imperative operations like “delete this” are not exposed to the language host, and it’s not clear they should be.
g

glamorous-printer-66548

09/22/2018, 6:44 AM
annotations to the k8s resource?
c

creamy-potato-29402

09/22/2018, 6:44 AM
yeah
like
"<http://pulumi.io/strict-delete|pulumi.io/strict-delete>": "true"
or something.
g

glamorous-printer-66548

09/22/2018, 6:45 AM
I see
c

creamy-potato-29402

09/22/2018, 6:45 AM
this particular issue of
StatefulSet
/
PersistentVolume
is sooooooo annoying.
And we don’t really tell the user what’s happening, currently. It just is something you have to figure out.
Not a good UX.
g

glamorous-printer-66548

09/22/2018, 6:47 AM
What I had in mind is some sort of generic resource on_destroy hook in which i can some execute an arbitrary function, e.g. in my case
execSync('kubectl delete pvc -l='some=label'')
. I’m not 100% about this, but I think terraform has some stuff like that.
c

creamy-potato-29402

09/22/2018, 6:47 AM
ah
hmm yeah
We are already planning on having things like “strict pods” Pulumi will consider successful if and only if none of the containers are crashing
So it might make sense to just wrap that into the definition of
StrictStatefulSet
or something.
that could work too.
g

glamorous-printer-66548

09/22/2018, 6:51 AM
I see
c

creamy-potato-29402

09/22/2018, 6:51 AM
The other option is, we could just decide to always delete the underlying PVC.
I’m actually not 100% sure I understand why k8s doesn’t do it.
data safety I guess.
g

glamorous-printer-66548

09/22/2018, 6:52 AM
Is there any workaround I could use for now?
c

creamy-potato-29402

09/22/2018, 6:52 AM
Hmmm.
g

glamorous-printer-66548

09/22/2018, 6:52 AM
Yeah I think actually k8s should introduce something similar to ReclaimPolicy on the statefulset itself.
c

creamy-potato-29402

09/22/2018, 6:53 AM
There are ways to do stuff after creation and update, but not delete, I think. @big-piano-35669 @white-balloon-205 do you have ideas here?
@glamorous-printer-66548 we could also have
StrictStatefulSet
extend the semantics of
StatefulSet
so that it does have a
ReclaimPolicy
.
That is not a crazy idea.
👍 1
Filed a bug.
My personal favorites are #2 and #3.