Kubernetes Cheatsheet

View saved

Kubernetes schedules containers across a cluster. You declare desired state; controllers work to match it.

Learn Deployments, Services, and kubectl get/describe/logs before diving into operators and meshes.

Cluster & kubectl

Context and nodes

See where kubectl points and list nodes.

kubectl config current-context
kubectl get nodes

Namespaces

Isolate resources. Pass -n or set a default context namespace.

kubectl get ns
kubectl get pods -n kube-system

API resources

Discover resource types short names.

kubectl api-resources
kubectl explain pod.spec

Apply YAML

Declaratively create or update objects from files.

kubectl apply -f deploy.yaml
kubectl delete -f deploy.yaml

Workloads

Pods

Smallest deployable unit—usually managed by a controller, not created bare in production.

kubectl get pods
kubectl describe pod NAME

Deployment

Manages replica Pods and rolling updates.

kubectl create deployment web --image=nginx:1.27
kubectl get deploy

Scale & rollout

Change replicas and watch rollouts.

kubectl scale deploy/web --replicas=3
kubectl rollout status deploy/web

Job / CronJob peek

Run finite or scheduled tasks.

kubectl get jobs,cronjobs

Networking & config

Service

Stable virtual IP / DNS name in front of Pods.

kubectl expose deploy/web --port=80 --type=ClusterIP
kubectl get svc

Ingress peek

HTTP routing from outside (controller required).

kubectl get ingress

ConfigMap / Secret

Inject config and sensitive values into Pods.

kubectl create configmap app-config --from-literal=MODE=dev
kubectl get secrets

port-forward

Tunnel a local port to a Pod or Service for debugging.

kubectl port-forward svc/web 8080:80

Debug

Logs

Print container logs; follow with -f.

kubectl logs deploy/web
kubectl logs -f pod/POD -c CONTAINER

exec

Open a shell or run a command in a container.

kubectl exec -it POD -- sh

Events

See why Pods are Pending or CrashLooping.

kubectl get events --sort-by=.lastTimestamp

kubectl get -o

Output YAML/JSON for inspection or backups of live state.

kubectl get deploy web -o yaml

Comments

One comment per signed-in account. Comments are saved with this page’s URL.