Skip to content

What Are Pods in Kubernetes?

A beginner-friendly introduction to Pods in Kubernetes, including containers, sidecars, init containers, and best practices.

What are Pods in Kubernetes?

A Pod is the smallest deployable unit in Kubernetes cluster.

A Pod represents one or more containers that are:

In practice, a Pod is the unit that Kubernetes creates, starts, stop, and replaces, not the container itself.

Key characteristics of a Pod

If a Pod dies, Kubernetes does not resurrect it. Instead, it create a new Pod to replace it.


Origin of the Word “Pod”

The word Pod comes form nature.

A pod of whales is a group of whales that travel together.

In Kubernetes terms:

This analogy works well, since containers inside a Pod:


Pods vs Containers

A common beginner misconception is:

“A Pod is a container.”

This is not correct

That said, the most common Pod type is a single-container Pod, which explains the confusion.


Single-Container Pods

A single-container Pod contains exactly one container.

This is:

Characteristics

Typical use cases

Example:

Pod
 └─ nginx container

REST API service example:

Pod
 └─ Node.js / Java / Go API

Best practice

Prefer single-container Pods unless you need tight coupling or shared resources between containers.


Multi container

A multi-container Pod contains multiple containers that are designed to work together.

These containers:

Shared resources

Pod
 ├─ app container
 └─ log-collector sidecar

Common Multi-Container Patterns

Sidecar Pattern

A helper container that extends or enhances the main container.

Common uses:

Example:

Pod
 ├─ Java app
 └─ Fluent Bit sidecar
Ambassador Pattern

A proxy container that handles communication with external services.

Adapter Pattern

A container that transforms output into a common format, such as logs or metrics.

When to use Multi-Container Pods

Multi-container Pods make sense when:

Avoid them when:


Init container

An Init Container is a special type of container that runs before the main application containers start.

How Init Containers Work

Pod startup flow: InitContainer 1 → InitContainer 2 → App containers

Init containers:

Common Init Container Use Cases

Database migration example:

InitContainer: run flyway/liquibase
App container: start API

Executing Commands Inside a Pod

To open a shell inside a running container in a Pod:

kubectl exec -it pod/httpd -- /bin/bash**

This command:

Multi-Container Pod Example

If a Pod has multiple container, specify the container name:

kubectl exec -it pod/my-pod -c app-container -- /bin/bash

Notes

Summary