Home > Blockchain >  Find if pod is being terminated due to statefulset deletion
Find if pod is being terminated due to statefulset deletion

Time:01-01

I need to perform some operations on a different server statefulset when pods inside a client statefulset comes down only because of a statefulset deletion. I can trap the sigterm signal which is sent during pod termination from inside the pod, but how do i figure out whether the termination is during a statefulset deletion because pods can come down/terminate for various other reasons. Does statefulset have its own status? because i see that statefulset status only shows the status of the pods when i do a describe. I use client-go.

Kubectl describe statefulset doesnt have a status of its own but only of the pods associated.

CodePudding user response:

You can look for the Kubernetes event indicating that a stateful set has been deleted, similar to the way this kube events exporter works.

That way, whenever the code detects an event indicating that a statefulset has been deleted, you can act accordingly.

CodePudding user response:

Looks like the statefulset object is deleted first and then pods are deleted in a cascading fashion. so when i trap SIGTERM, and try to query the statefulset in my code, i already receive statefulset "abc" not found. So i will use this to know that the statefulset is deleted.

By default, Kubernetes uses background cascading deletion to delete dependents of an object https://kubernetes.io/docs/concepts/architecture/garbage-collection/#background-deletion

  • Related