> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Pods

> Guide to creating inspecting and managing a single-container Pod in Minikube using kubectl, including commands, outputs, troubleshooting, and next steps

In this lesson we deploy a Pod into a Minikube cluster using `kubectl`. A Pod is the smallest deployable unit in Kubernetes and can contain one or more containers that share storage, network, and a specification for how to run the containers.

<Callout icon="lightbulb" color="#1CB2FE">
  Make sure your Minikube cluster is running and `kubectl` is configured to use the Minikube context. Verify with `kubectl config current-context` or `minikube status`.
</Callout>

## Create a simple Pod

With modern `kubectl`, use `--restart=Never` to create a Pod instead of a Deployment:

```bash theme={null}
kubectl run nginx --image=nginx --restart=Never
```

Notes:

* The Pod name (`nginx`) must be a valid DNS label.
* The image must be available from Docker Hub ([https://hub.docker.com/](https://hub.docker.com/)) or another container registry. You can specify a tag such as `nginx:1.21` or a fully qualified registry address.

After creating the Pod, confirm creation and inspect its status:

```bash theme={null}
admin@ubuntu-server ~ # kubectl run nginx --image=nginx --restart=Never
pod/nginx created
admin@ubuntu-server ~ # kubectl get pods
NAME     READY   STATUS    RESTARTS   AGE
nginx    1/1     Running   0          3s
admin@ubuntu-server ~ #
```

## Understand `kubectl get pods` columns

The columns returned by `kubectl get pods` help you quickly assess the Pod state. Here's a quick reference:

| Column | Meaning | Example |
| - | - | - |
| `NAME` | Pod name | `nginx` |
| `READY` | Number of ready containers / total containers | `1/1` |
| `STATUS` | Pod phase (Running, Pending, CrashLoopBackOff, etc.) | `Running` |
| `RESTARTS` | Count of container restarts | `0` |
| `AGE` | Time since Pod was created | `3s` |

## Inspect a Pod in detail

For more detailed info, use `kubectl describe pod <pod-name>`:

```bash theme={null}
admin@ubuntu-server ~ # kubectl describe pod nginx
Name:           nginx
Namespace:      default
Priority:       0
Node:           minikube/192.168.99.100
Start Time:     Sat, 11 Jul 2020 00:49:39 -0400
Labels:         run=nginx
Annotations:    <none>
Status:         Running
IP:             172.17.0.3
IPs:
  IP:           172.17.0.3
Containers:
  nginx:
    Container ID:   docker://987785b312ad2e38c77132300f8709b8a027566462c2d18634ff13b34de25479
    Image:          nginx
    Image ID:       docker-pullable://nginx@sha256:a93c8a0b0974c967aebe868a186e5c205f4d3bcb5423a56559f2f9599074bbcd
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Sat, 11 Jul 2020 00:49:41 -0400
    Ready:          True

Initialized            True
Ready                  True
ContainersReady        True
PodScheduled           True
Volumes:
  default-token-f5ntk:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-f5ntk
    Optional:    false
QoS Class:           BestEffort
Node-Selectors:      <none>
Tolerations:         node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s

Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  46s   default-scheduler  Successfully assigned default/nginx to minikube
  Normal  Pulling    45s   kubelet, minikube  Pulling image "nginx"
  Normal  Pulled     44s   kubelet, minikube  Successfully pulled image "nginx"
  Normal  Created    44s   kubelet, minikube  Created container nginx
  Normal  Started    44s   kubelet, minikube  Started container nginx

admin@ubuntu-server ~ #
```

Key information available from `kubectl describe`:

* Pod name, labels, and start time.
* Which node the Pod is scheduled on (e.g., `minikube/192.168.99.100`) and the Pod's internal IP (`172.17.0.3`).
* Container-specific details: image, container ID, state, and readiness.
* Events section that records lifecycle steps (Scheduled, Pulling, Pulled, Created, Started) — essential for troubleshooting.

<Callout icon="warning" color="#FF6B6B">
  Be cautious when using container images from unknown registries. Use pinned image tags (not `:latest`) in production to avoid unexpected changes.
</Callout>

## Get more fields with wide output

`kubectl get pods -o wide` shows additional fields like Pod IP and node:

```bash theme={null}
admin@ubuntu-server ~ # kubectl get pods -o wide
NAME     READY   STATUS    RESTARTS   AGE    IP           NODE      NOMINATED NODE
READINESS GATES
nginx    1/1     Running   0          2m28s  172.17.0.3   minikube  <none>
<none>
admin@ubuntu-server ~ #
```

The `-o wide` output is useful to see where each Pod is running (node name) and the Pod IP assigned by the cluster networking.

## Quick reference: common Pod commands

| Purpose | Command |
| - | - |
| Create a Pod (imperative) | `kubectl run nginx --image=nginx --restart=Never` |
| List Pods | `kubectl get pods` |
| List Pods with node and IP | `kubectl get pods -o wide` |
| Describe a Pod | `kubectl describe pod nginx` |
| Tail logs from a container | `kubectl logs -f podname [-c container]` |
| Exec into a Pod | `kubectl exec -it podname -- /bin/sh` |

## Notes and next steps

Each Pod receives an internal cluster IP. Pod networking and IP allocation are advanced topics — explore CNI plugins, Services, and Network Policies for production setups.

This demonstration showed how to run a single-container Pod in Minikube. Topics you may want to explore next:

* Declarative Pod manifests (YAML)
* Deployments for managed replicas and rolling updates
* Pods with multiple containers (sidecars)
* Services and exposing Pods externally

Links and references:

* [Kubernetes Concepts — Pods](https://kubernetes.io/docs/concepts/workloads/pods/)
* [kubectl Cheat Sheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
* [Minikube documentation](https://minikube.sigs.k8s.io/docs/)
* [Docker Hub](https://hub.docker.com/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/docker-certified-associate-exam-course/module/d9358627-4fc7-4acc-ab96-fa25232555c6/lesson/693f940b-bbe9-42e8-adfc-0150deb5a0b1" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.