Understanding the Lifecycle of a Kuberenetes Pod

What is a Pod?

A pod is the deployment unit for the Kubernetes. It is also having the life cycle just like the process in Linux. Pods are mortal, i.e. they can die and be reborn. Each pod consists of a unique Id (UID) which is different for each of them.

A Pod consists of a single container or multiple containers which represent the single instance of the application. It may be an application container, web server, volume container, or a batch job.

It’s always best practice to have one pod for one container. If the application is tightly coupled, then a pod consists of multiple containers.

Managing multi-container pods is more complex in terms of network and storage space. It wraps the single container or multiple containers.

Pod

 

Pod Template

Kubernetes is what manages the pod. To create the Pod object with Kubernetes it’s required to have the specification for the Pod. Pod templates give these specifications. This is a YAML / JSON file with certain specifications that describe the desired state of the Pod.

 

Pod Lifecycle

The pod has the life cycle of the Linux process. PodStatus object gives the status information of the Pod. It consists of the phase of the Pod. Phase indicates where the Pod lies in the lifecycle.

 

Pod Phases:

Running: All the containers in the Pod are created and at least one container is in running, restarting, or is in process of the starting. The pod is bounded with the Kubernetes cluster node.

Pending: Pod is accepted by the Kubernetes system. All containers are not created. Either Kubernetes scheduler is scheduling the pods on specific nodes or container images are still in the downloading phase. You can see the pending state when the container is downloading the images from the remote.

Succeeded: All containers in the Pod are terminated in a success state. The containers will not be restarted.

Failed: All containers in the Pod are terminated. One of the containers is terminated in failure. There may be a different reason for failure termination of the containers. It may be terminated by the system or forcefully killed.

Unknown: State of the Pod could not be obtained.

 

This is all about the Kubernetes Pod. If you want to know more about Kubernetes then please visit our other blogs.