DEV Community

sindhu cynixit
sindhu cynixit

Posted on • Updated on

What is a Kubernetes Pod?

In this article, I’m going to provide an explanation for Kubernetes pods, use cases, and lifecycle, and how to use it to deploy an application. This article assumes you recognize the purpose of the Kubernetes and you’ve got minikube and kubectl installed.

What is a pod in K8S?

Of object models in Kubernetes, the pod is the smallest building block. inside a cluster, a pod represents a system that’s running. The inside of a pod may have one or greater containers. Those within a single pod share:

  • A unique network IP
  • Network
  • Storage
  • Any additional specifications you’ve applied to the pod

To get in-Depth knowledge on Kubernetes you can enroll for a live demo on
kubernetes online training

Another way to think of a pod — a “logical host” that is specific to your application and holds one or more tightly-coupled containers. For example, say we've got an app-container and a logging-container during a pod.

The only job of the logging-container is to tug logs from the app-container. Locating your containers in a pod eliminates extra communication setup because they are co-located, so everything is local and they share all the resources. This is an equivalent thing as execution on an equivalent physical server during a pre-container world.

There are other things to do with pods, of course. You might have an init container that initializes a second container. Once the second container is up and serving, the first container stops — its job is done.

Pod model types

There are two model types of pod you can create:

  • One-container-per-pod: This model is the most popular. The post is that the “wrapper” for one container. Since pod is that the smallest object that K8S recognizes, it manages the pods rather than directly managing the containers.
  • Multi-container-pod: during this model, a pod can hold multiple co-located containers that are tightly coupled to share resources. These containers work as a single, cohesive unit of service. The pod then wraps these multi containers with storage resources into one unit. Example use cases include sidecars, proxies, logging.

Take your career to new heights of success with kubernetes training

Each pod runs one instance of your application. If you would like to scale the app horizontally (such as running several replicas), you’ll use a pod per instance. this is often different from running multiple containers of an equivalent app within one pod.

It is worth mentioning that pods aren’t intended as durable entities. If a node fails or if you’re maintaining nodes, the pods won’t survive. to unravel this issue, K8S has controllers — typically, a pod is often created with a type of controller.

Pod lifecycle phases

A pod status tells us where the pod is in its lifecycle. it’s meant to offer you thought not surely, therefore it’s good practice to debug if pod doesn’t come up cleanly. The five phases of a pod lifecycle are:

  1. Pending: The pod is accepted, but a minimum of one container image has not been created.
  2. Running: The pod is sure to a node, and every one container is created. One container is running or in the process of starting or restarting.
  3. Succeeded: All containers within the pod successfully terminated and can not restart.
  4. Failed: All containers are terminated, with at least one container failing. The failed container exited with a non-zero status.
  5. Unknown: The state of the pod couldn’t be obtained.

Top comments (1)