Whether you're new to Kubernetes or want a clean reference sheet, here’s a quick guide to working with Kubernetes Pods using the CLI and YAML definitions.
This post includes essential commands, how to access pods and containers and how to create pods using YAML.

Essential kubectl Commands for Pods.

Create a pod

kubectl run --image=

List all pods

kubectl get pods

List pods with extended details (IP address, node, etc.)

kubectl get pods -o wide

Access a running pod shell

kubectl exec -it -- bash

Access a specific container inside a multi-container pod

kubectl exec -it -c -- bash

Describe pod details

kubectl describe pod

Get detailed node information (container runtime, etc.)

kubectl get nodes -o wide

Delete a pod

kubectl delete pod

** Create a Pod Using YAML**

vim pod.yaml

apiVersion: v1
kind: Pod
metadata:
name: abc
spec:
containers:

  • name: c1 image: nginx
  • name: c2 image: redis

Commands:

Create resources from YAML

kubectl create -f pod.yaml

Delete resources from YAML

kubectl delete -f pod.yaml

Access Shell Inside Pod/Container

Access the shell of a pod

kubectl exec -it -- sh

Access a specific container in a pod

kubectl exec -it -c -- sh

If this helped you or you'd like to keep a quick reference around, feel free to bookmark or share this post! 🚀
Let’s keep growing together in the world of Cloud Native, Kubernetes, and DevOps.