What processes are initiated and how does recovery occur when a pod fails in Kubernetes?
sobes.tech AI
Answer from AI
In Kubernetes, when a Pod fails (for example, a container inside the Pod crashes), automatic recovery occurs, provided by controllers such as Deployment, ReplicaSet, or StatefulSet.
Recovery process:
-
Failure detection: kubelet on the node monitors the state of containers in the Pod. If a container crashes, kubelet reports this to the API server.
-
Container restart: If the Pod's restartPolicy is set to
Always(default), kubelet will attempt to restart the container within the same Pod. -
Pod recovery: If the Pod is completely deleted (for example, the node crashes or the Pod is manually deleted), the controller (such as ReplicaSet) detects that the number of replicas is less than desired and creates a new Pod on an available node.
-
Scheduling: The Scheduler assigns the new Pod to an appropriate node.
-
Initialization: The new Pod is created, containers are started, and it becomes ready.
Thus, Kubernetes ensures high availability of applications through automatic failure detection and Pod recovery without user intervention.