Skip to content
Related Articles
Open in App
Not now

Related Articles

Kubernetes – Pods

Improve Article
Save Article
Like Article
  • Last Updated : 01 Nov, 2022
Improve Article
Save Article
Like Article

Pre-requisite:- Kubernetes

Kubernetes is an open-source container orchestration system mainly used for automated software deployment, management, and scaling. Kubernetes is also known as K8s. Kubernetes was originally developed by Google but it is now being maintained by Cloud Native Computing Foundation. It was originally designed to be interfaced with only Docker runtime but it now works with containers and CRI-O also. The main purpose of Kubernetes is to automate the operational tasks of container management. It is included with built-in commands for the deployment of applications and rolling out the required changes in the application. It is currently being used by companies like Google, Spotify, and capital one.

Kubernetes- Pods:

A pod is the smallest unit that exists in Kubernetes. It is similar to that of tokens in C or C++ language. A specific pod can have one or more applications. The nature of Pods is ephemeral this means that in any case if a pod fails then Kubernetes can and will automatically create a new replica/ duplicate of the said pod and continue the operation. The pods have the capacity to include one or more containers based on the requirement. The containers can even be Docker containers. The Pods in Kubernetes provide environmental dependencies which include persistent storage volumes which means it is permanent and is available to all pods in the said cluster and even configuration data that is required to run the container within the pod. 

Types of Pods:

A pod can be defined as the collection of containers and their storage inside a node of a Kubernetes cluster. There is a possibility to create a pod with multiple containers inside them. 

Based on the number of pods present inside them they can be classified as a Single Container Pod or Multi Container Pod.

As the name suggests a single container contains only one container whereas the multi-container pod contains multiple containers. They can be used based on their function and use a case at the respective times. The methods of creation of both types of pods are different. 

Functions of Pods:

A Pod represents the processes running on a cluster. If one pod is limited to a single process then it is possible to report and maintain the health of each process running within the cluster. Every Pod has some unique features like a Unique IP address, persistent storage volumes, and configuration information required to run the working. Mostly all the pods have a single container but many of the will have a few containers working closely together to execute a particular function or activity.

Benefits of Pods:

  • If a pod contains many containers working towards a common goal then it is easy for them to communicate and share data among themselves. 
  • We know that all the containers in a pod will have the same network namespace due to which they can locate each other and communicate with help of localhost. 
  • Pods can communicate with each other by using another pod’s IP address or even by referring to a resource that is located in another pod. 
  • Any pod can even include containers that run when the pod is started mainly to run any operation before the application containers run. 
  • The presence of pods has made it more Scalable as each pod and its replicas can be created and shut down automatically considering the changes in demand. 

Working of Pods:

The creation of a pod is due to a workload resource called controller, which means rollout, replicate, and health of the pods present in a cluster. If we consider that a node in a cluster fails then a controller detects that the pod on the mode is unresponsive and then replicates a pod or pods on other nodes to carry out the same function. The three mostly used controllers used are Jobs, Deployments, and Stateful Sets. Jobs are used for batch-type jobs that are mostly ephemeral and will run a task to completion. Deployments are used for applications that are stateless and persistent, for example, web services. StatefulSets is used for applications that are both stateful and Persistent like a database. 

If any pod has any/multiple containers then all those are scheduled together on the same server in the cluster either a physical server or VM. All the containers present in the pods will share their resources and dependencies. All these clusters can coordinate their termination and execution.  For instance, if a pod contains an init container then it runs before the application container runs leveling or setting up the required environment for applications to follow.  Generally, pods are created by controllers that can automatically manage the pod lifecycle. The pod life cycle included replacing failed pods, replicating the pods when necessary, and eliminating the pod once the purpose is completed. Controllers use the information present in the pod templates to create the pods. 

Communication between Pods:

The creation of a pod has made it easy for communication between various components. If a pod contains multiple containers then they can communicate with each other by using a local host. Communication with outside pods can be made by exposing a pod. Communication within the clusters of the same pod is easy because Kubernetes assign a cluster private IP address to each pod in a cluster. 

Creation and Deletion of Pod:

 A pod can be created by using the create command format.

The command:

$ kubectl create -f [FILENAME]

In the [FILENAME], you need to insert the required filename with which you want to create your file, then a new pod with the name GeeksforGeeks will be created.


The command to delete a pod is:

$ kubectl delete -f FILENAME 

here the pod named GeeksforGeeks will be deleted


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!