Back to Blog
Lesson 9 of the Kubernetes: Kubernetes Concepts & Your First Pod course
KubernetesJuly 27, 20264 min read

The Pod: The Smallest Unit of Execution in Kubernetes

Learn what a Pod is, why it's the smallest unit of execution in Kubernetes, and how it differs from a standard Docker container for modern orchestration.

KubernetesPodContainersOrchestrationDevOps
Photograph of concrete tetrapods on a seawall with a clear blue ocean backdrop under a sunny sky.

Previously in this course, we explored the managing of kubeconfig and contexts to navigate your cluster environments. Now that you can connect to and organize your cluster, it is time to look at the "atom" of Kubernetes: the Pod.

Understanding the Pod Abstraction

When you move from local development to orchestration, you might be tempted to think of Kubernetes as just a "container runner." If you're coming from a background of running containers with Docker, you are used to managing individual containers directly.

In Kubernetes, you don't actually run containers directly. You run Pods.

A Pod is the smallest, most basic deployable object in the Kubernetes object model. It represents a single instance of a running process in your cluster. Think of a Pod as a "logical host" for your container—a wrapper that provides the necessary environment for your application to execute.

Pods vs. Standalone Containers

In the Docker world, a container is often treated as a single, immutable unit. You map ports, attach volumes, and define networks for that specific container.

Kubernetes introduces an abstraction layer because real-world applications rarely exist in isolation. A single service might need a sidecar process (like a log forwarder or a proxy) that needs to share the same local storage or network namespace as your primary application.

FeatureStandalone ContainerKubernetes Pod
LifecycleIndependentManaged by K8s (Recreated if needed)
NetworkingPort mapped to hostShared network namespace
StorageLocal to containerShared volumes within the Pod
ScaleScale containerScale Pod

By using a Pod, Kubernetes allows multiple containers to act as a single unit while maintaining the benefits of containerization.

The Container-per-Pod Model

While a Pod can hold multiple containers, the most common practice is the container-per-pod model. In this design, each Pod runs a single primary application container.

Why not just run one container? Because the Pod abstraction provides:

  1. Shared Networking: All containers in a Pod share the same IP address and port space. They can communicate via localhost.
  2. Shared Storage: You can mount a volume to the Pod, and all containers within that Pod can access the same files.
  3. Co-scheduling: The Kubernetes scheduler ensures that all containers in a Pod are placed on the same physical or virtual node.

A Worked Example: The Concept of Locality

Imagine you are deploying a web application that needs a "sidecar" helper to refresh a configuration file. If these were two separate Docker containers on a host, they would have to communicate over the network and manage separate filesystems.

In Kubernetes, you define them in the same Pod:

YAML
apiVersion: v1
kind: Pod
metadata:
  name: web-app-with-sidecar
spec:
  containers:
  - name: main-app
    image: nginx:latest
  - name: config-refresher
    image: alpine:latest
    command: ["/bin/sh", "-c", "while true; do echo 'refreshing'; sleep 3600; done"]

Because they are in the same Pod, the config-refresher can write to a shared volume that the main-app reads from, and they both "live" on the same internal network.

Hands-on Exercise: Inspecting a Pod

Since we are currently building our understanding before launching our first full-scale app, let's look at how to identify what exists.

  1. Open your terminal and ensure you have context to your cluster.
  2. Run the following command to see if any pods exist in your current namespace: kubectl get pods
  3. If you haven't deployed anything yet, you will see No resources found.
  4. Try adding the --all-namespaces flag to see the "system" pods that the cluster uses to manage itself: kubectl get pods --all-namespaces

You will see pods with names like kube-scheduler or coredns. These are the "smallest units of execution" that keep your cluster alive.

Common Pitfalls

  • Treating Pods like VMs: Do not try to SSH into Pods to update software. Pods are ephemeral; if they crash or the node fails, Kubernetes destroys the Pod and recreates it. Always bake your changes into the container image.
  • Overloading Pods: Beginners often try to stuff five different microservices into one Pod because they "need to talk to each other." This breaks the scaling model. Keep Pods focused.
  • Ignoring Lifecycle: Assuming a Pod will stay running forever. Your application should be designed to handle sudden restarts without data loss (which we will cover in later lessons).

Frequently Asked Questions

Can I run two different web servers in one Pod? Yes, but they will compete for the same network port (e.g., port 80). You would need to configure them to listen on different ports.

Why does my Pod disappear? If you delete a Pod manually, it is gone. In production, we rarely create Pods directly; we use higher-level controllers (like Deployments) that manage the Pods for us.

Is a Pod the same as a container? No. A Pod is a wrapper. A Pod contains one or more containers.

Recap

The Pod is the fundamental unit of deployment in Kubernetes. It abstracts away the complexity of managing individual containers by providing shared networking and storage, allowing you to treat related processes as a single atomic unit.

Up next: Creating Your First Pod Manifest, where we will move from theory to writing the YAML that brings your first application to life.

Similar Posts