Active Nerds
Back to Cheat Sheets
Topic Reference

Kubernetes Cheat Sheet

Quick reference guide for kubectl commands, pod debugging, workloads, services, and cluster operations.

Last updated: 2026-07-25

Core kubectl & Declarative Apply

Command / PatternDescription
kubectl apply -f manifest.yaml

Declaratively create or update cluster resources using 3-way merge patch.

kubectl get pods -A -o wide

List all Pods across all namespaces with Node assignment IPs.

kubectl describe pod pod_name

Fetch detailed events, status state, and volume mounts of a resource.

kubectl delete -f manifest.yaml

Gracefully terminate resources declared in target YAML manifest.

Pod Inspection & Debugging

Command / PatternDescription
kubectl logs -f pod_name -c container_name

Tail container stdout/stderr logs continuously for a target Pod container.

kubectl exec -it pod_name -- /bin/bash

Open interactive terminal shell in target Pod container.

kubectl port-forward pod/pod_name 8080:80

Forward local port 8080 directly to target Pod port 80.

kubectl cp pod_name:/path/to/file ./file

Copy files to or from container filesystem.

Deployments & Scaling

Command / PatternDescription
kubectl scale deployment/my-app --replicas=5

Imperatively adjust desired replica count for target Deployment.

kubectl rollout status deployment/my-app

Watch progressive rollout status of active deployment revision.

kubectl rollout history deployment/my-app

List previous revision history snapshots stored for rollback.

kubectl rollout undo deployment/my-app

Rollback deployment to previous revision state immediately.

Services & Ingress

Command / PatternDescription
kubectl get svc,ep

List internal ClusterIP/NodePort Services alongside active pod Endpoint IPs.

kubectl expose deployment my-app --port=80 --type=ClusterIP

Create internal Service exposing deployment Pods on port 80.

kubectl get ingress

List configured Ingress HTTP routing rules and external load balancer IPs.

ConfigMaps & Secrets

Command / PatternDescription
kubectl create configmap my-config --from-file=config.properties

Generate ConfigMap resource from a local raw file payload.

kubectl create secret generic my-secret --from-literal=key=val

Create base64-encoded secret payload imperatively.