Kubernetes
Cluster Info
kubectl cluster-info—Cluster endpoint info
kubectl get nodes—List cluster nodes
kubectl get ns—List namespaces
kubectl config view—View kubeconfig
kubectl config use-context—Switch context
kubectl api-resources—List resource types
Pods
kubectl get pods—List pods
kubectl get pods -o wide—Pods with node info
kubectl describe pod <name>—Pod details
kubectl logs <pod>—Pod logs
kubectl logs -f <pod>—Follow logs
kubectl exec -it <pod> -- sh—Shell into pod
kubectl delete pod <name>—Delete pod
kubectl port-forward <pod> 8080:80—Port forward
Deployments
kubectl get deploy—List deployments
kubectl create deploy <n> --image=img—Create deployment
kubectl scale deploy <n> --replicas=3—Scale replicas
kubectl rollout status deploy/<n>—Rollout status
kubectl rollout undo deploy/<n>—Rollback
kubectl set image deploy/<n> c=img:v2—Update image
kubectl rollout history—Rollout history
kubectl edit deploy <n>—Edit in place
Services & Networking
kubectl get svc—List services
kubectl expose deploy <n> --port=80—Create service
kubectl get ingress—List ingress rules
ClusterIP—Internal-only service
NodePort—Expose on node port
LoadBalancer—External load balancer
kubectl get endpoints—Service endpoints
Config & Secrets
kubectl create configmap—Create configmap
kubectl create secret generic—Create secret
kubectl get configmaps—List configmaps
kubectl get secrets—List secrets
kubectl describe secret <n>—Secret details
--from-literal=k=v—From key-value pair
--from-file=path—From file
envFrom: configMapRef—Use in pod spec
Storage
kubectl get pv—Persistent volumes
kubectl get pvc—Persistent volume claims
kubectl get sc—Storage classes
emptyDir: {}—Temp pod volume
hostPath—Node filesystem path
persistentVolumeClaim—PVC-backed volume
Apply & Manage
kubectl apply -f file.yaml—Apply config
kubectl apply -f dir/—Apply all in dir
kubectl delete -f file.yaml—Delete from file
kubectl diff -f file.yaml—Preview changes
kubectl get all—All resources
kubectl get all -n namespace—In namespace
kubectl label pod <n> k=v—Add label
kubectl annotate pod <n> k=v—Add annotation
Debugging
kubectl describe <resource>—Detailed info
kubectl get events—Cluster events
kubectl top pods—Pod resource usage
kubectl top nodes—Node resource usage
kubectl logs --previous—Previous container logs
kubectl run debug --image=busybox -it—Debug pod
Output & Filtering
-o yaml—Output as YAML
-o json—Output as JSON
-o wide—Extra columns
-l app=web—Filter by label
--all-namespaces / -A—All namespaces
-w / --watch—Watch for changes
allprintabledoc.com