G
GuideDevOps
Lesson 4 of 17

Pods

Part of the Kubernetes tutorial series.

A Pod is the atomic unit of Kubernetes. It represents a single instance of a running process in your cluster. You never deploy containers directly; you always deploy them inside Pods.

1. Creating a Basic Pod

Pods are usually defined in YAML files.

pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: web
spec:
  containers:
  - name: nginx-container
    image: nginx:1.14.2
    ports:
    - containerPort: 80

Apply the Manifest

Action:

kubectl apply -f pod.yaml

Result:

pod/nginx-pod created

2. Inspecting Pods

Once a Pod is created, you need to verify it's running correctly.

List Pods

Action:

kubectl get pods

Result:

NAME        READY   STATUS    RESTARTS   AGE
nginx-pod   1/1     Running   0          30s

Describe Pod Details

Use this when a Pod is stuck in Pending or Error state.

Action:

kubectl describe pod nginx-pod

Result:

Name:         nginx-pod
Namespace:    default
Node:         minikube/192.168.49.2
Start Time:   Fri, 10 Apr 2026 12:00:00 +0000
Labels:       app=web
Status:       Running
IP:           172.17.0.3
Containers:
  nginx-container:
    Image:          nginx:1.14.2
    ...
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  45s   default-scheduler  Successfully assigned default/nginx-pod to minikube
  Normal  Pulling    44s   kubelet            Pulling image "nginx:1.14.2"
  Normal  Pulled     40s   kubelet            Successfully pulled image "nginx:1.14.2"
  Normal  Created    40s   kubelet            Created container nginx-container
  Normal  Started    39s   kubelet            Started container nginx-container

3. Interacting with Pods

View Logs

Action:

kubectl logs nginx-pod

Result:

127.0.0.1 - - [10/Apr/2026:12:01:00 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.81.0" "-"

Execute Commands (Shell Access)

Action:

kubectl exec -it nginx-pod -- /bin/bash

Result:

root@nginx-pod:/# ls /usr/share/nginx/html
index.html
root@nginx-pod:/# exit

4. Resource Requests and Limits

Every production Pod should define its resource needs to ensure stability.

Action (Manifest snippet):

resources:
  requests:
    memory: "64Mi"
    cpu: "250m"
  limits:
    memory: "128Mi"
    cpu: "500m"

Summary

  • Pod: The smallest unit of deployment.
  • kubectl get pods: List your pods.
  • kubectl describe: Debugging (Events are key!).
  • kubectl logs: Application-level debugging.
  • kubectl exec: Direct interaction.
  • Always set resource limits for production.