π Kubernetes Pod Commands & YAML Guide β Quick Reference for DevOps

Essential kubectl Commands for Pods.
#Create a pod
kubectl run <pod-name> --image=<image-name>
#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 <pod-name> -- bash
#Access a specific container inside a multi-container pod
kubectl exec -it <pod-name> -c <container-name> -- bash
#Describe pod details
kubectl describe pod <pod-name>
#Get detailed node information (container runtime, etc.)
kubectl get nodes -o wide
#Delete a pod
kubectl delete pod <pod-name>
Create a Pod Using YAML
```yaml
vim pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: abc
spec:
containers:
- name: c1
image: nginx
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 <pod-name> -- sh
#Access a specific container in a pod
kubectl exec -it <pod-name> -c <container-name> -- 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.
Subscribe to my newsletter
Read articles from Dechen Tshering directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
