Kubernetes Handbook

    Pods, Containers, and Node Lifecycle in Kubernetes

    Introduction#

    So, I’ll be real with you. When I first dipped my toes into Kubernetes, all those terms like Pods, Containers, and Nodes were flying over my head like they were part of some sci-fi novel. 😅 If you've ever felt the same, trust me—you're not alone.

    A lot of developers jump into Kubernetes hoping to orchestrate containerized applications like a pro, only to feel overwhelmed by the basic building blocks. I mean, what even is a Pod? Is it just a container? And where does a Node fit into all this?

    In this blog, we're going to break these concepts down the way your best tech buddy would explain over coffee (or chai, if you're like me). We’ll talk about what Containers are (quick refresher!), what Pods do (spoiler: they’re more than containers), and how Nodes bring everything to life.

    Containers: The Building Blocks#

    Alright, before we get too deep, let's rewind a bit. If you're new to Kubernetes, it's worth revisiting what a container is.

    What is a Container?#

    A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software — code, runtime, libraries, and even system tools.

    Think of it like a lunchbox. You've packed your favorite meal, maybe some rice, curry, a spoon, and even tissues. Everything is there, sealed in one neat box, ready to eat anytime, anywhere. 🍱

    Example:

    docker run nginx

    Boom! You just started an NGINX container. It has its own environment, yet it runs using the shared OS of the host machine. Efficiency meets portability.

    Why Containers?#

    • Portability across environments
    • Fast startup and shutdown
    • Isolation from host and other containers

    Containers are the reason Kubernetes exists. Without them, Kubernetes would be like a conductor without an orchestra.

    Pods: Not Just Another Container#

    Here’s where things get interesting. If containers are lunchboxes, Pods are like picnic baskets. 🧺 They can hold one lunchbox or multiple lunchboxes that are meant to be eaten together.

    What is a Pod in Kubernetes?#

    A Pod is the smallest and most basic unit in Kubernetes. Think of it as a wrapper for one or more containers that work together as a single unit. It represents a single instance of a running process in your cluster.

    • A Pod can run one or multiple containers, and all of them share the same storage and network resources.
    • Since all containers inside a Pod are deployed on the same node, they can communicate easily using localhost.
    • Pods are temporary they can be created, replaced, or removed automatically, depending on how your cluster is configured.

    Key Features of Pods:#

    • Each Pod runs one or more containers, grouped together logically.
    • Containers inside a Pod share networking (same IP) and storage.
    • Pods are ephemeral, meaning they can be replaced or recreated dynamically.

    In short, Pods are the foundation of how Kubernetes manages and runs containerized applications.

    Kubernetes Pods

    Example of Pod Definition (YAML)#

    apiVersion: v1 kind: Pod metadata: name: my-app spec: containers: - name: nginx-container image: nginx ports: - containerPort: 80

    This Pod definition in Kubernetes creates a single instance named "my-app", running a container with the nginx web server. The spec section defines the container's name (nginx-container), the Docker image to be used (nginx), and the port 80, which allows the container to handle web traffic. Unlike a Deployment, this Pod is not managed automatically if it fails, Kubernetes will not restart it unless configured separately. This is useful for basic testing or running single-instance applications.

    How to create a Pod?#

    kubectl apply -f pod.yaml

    Output:

    pod/my-app created

    Check running Pods#

    kubectl get pods

    Output:

    NAME READY STATUS RESTARTS AGE my-app 1/1 Running 0 10s

    Basic kubectl Commands for Managing Pods#

    Create a Pod#

    kubectl run my-pod --image=nginx

    List Pods#

    Default Namespace:

    kubectl get pods

    Specific Namespace:

    kubectl get pods -n <namespace>

    Get Pod Details#

    Describe a Specific Pod:

    kubectl describe pod <pod-name>

    Retrieve Logs from a Pod:

    kubectl logs <pod-name>

    Interact with a Pod#

    Open a Shell Session Inside a Pod:(Works if the container supports it.)

    kubectl exec -it <pod-name> -- /bin/bash

    Delete a Pod#

    kubectl delete pod <pod-name>

    Create a Pod from a YAML File#

    kubectl apply -f pod.yaml

    Nodes: The Machines That Run the Show#

    Now, let's zoom out.

    If containers are lunchboxes, and Pods are picnic baskets, then Nodes are like picnic tables where all these baskets are placed and opened.

    Kubernetes Architecture 

    What is a Node?#

    A Node is a physical or virtual machine on which Kubernetes runs your Pods. Each Node has the services necessary to run Pods and is managed by the Master Node.

    Types of Nodes:#

    • Master Node (Control Plane): Makes decisions (scheduling, scaling, etc.)
    • Worker Node: Actually runs the containers (via Pods)

    Components of a Worker Node:#

    1. Kubelet – This is the primary "agent" on each worker node. It constantly communicates with the control plane, gets instructions (like what Pods to run), and ensures the containers described in PodSpecs are actually running and healthy on the node.
    2. Container Runtime – This is the engine responsible for pulling container images from registries, starting and stopping containers, and maintaining their lifecycle. Common runtimes include Docker, containerd, and CRI-O. If the container runtime fails, your containers won’t run — plain and simple.
    3. Kube-proxy – This component handles all the dirty work of networking for Pods. It maintains network rules on the node to allow communication to and from Pods, handles load balancing across Pod IPs, and ensures service discovery works smoothly using techniques like iptables or IPVS.

    Together, these three ensure that your Pods don’t just start, but stay running, can talk to each other, and handle traffic efficiently.

    Node Lifecycle:#

    Nodes can go through various states:

    • Ready: Accepting workloads
    • NotReady: Something's wrong
    • SchedulingDisabled: Manually tainted or drained

    Check Node Status:

    kubectl get nodes

    Output:

    NAME STATUS ROLES AGE VERSION worker-node-1 Ready <none> 10d v1.30.1

    Let’s Stitch It Together#

    Here's a quick analogy to tie it all together:

    Imagine you're at a cloud-based restaurant. 🍽️

    • Each container is a chef preparing a dish.
    • A Pod is a kitchen room where chefs work together.
    • A Node is an entire branch of the restaurant with multiple kitchen rooms (Pods).
    • Kubernetes is the restaurant manager assigning chefs to kitchens, ordering supplies, and managing all restaurant branches.

    Pretty neat, huh?

    Conclusion#

    In this blog, you learned the essential core components of Kubernetes: what containers are, how Pods serve as their operational units, and how Nodes bring everything to life on real machines.

    In the next blog, we’re going to dive into the world of Namespaces and Isolation — where Kubernetes really shows off its multi-tenant capabilities and allows teams to work without stepping on each other’s toes.

    Last updated on May 06, 2025