Mongodb cluster Kubernetes Stateful set is not deleting

12/25/2021

I have created Mongodb stateful set using mongodb kubernetes operator.

Now I want to delete that stateful set from kubernetes dashboard, but it is getting recreated again and again.

How do we delete stateful set permanently so that it doesn't get created again.

-- Anonymous Creator
kubernetes
kubernetes-operator
kubernetes-statefulset
mongodb-cluster

3 Answers

12/25/2021

Are you trying to delete a pod or the Stateful set itself?

Try to run:

kubectl scale sts <Stateful Set name> --replicas=0 -n <your namespace>
-- KubePony
Source: StackOverflow

12/26/2021

For deleting pod forcefully use this.

kubectl delete pod <Pod_Name> -n <namespace_name>  --grace-period=0  --force

OR

kubectl delete pod <Pod_Name> -n <namespace_name>  --wait=false

For reference please follow below link. https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/

-- Sachin Arote
Source: StackOverflow

12/25/2021

How do we delete stateful set permanently so that it doesn't get created again.

List and check the name of statefulset

kubectl get statefulsets -n <namespace name>

Command to delete the stateful set permanently

kubectl delete statefulset <Mongo statefulset name> -n <namespace name>

Update

Try deleting the CRD also

kubectl get crd

delete CRD for mongo

kubectl delete crd <CRD name>
-- Harsh Manvar
Source: StackOverflow