-1

New to k8s. I want to understand, what kubectl delete sts --cascade=false does?

If i remove cascade, it deletes the statefulsets pods.

Ankush Ganatra
  • 500
  • 5
  • 23

2 Answers2

2

It is clearly explained in the documentation under Deleting the Statefulset:

Deleting a StatefulSet through kubectl will scale it down to 0, thereby deleting all pods that are a part of it. If you want to delete just the StatefulSet and not the pods, use --cascade=false.

So by passing this flag to kubectl delete the Pods that are managed by Statefulset are still running even though the StatefulSet object itself is deleted.

acid_fuji
  • 6,287
  • 7
  • 22
  • Yes I did read the k8s page but I still don't understand whats is meant by deleting statefulset? what exactly gets deleted? – Ankush Ganatra Aug 18 '20 at 00:08
  • Statefulset is an Kubernetes API object. It's way to tell the Kubernetes system how you want your cluster workload to look. When you create your object, cluster make sure that object exist and he is maintaining your desired state such a pod replicas, much like deployments do. With `--cascafde=false` you're just deleting the STS object in K8s API but the pods that K8s was maintaining for this pod are not deleted. – acid_fuji Aug 18 '20 at 07:32
  • That's bookish definition which i did read. I want to see what exactly gets deleted when i say kubectl delete sts . Any idea? – Ankush Ganatra Aug 18 '20 at 08:11
  • I don`t quite get what is that you want here. What do you mean by see exactly? – acid_fuji Aug 18 '20 at 08:22
  • If i delete po, or svc or pvc or pv or any other object i can see that it has been removed or re-created. how can i see whats deleted or re-created if i delete sts? – Ankush Ganatra Aug 18 '20 at 08:24
  • If you delete sts, nothing gets re-created. Pods running under sts and sts object gets deleted. You can check that its gone by using `kubectl get statefulsets` – acid_fuji Aug 18 '20 at 08:31
0

As described by the fine manual, it deletes the StatefulSet oversight mechanism without actually deleting the underlying Pods. Removing the oversight mechanism means that if a Pod dies, or you wish to make some kind of change, kubernetes will no longer take responsibility for ensuring the Pods are in the desired configuration.

mdaniel
  • 31,240
  • 5
  • 55
  • 58