Search code examples
kubernetesdaemonset

What does a kubectl delete do that a Crashloop Backoff Restart doesn't do?


Perhaps there's something fundamental that a pod delete-and-recreate does that a pod restart doesn't do (restart as per a Crashloop). My first thought is mounting file, etc. I've seen where some issues are resolved after a Delete, even though a Crashloop was in effect.

What does a kubectl delete do that a Crashloop Backoff Restart doesn't do? Not sure if this is particular to a Daemonset, but it was a Daemonset that I last saw this behavior.


Solution

    • CrashLoopBackOff
      • Restarts the same pod and containers in the pod
      • If the pods keep crashing or failing health checks the time that it takes to restart the pod keeps increasing with every restart.
    • kubectl delete
      • Deletes the pod
      • If the pods are managed by a higher abstraction: DaemonSet, Deployment, StatefulSet, etc. a new pod gets created. Note that in a StatefulSet the ordinal numbers remain constant so the pod will have the same name, but with other abstractions, your pod name will change.

    My first thought is mounting a file, etc. I've seen where some issues are resolved after a Delete, even though a Crashloop was in effect.

    Yes, when you delete, technically volumes are unmounted and then re-mounted on the new Pod. When a CrashLoopBackOff the containers are restarted.

    From the docs:

    Whilst a Pod is running, the kubelet is able to restart containers to handle some kind of faults. Within a Pod, Kubernetes tracks different container states and handles

    ✌️