Kubernetes Pods: My Quick Reference Guide (Commands + YAML Examples)

Dechen TsheringDechen Tshering
2 min read

As I continue my #DevOps learning journey, I’ve been diving deep into Kubernetes Pods—the smallest deployable units in K8s. To solidify my understanding and help others, I’ve compiled this quick reference for working with Pods via kubectl and YAML.

Whether you’re a beginner or need a refresher, bookmark this for easy access!

Essential kubectl Commands for Pods

1. Create & Manage Pods

# Create a Pod from an image  
kubectl run <pod-name> --image=<image-name>  

# List all Pods (default namespace)  
kubectl get pods  

# Detailed Pod info (IP, node, status)  
kubectl get pods -o wide  

# Describe a Pod (debugging, events, config)  
kubectl describe pod <pod-name>  

# Delete a Pod  
kubectl delete pod <pod-name>

2. Accessing Pods & Containers

# Start an interactive shell in a Pod  
kubectl exec -it <pod-name> -- sh  

# Access a specific container in a multi-container Pod  
kubectl exec -it <pod-name> -c <container-name> -- bash  

# View Pod logs  
kubectl logs <pod-name>

3. Node & Cluster Info

# List nodes with extended details (OS, container runtime)  
kubectl get nodes -o wide

Creating a Pod Using YAML

Here’s a basic pod.yaml I used to deploy an NGINX container:

apiVersion: v1  
kind: Pod  
metadata:  
  name: nginx-pod  
spec:  
  containers:  
  - name: nginx-container  
    image: nginx

Commands to Apply YAML:

# Create the Pod  
kubectl apply -f pod.yaml  

# Delete the Pod (via YAML)  
kubectl delete -f pod.yaml

Key Takeaways from My Learning

  1. Pods are ephemeral – They can crash or reschedule, so treat them as disposable.

  2. Multi-container Pods share networking and storage.

  3. Always check logs (kubectl logs) when debugging issues.

0
Subscribe to my newsletter

Read articles from Dechen Tshering directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dechen Tshering
Dechen Tshering