What is a Pod ?

Pod Overview

A pod is the smallest building block of Kubernetes object model. In a Kubernetes cluster, a pod represents a running process. Inside a pod, you can have one or more containers. Those containers all share a unique network IP, storage, network and any other specification applied to the pod. This means all of the containers in a pod always land on the same machine.

Each container within a pod runs its own cgroups, but they share a number of namespaces.

Applications running in the same pod share the same IP address and port space, same hostname (UTS ns) and can communicate using native interprocess communication channels over System v IPC ns. However applications in different pods are isolated from each other.

  • Pod model types

There are two methods you can use to create a create. “one-container-per-pod” and “multi-container-pod.

  • One-container-per-pod

This model is the most popular. The Pod acts as a wrapper for a single container and since Pod is the smallest object Kubernetes knows, it manages the Pods rather than the containers directly.

  • Multi-container-pod

With this model a pod might hold multiple containers that are tightly coupled and need to share resources. These containers work as a single cohesive unit of service. The Pod wraps these containers and storage resources together as a single unit. Some example use cases are sidecars, proxies, logging.

Pod

Where a Pod runs?

Node

A Pod always runs on a Node. A Node is a worker machine in Kubernetes and may be either a virtual or a physical machine, depending on the cluster. Each Node is managed by the Master. A Node can have multiple pods, and the Kubernetes master automatically handles scheduling the pods across the Nodes in the cluster. The Master’s automatic scheduling takes into account the available resources on each Node.

  • How to create a Pod?

There are two ways you can create a pod.

  • Imperative way
  • Declarative way

With an imperative way, the configuration would say “run X, run Y and run Z” where as in declarative configuration would be “replicas=3” and its YAML based defination than just command based like “kubectl run ..”