0
0
Kubernetesdevops~5 mins

Why Pods are the smallest deployable unit in Kubernetes - Why It Works

Choose your learning style9 modes available
Introduction
In Kubernetes, a Pod is the smallest unit you can deploy and manage. It groups one or more containers that share resources and run together on the same machine. This helps keep related containers close and makes managing them easier.
When you want to run a single container or a tightly coupled group of containers together on the same host.
When you need containers to share storage or network resources easily.
When you want to manage the lifecycle of related containers as a single unit.
When you want to ensure containers start, stop, and scale together.
When you want to simplify deployment by grouping containers that must work closely.
Commands
This command creates a Pod named 'my-pod' running the nginx container. The '--restart=Never' flag ensures it creates a Pod directly, not a Deployment.
Terminal
kubectl run my-pod --image=nginx --restart=Never
Expected OutputExpected
pod/my-pod created
--restart=Never - Creates a Pod directly instead of a Deployment
This command lists all Pods in the current namespace to verify that 'my-pod' is running.
Terminal
kubectl get pods
Expected OutputExpected
NAME READY STATUS RESTARTS AGE my-pod 1/1 Running 0 10s
This command shows detailed information about the 'my-pod' Pod, including its containers, status, and resource usage.
Terminal
kubectl describe pod my-pod
Expected OutputExpected
Name: my-pod Namespace: default Priority: 0 Node: <node-name> Start Time: <time> Labels: <none> Annotations: <none> Status: Running IP: <pod-ip> Containers: nginx: Container ID: <container-id> Image: nginx State: Running Ready: True Restart Count: 0 Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: <none> QoS Class: BestEffort Node-Selectors: <none> Tolerations: <none> Events: <none>
Key Concept

A Pod is the smallest deployable unit because it groups containers that share resources and lifecycle, making them manageable as one.

Common Mistakes
Trying to deploy individual containers without using Pods
Containers need to be inside Pods to run in Kubernetes; you cannot deploy containers alone.
Always create Pods to run containers, either directly or via higher-level objects like Deployments.
Using 'kubectl run' without '--restart=Never' expecting a Pod but getting a Deployment
'kubectl run' defaults to creating a Deployment unless '--restart=Never' is specified.
Add '--restart=Never' to create a Pod directly with 'kubectl run'.
Summary
Pods are the smallest deployable units in Kubernetes that hold one or more containers.
Pods share storage, network, and lifecycle, making container management simpler.
Use 'kubectl run' with '--restart=Never' to create a Pod directly and 'kubectl get pods' to verify.