Verified6 commandsAI-assisted

Core Resources

Verified against kubectl v1.34.0 (client), flags verified via `kubectl <cmd> --help`, 2026-08-20 · official docs

Getting, describing, creating, and deleting the resources you touch every day — pods, deployments, services — plus applying manifests.

Listing resources#

kubectl get pods
kubectl get pods -o wide                       # + node, IP, and readiness columns
kubectl get pods -n my-namespace
kubectl get pods --all-namespaces
kubectl get deployments,services                # multiple resource types in one call
kubectl get pods -l app=nginx                    # filter by label selector
kubectl get pods -w                              # watch for changes live

Inspecting a resource in detail#

kubectl describe pod my-pod
kubectl describe deployment my-deployment
kubectl get pod my-pod -o yaml                  # full resource manifest as YAML
kubectl get pod my-pod -o json                  # full resource manifest as JSON

describe includes recent Events for the resource — often the fastest way to see why a pod is stuck (ImagePullBackOff, failed readiness probe, insufficient node resources) without a separate get events call.

Applying and creating resources#

kubectl apply -f deployment.yaml                # create or update to match the file (idempotent)
kubectl apply -f ./manifests/                   # apply every manifest in a directory
kubectl create -f pod.yaml                      # create only — fails if it already exists
kubectl create deployment my-app --image=nginx:1.27

apply is the standard for anything you'll re-run (it diffs against the last-applied state and only changes what differs); create is a one-shot, fails on a resource that already exists. Prefer apply for anything under version control.

Deleting resources#

kubectl delete pod my-pod
kubectl delete -f deployment.yaml
kubectl delete pods -l app=nginx                # delete everything matching a label
kubectl delete pod my-pod --grace-period=0 --force   # skip graceful termination (last resort)

Logs and exec#

kubectl logs my-pod
kubectl logs my-pod -c my-container             # a specific container in a multi-container pod
kubectl logs my-pod -f                          # stream/follow
kubectl logs deployment/my-deployment --all-pods=true
kubectl exec my-pod -- date                     # run a one-off command
kubectl exec -it my-pod -- /bin/bash            # interactive shell

-it (interactive + tty) is what makes exec behave like a real shell session instead of a single non-interactive command — forgetting it against a shell command leaves you unable to type.

Editing and scaling#

kubectl edit deployment my-deployment           # opens the live resource in $EDITOR
kubectl scale deployment my-deployment --replicas=5
kubectl set image deployment/my-deployment my-container=myrepo/app:v2   # roll a new image without editing YAML