In Kubernetes, Pods are the most basic deployable units. If you're just starting to learn kubernetes, getting to know Pods inside out is absolutely essential.

In this post, we'll break down what Pods are, how they work, and a quick example of creating a Pod using kubectl — the most direct way to get hands-on practice.

🌟 What is a Pod in Kubernetes?
A Pod is the smallest and simplest unit in the Kubernetes object model. It represents a single instance of a running process in your cluster.

Typically, a Pod will contain:

One container (most common), or

Multiple tightly coupled containers that share storage/network and are always co-located and co-scheduled.

Think of a Pod as a wrapper around one or more containers. It provides an environment for containers to communicate easily and share resources.

Key characteristics of Pods:

Shared Storage: Volumes can be mounted to Pods for data persistence.

Shared Network: Each Pod gets a unique IP address. Containers inside a Pod can communicate with each other over localhost.

Lifecycle Management: Pods are designed to be ephemeral. If a Pod dies, Kubernetes can create a new one through controllers like Deployments or replicasets.

🔹 Why Not Just Use Containers Directly?
While tools like Docker allow you to run containers individually, Kubernetes groups containers into Pods for better management, scalability, and communication.

For example:

Containers in the same Pod can easily share data.

Containers can work together (like a helper container that updates a main app container).

🚀 How to Create a Pod (Using a YAML File)
Let’s create a simple Pod running an nginx container by defining a YAML manifest.

Here’s a sample pod.yaml file:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
    - name: nginx
      image: nginx
  • apiVersion: v1 specifies the Kubernetes API version.

  • kind: Pod tells Kubernetes that we are creating a Pod resource.

  • metadata.name is the name of the Pod.

  • spec.containers lists the containers inside the Pod, with their names and images.

Once you have the YAML file ready, you can create the Pod with:

kubectl apply -f pod.yaml

You can verify the Pod creation by running:

kubectl get pods

And inspect the Pod in detail:

kubectl describe pod nginx-pod

Pro Tip:
During exams like CKAD/CKA, using YAML manifests is often safer for complex resources, as it helps avoid mistakes and makes it easier to edit and reapply configurations.

🎥 In the video linked below, I walk you through creating this Pod step-by-step using a YAML file.