DEV Community

Janardhan Pulivarthi
Janardhan Pulivarthi

Posted on • Updated on • Originally published at i.janardhanpulivarthi.com

What happens when a pod gets deleted

1 State change and preparation

The pod is set to Terminating. And it will be isolated from end points

2 Run a preStop Hook

preStopHook will be executed. It is special command or http request sent to containers in the pod.

3 SIGTERM signal is sent to the pod

Kubernetes sends SIGTERM signal to all the containers in the pod. This lets them know that they are going to be terminated. SIGTERM can be handled, or ignored.

4 Kuberntes waits for the grace period

apiVersion: v1
kind: pod
metadata:
  name: app-pod
spec:
  containers:
  - name: app-container
    image: busybox
  terminationGracePeriodSeconds: 60
Enter fullscreen mode Exit fullscreen mode

5 Kubernetes sends SIGKILL command

If the containers are still running it sends SIGKILL command. Kubernetes cleanup all the objects related to the terminated pod.\

Top comments (0)