Operations 6 min read

Essential Kubernetes Ops Cheat Sheet: Quick Commands & Tips

A concise reference guide that outlines core Kubernetes concepts, categorizes essential kubectl commands for creation, troubleshooting, rollout, scaling, port‑forwarding, node management, and multi‑cluster contexts, and provides practical tips and a quick‑lookup command table for everyday operations.

Ray's Galactic Tech
Ray's Galactic Tech
Ray's Galactic Tech
Essential Kubernetes Ops Cheat Sheet: Quick Commands & Tips

Core Concepts

Pod – the smallest deployable unit, a short‑lived group of containers.

Deployment – manages Pods, handling replica count, rolling updates, and rollbacks.

Service – provides a stable IP/DNS entry point and load‑balances traffic to Pods.

Namespace – logical partition of resources (e.g., dev / test / prod).

ConfigMap / Secret – decouple configuration and sensitive data from workloads.

Volume – external storage attached to Pods.

PV / PVC – PersistentVolume supplies storage; PersistentVolumeClaim requests it.

kubectl Command Categories

1. Create, Read, Update, Delete (CRUD)

kubectl get pods -o wide
kubectl apply -f app.yaml
kubectl delete pod <name>
kubectl edit deployment <name>

2. Troubleshooting

kubectl describe pod <name>
kubectl logs -f <pod-name> [-c container]
kubectl exec -it <pod> -- /bin/bash

3. Rolling Update / Rollback

kubectl rollout status deploy/<name>
kubectl rollout history deploy/<name>
kubectl rollout undo deploy/<name>
kubectl rollout restart deploy/<name>

4. Scaling

kubectl scale deploy/my-app --replicas=3

5. Port Forwarding

kubectl port-forward svc/my-app 8080:80

6. Cluster & Node Management

kubectl top nodes
kubectl cordon <node>
kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
kubectl uncordon <node>

7. Multi‑Cluster Contexts

kubectl config get-contexts
kubectl config use-context <name>

Operational Tips

Generate a Deployment YAML quickly

kubectl create deploy nginx --image=nginx --dry-run=client -o yaml > nginx.yaml

List Pods with a specific label kubectl get pods -l app=nginx Force‑delete a stuck Pod

kubectl delete pod <name> --force --grace-period=0

Enter the first Pod in the namespace

kubectl exec -it $(kubectl get po -o name | head -1) -- /bin/bash

Quick‑Lookup Command Table

Cluster information : kubectl cluster-info Node status : kubectl get nodes -o wide Deploy an application : kubectl apply -f app.yaml Deployment status : kubectl get deploy,rs,po -l app=my-app Service view : kubectl get svc -o wide Live logs : kubectl logs -f deploy/my-app Enter container : kubectl exec -it deploy/my-app -- bash Scale replicas : kubectl scale deploy/my-app --replicas=5 Update image : kubectl set image deploy/my-app my-app=nginx:1.20 Rollback : kubectl rollout undo deploy/my-app Resource usage : kubectl top pods --containers Config management : kubectl get cm,secret Storage management : kubectl get pv,pvc Drain node :

kubectl drain <node> --ignore-daemonsets

Recommendations

Bookmark this cheat sheet for fast command lookup.

Practice with kubectl get -o yaml to deepen understanding of resource definitions.

In production, prefer kubectl apply -f to manage YAML files and avoid undocumented manual edits.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

cloud-nativeKuberneteskubectlCheat Sheet
Ray's Galactic Tech
Written by

Ray's Galactic Tech

Practice together, never alone. We cover programming languages, development tools, learning methods, and pitfall notes. We simplify complex topics, guiding you from beginner to advanced. Weekly practical content—let's grow together!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.