CKA - Personal Notes

Reference: Official kubectl command conventions – https://kubernetes.io/docs/reference/kubectl/conventions/

CommandWhat It DoesWhen I Use It
kubectl run nginx-pod --image=nginx --restart=NeverCreates a single Pod directly (not a Deployment).When the task explicitly asks for a Pod quickly.
kubectl describe pod nginx-podPrints the resource details, status conditions, and recent events so I can diagnose issues.When pods, services, or other objects misbehave and I need the full state and events in one view.
kubectl explain pod.specShows the schema, required fields, and field descriptions for core API objects.When I need to recall the exact field names, types, or nested structure while editing manifests in a hurry.
kubectl get pods -o wideShows extra pod details like node and pod IP.Quick troubleshooting and placement checks.
kubectl expose deployment nginx --port=80 --target-port=8080 --type=ClusterIPWraps an existing Deployment with a Service so its pods are reachable inside/outside the cluster depending on type.When I need to quickly expose HTTP workloads to other pods or create an exam service with minimal YAML.
kubectl explain pod --recursive \u2502 lessDumps the entire pod schema and subfields so you can page through the hierarchy without re-running the command.When I need to explore every nested field of pods or study the schema without my terminal scrolling away.
kubectl run test-pod --image=busybox --restart=Never -- sleep 3600Creates a long-running test Pod for debug/exec checks.Network/DNS/connectivity validation in-cluster.
kubectl run web --image=nginx --restart=Never --dry-run=client -o yaml > pod.yamlGenerates a Pod manifest without creating it.Fast YAML scaffolding during exam tasks.
kubectl create deployment httpd-frontend --image=httpd:2.4-alpine --dry-run=client -o yaml > httpd-frontend.yamlEmits the Deployment YAML without applying it so I can review or hand-edit before creation.When I need create deployment manifests quickly but control the exact spec before handing it to the cluster.
kubectl replace -f my-replicaset.yamlReplaces the ReplicaSet manifest atomically so the existing object updates in place.When I need to shift the pod template, labels, or container spec without tearing the ReplicaSet down.
kubectl scale rs my-app --replicas=5Changes the desired replica count of the ReplicaSet so the controller adjusts pods immediately.During load spikes, debugging sessions, or when pods drop below the expected count and need a quick restore.