is it possible to define some custom resource clea...
# general
g
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
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
annotations to the k8s resource?
c
yeah
like
"<http://pulumi.io/strict-delete|pulumi.io/strict-delete>": "true"
or something.
g
I see
c
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
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
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
I see
c
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
Is there any workaround I could use for now?
c
Hmmm.
g
Yeah I think actually k8s should introduce something similar to ReclaimPolicy on the statefulset itself.
c
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.