How to remove stuck statefullset.apps in Kubernetes?

8/19/2021

I have stuck resources after delete a jitsi stack in my master node. The only pending resources are this two statefullset.appsset, no pods are running.

My issue

If I execute the command:

kubectl delete statefulsets shard-0-jvb -n jitsi --force --grace-period=0 --cascade=orphan

The console freezes for hours and resources are not removed.

Any other way to force the destroying process?

The stack was created with Kustomize.

enter image description here

-- Miguel Conde
jitsi
kubernetes
kustomize

1 Answer

8/25/2021

Posting the answer as community wiki, feel free to edit and expand.


Stuck objects in general

Sometimes objects can't be deleted due to finalizer(s), you will need to find them by viewing at the whole object e.g. kubectl get pod pod-name -o json.

Then there are two options:

  1. fix what prevents dependent object to be deleted (for instance it was metrics server - see another answer on SO)

  2. if it's not possible to fix, then finalizer should be removed manually by kubectl edit resource_type resouce_name

Stuck statefulsets

Kubernetes documentation has two parts related to deleting statefulsets (it's a bit more complicated since usually they have persistent volumes as well).

Useful links:

-- moonkotte
Source: StackOverflow