Tools: Kubernetes Cheat Sheet: Essential kubectl Commands for Developers

Tools: Kubernetes Cheat Sheet: Essential kubectl Commands for Developers

Source: Dev.to

Table of Contents ## Getting Started ## Install kubectl ## Check Your Setup ## Understanding Kubernetes Objects ## Cluster and Context Management ## Viewing Contexts ## Switching Contexts ## Quick Tip: kubectx and kubens ## Viewing Pods ## Creating Pods ## Deleting Pods ## Interacting with Pods ## Deployments ## Viewing Deployments ## Creating Deployments ## Scaling Deployments ## Updating Deployments ## Rollouts and Rollbacks ## Deleting Deployments ## Services ## Service Types ## Viewing Services ## Creating Services ## Testing Services ## Deleting Services ## Namespaces ## Viewing Namespaces ## Working with Namespaces ## Default Namespaces ## ConfigMaps and Secrets ## ConfigMaps ## Secrets ## Logs and Debugging ## Viewing Logs ## Debugging Pods ## The Debugging Workflow ## Common Pod States ## Resource Management ## Setting Resource Limits ## Checking Resource Usage ## Resource Quotas ## Other Workload Types ## StatefulSets ## DaemonSets ## Jobs and CronJobs ## Common Debugging Workflows ## Workflow 1: Pod Keeps Crashing ## Workflow 2: Service Not Reachable ## Workflow 3: Pod Stuck in Pending ## Productivity Tips ## Essential Aliases ## Shell Completion ## Output Formats ## Dry Run and Diff ## Quick Reference Tables ## Most Used Commands ## Flags You Should Know ## Common Object Shortnames ## External Resources This cheat sheet is everything I wish I had when I started with Kubernetes. It covers the commands you will actually use, organized by what you are trying to do. No theory dumps. Just practical commands that work. Bookmark this. You'll be back. Before running commands, you need kubectl installed and configured. Windows (Chocolatey): After installation, verify it works: You should see output showing the client version. If you get "command not found", ensure kubectl is in your PATH. Everything in Kubernetes is an object. Here is how they relate: When you work with multiple clusters (dev, staging, prod), context management becomes essential. If you switch contexts frequently, install kubectx. It provides: Pods are the atomic unit of Kubernetes. A pod runs one or more containers that share network and storage. For production, always use Deployments instead of creating pods directly. Direct pods are not recreated when they die. Deployments manage pods and provide rolling updates, rollbacks, and scaling. Here is a basic deployment YAML: For understanding CPU and memory units like 100m and 128Mi, see Kubernetes Resource Units Explained. Services provide stable network endpoints for accessing pods. Since pods are ephemeral and get new IPs when recreated, Services give you a consistent way to reach them. Service YAML example: Important: The selector must match labels on your pods. If they do not match, the service will not route traffic to your pods. This is the most common service configuration mistake. Namespaces provide logical isolation within a cluster. Use them to separate environments, teams, or applications. ConfigMaps store non-sensitive configuration data. Using ConfigMap in a pod: Secrets store sensitive data like passwords, tokens, and keys. Values are base64 encoded (not encrypted by default). Using Secret in a pod: Security Note: Base64 is encoding, not encryption. Anyone with cluster access can decode secrets. For production, consider using a secrets management tool like HashiCorp Vault or AWS Secrets Manager. This is where you spend most of your time when things go wrong. When a pod is not working, follow this sequence: Always set resource requests and limits. Without them, a single pod can consume all node resources. See Kubernetes Resource Units for detailed explanations. Limit resources per namespace: Beyond Deployments, Kubernetes has specialized controllers for different workload patterns. For stateful applications that need stable network identity and persistent storage. Use for: databases, message queues, anything needing stable storage and network identity. Run one pod per node. Great for node agents. Use for: log collectors, monitoring agents, network plugins. Run tasks to completion or on a schedule. For cron expression syntax, see Cron Jobs Explained or use the Cron Expression Tool. Add these to your shell profile (.bashrc or .zshrc): Enable tab completion for kubectl: The best way to learn kubectl is to use it. Start with kubectl get and kubectl describe. When something breaks, follow the debugging workflow. The commands will become muscle memory faster than you expect. Originally published on my blog. Follow me for more system design and DevOps content. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: brew install kubectl Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: brew install kubectl CODE_BLOCK: brew install kubectl COMMAND_BLOCK: # Download the latest release curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" # Install kubectl sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Download the latest release curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" # Install kubectl sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl COMMAND_BLOCK: # Download the latest release curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" # Install kubectl sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl CODE_BLOCK: choco install kubernetes-cli Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: choco install kubernetes-cli CODE_BLOCK: choco install kubernetes-cli CODE_BLOCK: winget install -e --id Kubernetes.kubectl Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: winget install -e --id Kubernetes.kubectl CODE_BLOCK: winget install -e --id Kubernetes.kubectl COMMAND_BLOCK: kubectl version --client Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: kubectl version --client COMMAND_BLOCK: kubectl version --client COMMAND_BLOCK: # Check kubectl version kubectl version --client # Check cluster connection kubectl cluster-info # Check current context (which cluster you are talking to) kubectl config current-context # List all nodes in cluster kubectl get nodes Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Check kubectl version kubectl version --client # Check cluster connection kubectl cluster-info # Check current context (which cluster you are talking to) kubectl config current-context # List all nodes in cluster kubectl get nodes COMMAND_BLOCK: # Check kubectl version kubectl version --client # Check cluster connection kubectl cluster-info # Check current context (which cluster you are talking to) kubectl config current-context # List all nodes in cluster kubectl get nodes COMMAND_BLOCK: flowchart TB subgraph Control["Control Plane"] API[API Server] end subgraph Objects["Core Objects"] D[Deployment] RS[ReplicaSet] P[Pod] S[Service] CM[ConfigMap] SEC[Secret] end D --> RS RS --> P S --> P CM --> P SEC --> P API --> D API --> S API --> CM API --> SEC Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: flowchart TB subgraph Control["Control Plane"] API[API Server] end subgraph Objects["Core Objects"] D[Deployment] RS[ReplicaSet] P[Pod] S[Service] CM[ConfigMap] SEC[Secret] end D --> RS RS --> P S --> P CM --> P SEC --> P API --> D API --> S API --> CM API --> SEC COMMAND_BLOCK: flowchart TB subgraph Control["Control Plane"] API[API Server] end subgraph Objects["Core Objects"] D[Deployment] RS[ReplicaSet] P[Pod] S[Service] CM[ConfigMap] SEC[Secret] end D --> RS RS --> P S --> P CM --> P SEC --> P API --> D API --> S API --> CM API --> SEC COMMAND_BLOCK: # List all contexts kubectl config get-contexts # Show current context kubectl config current-context # Show full config kubectl config view Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List all contexts kubectl config get-contexts # Show current context kubectl config current-context # Show full config kubectl config view COMMAND_BLOCK: # List all contexts kubectl config get-contexts # Show current context kubectl config current-context # Show full config kubectl config view COMMAND_BLOCK: # Switch to a different cluster kubectl config use-context production-cluster # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Create a new context kubectl config set-context dev-context \ --cluster=dev-cluster \ --user=dev-user \ --namespace=development Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Switch to a different cluster kubectl config use-context production-cluster # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Create a new context kubectl config set-context dev-context \ --cluster=dev-cluster \ --user=dev-user \ --namespace=development COMMAND_BLOCK: # Switch to a different cluster kubectl config use-context production-cluster # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Create a new context kubectl config set-context dev-context \ --cluster=dev-cluster \ --user=dev-user \ --namespace=development COMMAND_BLOCK: # Instead of: kubectl config use-context production kubectx production # Instead of: kubectl config set-context --current --namespace=my-app kubens my-app Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Instead of: kubectl config use-context production kubectx production # Instead of: kubectl config set-context --current --namespace=my-app kubens my-app COMMAND_BLOCK: # Instead of: kubectl config use-context production kubectx production # Instead of: kubectl config set-context --current --namespace=my-app kubens my-app COMMAND_BLOCK: # List pods in current namespace kubectl get pods # List pods in all namespaces kubectl get pods -A # List pods with more details kubectl get pods -o wide # List pods with labels kubectl get pods --show-labels # Watch pods in real time kubectl get pods -w # Get pod details kubectl describe pod my-pod # Get pod YAML kubectl get pod my-pod -o yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List pods in current namespace kubectl get pods # List pods in all namespaces kubectl get pods -A # List pods with more details kubectl get pods -o wide # List pods with labels kubectl get pods --show-labels # Watch pods in real time kubectl get pods -w # Get pod details kubectl describe pod my-pod # Get pod YAML kubectl get pod my-pod -o yaml COMMAND_BLOCK: # List pods in current namespace kubectl get pods # List pods in all namespaces kubectl get pods -A # List pods with more details kubectl get pods -o wide # List pods with labels kubectl get pods --show-labels # Watch pods in real time kubectl get pods -w # Get pod details kubectl describe pod my-pod # Get pod YAML kubectl get pod my-pod -o yaml COMMAND_BLOCK: # Run a quick test pod kubectl run nginx --image=nginx # Run and expose a port kubectl run nginx --image=nginx --port=80 # Run with environment variables kubectl run myapp --image=myapp:v1 --env="DB_HOST=localhost" # Generate YAML without creating (dry run) kubectl run nginx --image=nginx --dry-run=client -o yaml > pod.yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Run a quick test pod kubectl run nginx --image=nginx # Run and expose a port kubectl run nginx --image=nginx --port=80 # Run with environment variables kubectl run myapp --image=myapp:v1 --env="DB_HOST=localhost" # Generate YAML without creating (dry run) kubectl run nginx --image=nginx --dry-run=client -o yaml > pod.yaml COMMAND_BLOCK: # Run a quick test pod kubectl run nginx --image=nginx # Run and expose a port kubectl run nginx --image=nginx --port=80 # Run with environment variables kubectl run myapp --image=myapp:v1 --env="DB_HOST=localhost" # Generate YAML without creating (dry run) kubectl run nginx --image=nginx --dry-run=client -o yaml > pod.yaml COMMAND_BLOCK: # Delete a pod kubectl delete pod my-pod # Delete pod immediately (no grace period) kubectl delete pod my-pod --grace-period=0 --force # Delete all pods in namespace kubectl delete pods --all # Delete pods by label kubectl delete pods -l app=myapp Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Delete a pod kubectl delete pod my-pod # Delete pod immediately (no grace period) kubectl delete pod my-pod --grace-period=0 --force # Delete all pods in namespace kubectl delete pods --all # Delete pods by label kubectl delete pods -l app=myapp COMMAND_BLOCK: # Delete a pod kubectl delete pod my-pod # Delete pod immediately (no grace period) kubectl delete pod my-pod --grace-period=0 --force # Delete all pods in namespace kubectl delete pods --all # Delete pods by label kubectl delete pods -l app=myapp COMMAND_BLOCK: # Execute command in pod kubectl exec my-pod -- ls /app # Get interactive shell kubectl exec -it my-pod -- /bin/bash # For pods without bash kubectl exec -it my-pod -- /bin/sh # Execute in specific container (multi-container pod) kubectl exec -it my-pod -c sidecar -- /bin/bash # Copy file to pod kubectl cp local-file.txt my-pod:/path/in/pod/ # Copy file from pod kubectl cp my-pod:/path/in/pod/file.txt ./local-copy.txt Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Execute command in pod kubectl exec my-pod -- ls /app # Get interactive shell kubectl exec -it my-pod -- /bin/bash # For pods without bash kubectl exec -it my-pod -- /bin/sh # Execute in specific container (multi-container pod) kubectl exec -it my-pod -c sidecar -- /bin/bash # Copy file to pod kubectl cp local-file.txt my-pod:/path/in/pod/ # Copy file from pod kubectl cp my-pod:/path/in/pod/file.txt ./local-copy.txt COMMAND_BLOCK: # Execute command in pod kubectl exec my-pod -- ls /app # Get interactive shell kubectl exec -it my-pod -- /bin/bash # For pods without bash kubectl exec -it my-pod -- /bin/sh # Execute in specific container (multi-container pod) kubectl exec -it my-pod -c sidecar -- /bin/bash # Copy file to pod kubectl cp local-file.txt my-pod:/path/in/pod/ # Copy file from pod kubectl cp my-pod:/path/in/pod/file.txt ./local-copy.txt COMMAND_BLOCK: # List deployments kubectl get deployments # List with details kubectl get deployments -o wide # Describe deployment kubectl describe deployment my-deployment # Get deployment YAML kubectl get deployment my-deployment -o yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List deployments kubectl get deployments # List with details kubectl get deployments -o wide # Describe deployment kubectl describe deployment my-deployment # Get deployment YAML kubectl get deployment my-deployment -o yaml COMMAND_BLOCK: # List deployments kubectl get deployments # List with details kubectl get deployments -o wide # Describe deployment kubectl describe deployment my-deployment # Get deployment YAML kubectl get deployment my-deployment -o yaml COMMAND_BLOCK: # Create deployment from image kubectl create deployment nginx --image=nginx # Create with replicas kubectl create deployment nginx --image=nginx --replicas=3 # Generate YAML without creating kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > deployment.yaml # Apply from YAML file (preferred method) kubectl apply -f deployment.yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Create deployment from image kubectl create deployment nginx --image=nginx # Create with replicas kubectl create deployment nginx --image=nginx --replicas=3 # Generate YAML without creating kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > deployment.yaml # Apply from YAML file (preferred method) kubectl apply -f deployment.yaml COMMAND_BLOCK: # Create deployment from image kubectl create deployment nginx --image=nginx # Create with replicas kubectl create deployment nginx --image=nginx --replicas=3 # Generate YAML without creating kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > deployment.yaml # Apply from YAML file (preferred method) kubectl apply -f deployment.yaml CODE_BLOCK: apiVersion: apps/v1 kind: Deployment metadata: name: web-app spec: replicas: 3 selector: matchLabels: app: web-app template: metadata: labels: app: web-app spec: containers: - name: web image: nginx:1.21 ports: - containerPort: 80 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: apiVersion: apps/v1 kind: Deployment metadata: name: web-app spec: replicas: 3 selector: matchLabels: app: web-app template: metadata: labels: app: web-app spec: containers: - name: web image: nginx:1.21 ports: - containerPort: 80 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi CODE_BLOCK: apiVersion: apps/v1 kind: Deployment metadata: name: web-app spec: replicas: 3 selector: matchLabels: app: web-app template: metadata: labels: app: web-app spec: containers: - name: web image: nginx:1.21 ports: - containerPort: 80 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi COMMAND_BLOCK: # Scale to 5 replicas kubectl scale deployment my-deployment --replicas=5 # Autoscale based on CPU kubectl autoscale deployment my-deployment --min=2 --max=10 --cpu-percent=80 # View autoscaler kubectl get hpa Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Scale to 5 replicas kubectl scale deployment my-deployment --replicas=5 # Autoscale based on CPU kubectl autoscale deployment my-deployment --min=2 --max=10 --cpu-percent=80 # View autoscaler kubectl get hpa COMMAND_BLOCK: # Scale to 5 replicas kubectl scale deployment my-deployment --replicas=5 # Autoscale based on CPU kubectl autoscale deployment my-deployment --min=2 --max=10 --cpu-percent=80 # View autoscaler kubectl get hpa COMMAND_BLOCK: flowchart LR D[Deployment: 3 replicas] --> RS[ReplicaSet] RS --> P1[Pod 1] RS --> P2[Pod 2] RS --> P3[Pod 3] HPA[HorizontalPodAutoscaler] --> D Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: flowchart LR D[Deployment: 3 replicas] --> RS[ReplicaSet] RS --> P1[Pod 1] RS --> P2[Pod 2] RS --> P3[Pod 3] HPA[HorizontalPodAutoscaler] --> D COMMAND_BLOCK: flowchart LR D[Deployment: 3 replicas] --> RS[ReplicaSet] RS --> P1[Pod 1] RS --> P2[Pod 2] RS --> P3[Pod 3] HPA[HorizontalPodAutoscaler] --> D COMMAND_BLOCK: # Update image (triggers rolling update) kubectl set image deployment/my-deployment web=nginx:1.22 # Edit deployment directly kubectl edit deployment my-deployment # Apply updated YAML kubectl apply -f deployment.yaml # Restart all pods (rolling restart) kubectl rollout restart deployment my-deployment Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Update image (triggers rolling update) kubectl set image deployment/my-deployment web=nginx:1.22 # Edit deployment directly kubectl edit deployment my-deployment # Apply updated YAML kubectl apply -f deployment.yaml # Restart all pods (rolling restart) kubectl rollout restart deployment my-deployment COMMAND_BLOCK: # Update image (triggers rolling update) kubectl set image deployment/my-deployment web=nginx:1.22 # Edit deployment directly kubectl edit deployment my-deployment # Apply updated YAML kubectl apply -f deployment.yaml # Restart all pods (rolling restart) kubectl rollout restart deployment my-deployment COMMAND_BLOCK: # Check rollout status kubectl rollout status deployment my-deployment # View rollout history kubectl rollout history deployment my-deployment # Rollback to previous version kubectl rollout undo deployment my-deployment # Rollback to specific revision kubectl rollout undo deployment my-deployment --to-revision=2 # Pause rollout kubectl rollout pause deployment my-deployment # Resume rollout kubectl rollout resume deployment my-deployment Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Check rollout status kubectl rollout status deployment my-deployment # View rollout history kubectl rollout history deployment my-deployment # Rollback to previous version kubectl rollout undo deployment my-deployment # Rollback to specific revision kubectl rollout undo deployment my-deployment --to-revision=2 # Pause rollout kubectl rollout pause deployment my-deployment # Resume rollout kubectl rollout resume deployment my-deployment COMMAND_BLOCK: # Check rollout status kubectl rollout status deployment my-deployment # View rollout history kubectl rollout history deployment my-deployment # Rollback to previous version kubectl rollout undo deployment my-deployment # Rollback to specific revision kubectl rollout undo deployment my-deployment --to-revision=2 # Pause rollout kubectl rollout pause deployment my-deployment # Resume rollout kubectl rollout resume deployment my-deployment COMMAND_BLOCK: # Delete deployment (also deletes pods) kubectl delete deployment my-deployment # Delete from YAML file kubectl delete -f deployment.yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Delete deployment (also deletes pods) kubectl delete deployment my-deployment # Delete from YAML file kubectl delete -f deployment.yaml COMMAND_BLOCK: # Delete deployment (also deletes pods) kubectl delete deployment my-deployment # Delete from YAML file kubectl delete -f deployment.yaml COMMAND_BLOCK: flowchart TB subgraph External["External Traffic"] User[Internet Users] end subgraph Cluster["Kubernetes Cluster"] LB[LoadBalancer Service] NP[NodePort Service] CIP[ClusterIP Service] subgraph Pods["Backend Pods"] P1[Pod 1] P2[Pod 2] P3[Pod 3] end end User --> LB LB --> Pods NP --> Pods CIP --> Pods Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: flowchart TB subgraph External["External Traffic"] User[Internet Users] end subgraph Cluster["Kubernetes Cluster"] LB[LoadBalancer Service] NP[NodePort Service] CIP[ClusterIP Service] subgraph Pods["Backend Pods"] P1[Pod 1] P2[Pod 2] P3[Pod 3] end end User --> LB LB --> Pods NP --> Pods CIP --> Pods COMMAND_BLOCK: flowchart TB subgraph External["External Traffic"] User[Internet Users] end subgraph Cluster["Kubernetes Cluster"] LB[LoadBalancer Service] NP[NodePort Service] CIP[ClusterIP Service] subgraph Pods["Backend Pods"] P1[Pod 1] P2[Pod 2] P3[Pod 3] end end User --> LB LB --> Pods NP --> Pods CIP --> Pods COMMAND_BLOCK: # List services kubectl get services # List with shorthand kubectl get svc # Describe service kubectl describe service my-service # Get service YAML kubectl get service my-service -o yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List services kubectl get services # List with shorthand kubectl get svc # Describe service kubectl describe service my-service # Get service YAML kubectl get service my-service -o yaml COMMAND_BLOCK: # List services kubectl get services # List with shorthand kubectl get svc # Describe service kubectl describe service my-service # Get service YAML kubectl get service my-service -o yaml COMMAND_BLOCK: # Expose deployment as ClusterIP (internal only) kubectl expose deployment my-deployment --port=80 # Expose as NodePort (accessible on node IP) kubectl expose deployment my-deployment --port=80 --type=NodePort # Expose as LoadBalancer (cloud only) kubectl expose deployment my-deployment --port=80 --type=LoadBalancer # Create from YAML kubectl apply -f service.yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Expose deployment as ClusterIP (internal only) kubectl expose deployment my-deployment --port=80 # Expose as NodePort (accessible on node IP) kubectl expose deployment my-deployment --port=80 --type=NodePort # Expose as LoadBalancer (cloud only) kubectl expose deployment my-deployment --port=80 --type=LoadBalancer # Create from YAML kubectl apply -f service.yaml COMMAND_BLOCK: # Expose deployment as ClusterIP (internal only) kubectl expose deployment my-deployment --port=80 # Expose as NodePort (accessible on node IP) kubectl expose deployment my-deployment --port=80 --type=NodePort # Expose as LoadBalancer (cloud only) kubectl expose deployment my-deployment --port=80 --type=LoadBalancer # Create from YAML kubectl apply -f service.yaml COMMAND_BLOCK: apiVersion: v1 kind: Service metadata: name: web-service spec: selector: app: web-app # Finds pods with this label ports: - port: 80 # Service port targetPort: 80 # Pod port type: ClusterIP Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: apiVersion: v1 kind: Service metadata: name: web-service spec: selector: app: web-app # Finds pods with this label ports: - port: 80 # Service port targetPort: 80 # Pod port type: ClusterIP COMMAND_BLOCK: apiVersion: v1 kind: Service metadata: name: web-service spec: selector: app: web-app # Finds pods with this label ports: - port: 80 # Service port targetPort: 80 # Pod port type: ClusterIP COMMAND_BLOCK: # Port forward to access locally kubectl port-forward service/my-service 8080:80 # Access at http://localhost:8080 # Get service endpoints (which pods it routes to) kubectl get endpoints my-service # Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Port forward to access locally kubectl port-forward service/my-service 8080:80 # Access at http://localhost:8080 # Get service endpoints (which pods it routes to) kubectl get endpoints my-service # Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 COMMAND_BLOCK: # Port forward to access locally kubectl port-forward service/my-service 8080:80 # Access at http://localhost:8080 # Get service endpoints (which pods it routes to) kubectl get endpoints my-service # Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 COMMAND_BLOCK: # Delete service kubectl delete service my-service # Delete by label kubectl delete service -l app=myapp Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Delete service kubectl delete service my-service # Delete by label kubectl delete service -l app=myapp COMMAND_BLOCK: # Delete service kubectl delete service my-service # Delete by label kubectl delete service -l app=myapp COMMAND_BLOCK: # List namespaces kubectl get namespaces # Short form kubectl get ns # Describe namespace kubectl describe namespace my-namespace Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List namespaces kubectl get namespaces # Short form kubectl get ns # Describe namespace kubectl describe namespace my-namespace COMMAND_BLOCK: # List namespaces kubectl get namespaces # Short form kubectl get ns # Describe namespace kubectl describe namespace my-namespace COMMAND_BLOCK: # Create namespace kubectl create namespace my-namespace # Run commands in specific namespace kubectl get pods -n my-namespace # Run commands in all namespaces kubectl get pods -A # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Delete namespace (deletes ALL resources inside) kubectl delete namespace my-namespace Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Create namespace kubectl create namespace my-namespace # Run commands in specific namespace kubectl get pods -n my-namespace # Run commands in all namespaces kubectl get pods -A # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Delete namespace (deletes ALL resources inside) kubectl delete namespace my-namespace COMMAND_BLOCK: # Create namespace kubectl create namespace my-namespace # Run commands in specific namespace kubectl get pods -n my-namespace # Run commands in all namespaces kubectl get pods -A # Set default namespace for current context kubectl config set-context --current --namespace=my-namespace # Delete namespace (deletes ALL resources inside) kubectl delete namespace my-namespace COMMAND_BLOCK: # Create from literal values kubectl create configmap my-config \ --from-literal=DATABASE_HOST=db.example.com \ --from-literal=LOG_LEVEL=info # Create from file kubectl create configmap app-config --from-file=config.properties # Create from directory kubectl create configmap app-config --from-file=./config-files/ # View configmap kubectl get configmap my-config -o yaml # Delete configmap kubectl delete configmap my-config Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Create from literal values kubectl create configmap my-config \ --from-literal=DATABASE_HOST=db.example.com \ --from-literal=LOG_LEVEL=info # Create from file kubectl create configmap app-config --from-file=config.properties # Create from directory kubectl create configmap app-config --from-file=./config-files/ # View configmap kubectl get configmap my-config -o yaml # Delete configmap kubectl delete configmap my-config COMMAND_BLOCK: # Create from literal values kubectl create configmap my-config \ --from-literal=DATABASE_HOST=db.example.com \ --from-literal=LOG_LEVEL=info # Create from file kubectl create configmap app-config --from-file=config.properties # Create from directory kubectl create configmap app-config --from-file=./config-files/ # View configmap kubectl get configmap my-config -o yaml # Delete configmap kubectl delete configmap my-config COMMAND_BLOCK: spec: containers: - name: app image: myapp envFrom: - configMapRef: name: my-config # Or mount as volume volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: my-config Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: spec: containers: - name: app image: myapp envFrom: - configMapRef: name: my-config # Or mount as volume volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: my-config COMMAND_BLOCK: spec: containers: - name: app image: myapp envFrom: - configMapRef: name: my-config # Or mount as volume volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: my-config COMMAND_BLOCK: # Create from literal values kubectl create secret generic db-secret \ --from-literal=username=admin \ --from-literal=password=s3cret # Create from file kubectl create secret generic tls-secret \ --from-file=tls.crt=path/to/cert \ --from-file=tls.key=path/to/key # Create Docker registry secret kubectl create secret docker-registry regcred \ --docker-server=registry.example.com \ --docker-username=user \ --docker-password=pass # View secret (base64 encoded) kubectl get secret my-secret -o yaml # Decode secret value kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 --decode # Delete secret kubectl delete secret my-secret Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Create from literal values kubectl create secret generic db-secret \ --from-literal=username=admin \ --from-literal=password=s3cret # Create from file kubectl create secret generic tls-secret \ --from-file=tls.crt=path/to/cert \ --from-file=tls.key=path/to/key # Create Docker registry secret kubectl create secret docker-registry regcred \ --docker-server=registry.example.com \ --docker-username=user \ --docker-password=pass # View secret (base64 encoded) kubectl get secret my-secret -o yaml # Decode secret value kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 --decode # Delete secret kubectl delete secret my-secret COMMAND_BLOCK: # Create from literal values kubectl create secret generic db-secret \ --from-literal=username=admin \ --from-literal=password=s3cret # Create from file kubectl create secret generic tls-secret \ --from-file=tls.crt=path/to/cert \ --from-file=tls.key=path/to/key # Create Docker registry secret kubectl create secret docker-registry regcred \ --docker-server=registry.example.com \ --docker-username=user \ --docker-password=pass # View secret (base64 encoded) kubectl get secret my-secret -o yaml # Decode secret value kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 --decode # Delete secret kubectl delete secret my-secret CODE_BLOCK: spec: containers: - name: app image: myapp env: - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: password Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: spec: containers: - name: app image: myapp env: - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: password CODE_BLOCK: spec: containers: - name: app image: myapp env: - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: password COMMAND_BLOCK: # View pod logs kubectl logs my-pod # Follow logs in real time kubectl logs -f my-pod # View last 100 lines kubectl logs --tail=100 my-pod # View logs from last hour kubectl logs --since=1h my-pod # View logs from specific container kubectl logs my-pod -c sidecar # View logs from previous container (after crash) kubectl logs my-pod --previous # View logs from all pods with label kubectl logs -l app=myapp # View logs from all containers in pod kubectl logs my-pod --all-containers Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # View pod logs kubectl logs my-pod # Follow logs in real time kubectl logs -f my-pod # View last 100 lines kubectl logs --tail=100 my-pod # View logs from last hour kubectl logs --since=1h my-pod # View logs from specific container kubectl logs my-pod -c sidecar # View logs from previous container (after crash) kubectl logs my-pod --previous # View logs from all pods with label kubectl logs -l app=myapp # View logs from all containers in pod kubectl logs my-pod --all-containers COMMAND_BLOCK: # View pod logs kubectl logs my-pod # Follow logs in real time kubectl logs -f my-pod # View last 100 lines kubectl logs --tail=100 my-pod # View logs from last hour kubectl logs --since=1h my-pod # View logs from specific container kubectl logs my-pod -c sidecar # View logs from previous container (after crash) kubectl logs my-pod --previous # View logs from all pods with label kubectl logs -l app=myapp # View logs from all containers in pod kubectl logs my-pod --all-containers COMMAND_BLOCK: # Get detailed pod info kubectl describe pod my-pod # Check events in namespace kubectl get events --sort-by='.lastTimestamp' # Check events for specific pod kubectl get events --field-selector involvedObject.name=my-pod # Get shell in running pod kubectl exec -it my-pod -- /bin/bash # Run debug container (for distroless images) kubectl debug my-pod -it --image=busybox # Check pod resource usage kubectl top pods # Check node resource usage kubectl top nodes Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Get detailed pod info kubectl describe pod my-pod # Check events in namespace kubectl get events --sort-by='.lastTimestamp' # Check events for specific pod kubectl get events --field-selector involvedObject.name=my-pod # Get shell in running pod kubectl exec -it my-pod -- /bin/bash # Run debug container (for distroless images) kubectl debug my-pod -it --image=busybox # Check pod resource usage kubectl top pods # Check node resource usage kubectl top nodes COMMAND_BLOCK: # Get detailed pod info kubectl describe pod my-pod # Check events in namespace kubectl get events --sort-by='.lastTimestamp' # Check events for specific pod kubectl get events --field-selector involvedObject.name=my-pod # Get shell in running pod kubectl exec -it my-pod -- /bin/bash # Run debug container (for distroless images) kubectl debug my-pod -it --image=busybox # Check pod resource usage kubectl top pods # Check node resource usage kubectl top nodes COMMAND_BLOCK: flowchart TB A[Pod Issue] --> B{kubectl get pods} B -->|CrashLoopBackOff| C[kubectl logs pod --previous] B -->|Pending| D[kubectl describe pod] B -->|Running but broken| E[kubectl logs pod] C --> F{Check application error} D --> G{Check Events section} E --> H{Check for errors} F --> I[Fix code or config] G --> J[Fix scheduling or resources] H --> K[Fix application logic] Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: flowchart TB A[Pod Issue] --> B{kubectl get pods} B -->|CrashLoopBackOff| C[kubectl logs pod --previous] B -->|Pending| D[kubectl describe pod] B -->|Running but broken| E[kubectl logs pod] C --> F{Check application error} D --> G{Check Events section} E --> H{Check for errors} F --> I[Fix code or config] G --> J[Fix scheduling or resources] H --> K[Fix application logic] COMMAND_BLOCK: flowchart TB A[Pod Issue] --> B{kubectl get pods} B -->|CrashLoopBackOff| C[kubectl logs pod --previous] B -->|Pending| D[kubectl describe pod] B -->|Running but broken| E[kubectl logs pod] C --> F{Check application error} D --> G{Check Events section} E --> H{Check for errors} F --> I[Fix code or config] G --> J[Fix scheduling or resources] H --> K[Fix application logic] COMMAND_BLOCK: resources: requests: cpu: 100m # Guaranteed CPU memory: 128Mi # Guaranteed memory limits: cpu: 500m # Maximum CPU memory: 512Mi # Maximum memory (OOMKill if exceeded) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: resources: requests: cpu: 100m # Guaranteed CPU memory: 128Mi # Guaranteed memory limits: cpu: 500m # Maximum CPU memory: 512Mi # Maximum memory (OOMKill if exceeded) COMMAND_BLOCK: resources: requests: cpu: 100m # Guaranteed CPU memory: 128Mi # Guaranteed memory limits: cpu: 500m # Maximum CPU memory: 512Mi # Maximum memory (OOMKill if exceeded) COMMAND_BLOCK: # Pod resource usage (requires metrics-server) kubectl top pods # Node resource usage kubectl top nodes # Pod resource usage sorted by memory kubectl top pods --sort-by=memory # Describe node to see allocatable resources kubectl describe node my-node | grep -A 5 "Allocatable" Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Pod resource usage (requires metrics-server) kubectl top pods # Node resource usage kubectl top nodes # Pod resource usage sorted by memory kubectl top pods --sort-by=memory # Describe node to see allocatable resources kubectl describe node my-node | grep -A 5 "Allocatable" COMMAND_BLOCK: # Pod resource usage (requires metrics-server) kubectl top pods # Node resource usage kubectl top nodes # Pod resource usage sorted by memory kubectl top pods --sort-by=memory # Describe node to see allocatable resources kubectl describe node my-node | grep -A 5 "Allocatable" COMMAND_BLOCK: # View resource quotas kubectl get resourcequota # Describe quota kubectl describe resourcequota my-quota Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # View resource quotas kubectl get resourcequota # Describe quota kubectl describe resourcequota my-quota COMMAND_BLOCK: # View resource quotas kubectl get resourcequota # Describe quota kubectl describe resourcequota my-quota CODE_BLOCK: apiVersion: v1 kind: ResourceQuota metadata: name: compute-quota spec: hard: requests.cpu: "4" requests.memory: 8Gi limits.cpu: "8" limits.memory: 16Gi pods: "20" Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: apiVersion: v1 kind: ResourceQuota metadata: name: compute-quota spec: hard: requests.cpu: "4" requests.memory: 8Gi limits.cpu: "8" limits.memory: 16Gi pods: "20" CODE_BLOCK: apiVersion: v1 kind: ResourceQuota metadata: name: compute-quota spec: hard: requests.cpu: "4" requests.memory: 8Gi limits.cpu: "8" limits.memory: 16Gi pods: "20" COMMAND_BLOCK: # List statefulsets kubectl get statefulsets # Scale statefulset kubectl scale statefulset my-statefulset --replicas=5 # Delete pod (will be recreated with same identity) kubectl delete pod my-statefulset-0 Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List statefulsets kubectl get statefulsets # Scale statefulset kubectl scale statefulset my-statefulset --replicas=5 # Delete pod (will be recreated with same identity) kubectl delete pod my-statefulset-0 COMMAND_BLOCK: # List statefulsets kubectl get statefulsets # Scale statefulset kubectl scale statefulset my-statefulset --replicas=5 # Delete pod (will be recreated with same identity) kubectl delete pod my-statefulset-0 COMMAND_BLOCK: # List daemonsets kubectl get daemonsets # Describe daemonset kubectl describe daemonset my-daemonset Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # List daemonsets kubectl get daemonsets # Describe daemonset kubectl describe daemonset my-daemonset COMMAND_BLOCK: # List daemonsets kubectl get daemonsets # Describe daemonset kubectl describe daemonset my-daemonset COMMAND_BLOCK: # Create job kubectl create job my-job --image=busybox -- echo "Hello" # List jobs kubectl get jobs # Create cronjob kubectl create cronjob my-cronjob --image=busybox --schedule="0 * * * *" -- echo "Hourly" # List cronjobs kubectl get cronjobs # View job logs kubectl logs job/my-job Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Create job kubectl create job my-job --image=busybox -- echo "Hello" # List jobs kubectl get jobs # Create cronjob kubectl create cronjob my-cronjob --image=busybox --schedule="0 * * * *" -- echo "Hourly" # List cronjobs kubectl get cronjobs # View job logs kubectl logs job/my-job COMMAND_BLOCK: # Create job kubectl create job my-job --image=busybox -- echo "Hello" # List jobs kubectl get jobs # Create cronjob kubectl create cronjob my-cronjob --image=busybox --schedule="0 * * * *" -- echo "Hourly" # List cronjobs kubectl get cronjobs # View job logs kubectl logs job/my-job COMMAND_BLOCK: # 1. Check pod status kubectl get pods # 2. Check events kubectl describe pod my-pod | grep -A 20 Events # 3. Check previous logs (from crashed container) kubectl logs my-pod --previous # 4. Check current logs kubectl logs my-pod # 5. Check resource limits kubectl describe pod my-pod | grep -A 10 Limits Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # 1. Check pod status kubectl get pods # 2. Check events kubectl describe pod my-pod | grep -A 20 Events # 3. Check previous logs (from crashed container) kubectl logs my-pod --previous # 4. Check current logs kubectl logs my-pod # 5. Check resource limits kubectl describe pod my-pod | grep -A 10 Limits COMMAND_BLOCK: # 1. Check pod status kubectl get pods # 2. Check events kubectl describe pod my-pod | grep -A 20 Events # 3. Check previous logs (from crashed container) kubectl logs my-pod --previous # 4. Check current logs kubectl logs my-pod # 5. Check resource limits kubectl describe pod my-pod | grep -A 10 Limits COMMAND_BLOCK: # 1. Check service exists kubectl get service my-service # 2. Check endpoints (pods the service routes to) kubectl get endpoints my-service # 3. If no endpoints, check selector matches pod labels kubectl describe service my-service kubectl get pods --show-labels # 4. Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 # 5. Check pod is ready kubectl get pods -l app=myapp Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # 1. Check service exists kubectl get service my-service # 2. Check endpoints (pods the service routes to) kubectl get endpoints my-service # 3. If no endpoints, check selector matches pod labels kubectl describe service my-service kubectl get pods --show-labels # 4. Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 # 5. Check pod is ready kubectl get pods -l app=myapp COMMAND_BLOCK: # 1. Check service exists kubectl get service my-service # 2. Check endpoints (pods the service routes to) kubectl get endpoints my-service # 3. If no endpoints, check selector matches pod labels kubectl describe service my-service kubectl get pods --show-labels # 4. Test from within cluster kubectl run test --image=busybox --rm -it -- wget -qO- my-service:80 # 5. Check pod is ready kubectl get pods -l app=myapp COMMAND_BLOCK: # 1. Check pod events kubectl describe pod my-pod | grep -A 10 Events # 2. Check node resources kubectl describe nodes | grep -A 5 "Allocated resources" # 3. Check for taints kubectl describe nodes | grep Taints # 4. Check pod resource requests kubectl get pod my-pod -o yaml | grep -A 10 resources Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # 1. Check pod events kubectl describe pod my-pod | grep -A 10 Events # 2. Check node resources kubectl describe nodes | grep -A 5 "Allocated resources" # 3. Check for taints kubectl describe nodes | grep Taints # 4. Check pod resource requests kubectl get pod my-pod -o yaml | grep -A 10 resources COMMAND_BLOCK: # 1. Check pod events kubectl describe pod my-pod | grep -A 10 Events # 2. Check node resources kubectl describe nodes | grep -A 5 "Allocated resources" # 3. Check for taints kubectl describe nodes | grep Taints # 4. Check pod resource requests kubectl get pod my-pod -o yaml | grep -A 10 resources COMMAND_BLOCK: # Basic alias alias k=kubectl # Get commands alias kg='kubectl get' alias kgp='kubectl get pods' alias kgd='kubectl get deployments' alias kgs='kubectl get services' alias kgn='kubectl get nodes' # Describe and logs alias kd='kubectl describe' alias kl='kubectl logs' alias klf='kubectl logs -f' # Apply and delete alias ka='kubectl apply -f' alias kdel='kubectl delete' # Context alias kctx='kubectl config use-context' alias kns='kubectl config set-context --current --namespace' Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Basic alias alias k=kubectl # Get commands alias kg='kubectl get' alias kgp='kubectl get pods' alias kgd='kubectl get deployments' alias kgs='kubectl get services' alias kgn='kubectl get nodes' # Describe and logs alias kd='kubectl describe' alias kl='kubectl logs' alias klf='kubectl logs -f' # Apply and delete alias ka='kubectl apply -f' alias kdel='kubectl delete' # Context alias kctx='kubectl config use-context' alias kns='kubectl config set-context --current --namespace' COMMAND_BLOCK: # Basic alias alias k=kubectl # Get commands alias kg='kubectl get' alias kgp='kubectl get pods' alias kgd='kubectl get deployments' alias kgs='kubectl get services' alias kgn='kubectl get nodes' # Describe and logs alias kd='kubectl describe' alias kl='kubectl logs' alias klf='kubectl logs -f' # Apply and delete alias ka='kubectl apply -f' alias kdel='kubectl delete' # Context alias kctx='kubectl config use-context' alias kns='kubectl config set-context --current --namespace' COMMAND_BLOCK: # Bash echo 'source <(kubectl completion bash)' >> ~/.bashrc # Zsh echo 'source <(kubectl completion zsh)' >> ~/.zshrc # Make alias work with completion complete -F __start_kubectl k Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Bash echo 'source <(kubectl completion bash)' >> ~/.bashrc # Zsh echo 'source <(kubectl completion zsh)' >> ~/.zshrc # Make alias work with completion complete -F __start_kubectl k COMMAND_BLOCK: # Bash echo 'source <(kubectl completion bash)' >> ~/.bashrc # Zsh echo 'source <(kubectl completion zsh)' >> ~/.zshrc # Make alias work with completion complete -F __start_kubectl k COMMAND_BLOCK: # Wide output (more columns) kubectl get pods -o wide # YAML output kubectl get pod my-pod -o yaml # JSON output kubectl get pod my-pod -o json # Custom columns kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase # JSONPath (extract specific fields) kubectl get pods -o jsonpath='{.items[*].metadata.name}' # Get just names kubectl get pods -o name Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Wide output (more columns) kubectl get pods -o wide # YAML output kubectl get pod my-pod -o yaml # JSON output kubectl get pod my-pod -o json # Custom columns kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase # JSONPath (extract specific fields) kubectl get pods -o jsonpath='{.items[*].metadata.name}' # Get just names kubectl get pods -o name COMMAND_BLOCK: # Wide output (more columns) kubectl get pods -o wide # YAML output kubectl get pod my-pod -o yaml # JSON output kubectl get pod my-pod -o json # Custom columns kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase # JSONPath (extract specific fields) kubectl get pods -o jsonpath='{.items[*].metadata.name}' # Get just names kubectl get pods -o name COMMAND_BLOCK: # Preview what would be created kubectl apply -f deployment.yaml --dry-run=client # Server-side dry run (validates against API) kubectl apply -f deployment.yaml --dry-run=server # Show diff before applying kubectl diff -f deployment.yaml Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: # Preview what would be created kubectl apply -f deployment.yaml --dry-run=client # Server-side dry run (validates against API) kubectl apply -f deployment.yaml --dry-run=server # Show diff before applying kubectl diff -f deployment.yaml COMMAND_BLOCK: # Preview what would be created kubectl apply -f deployment.yaml --dry-run=client # Server-side dry run (validates against API) kubectl apply -f deployment.yaml --dry-run=server # Show diff before applying kubectl diff -f deployment.yaml - Getting Started - Cluster and Context Management - Deployments - ConfigMaps and Secrets - Logs and Debugging - Resource Management - Other Workload Types - Common Debugging Workflows - Productivity Tips - Quick Reference Tables - kubectx to switch clusters quickly - kubens to switch namespaces quickly - Application error (check logs) - OOMKilled (increase memory limit) - Liveness probe failing (check probe config) - Missing dependencies (check ConfigMaps, Secrets, Services) - Selector does not match pod labels - Pod is not ready (readiness probe failing) - Wrong port in service definition - Pod crashed - Insufficient CPU or memory on nodes - Node selector or affinity not matching any nodes - Taints without matching tolerations - Volume cannot be mounted - Official kubectl Cheat Sheet - Kubernetes Documentation - kubectx + kubens for fast context switching - k9s terminal UI for Kubernetes - Lens desktop Kubernetes IDE - System Design Cheat Sheet - Linux Commands Cheat Sheet - Git Cheat Sheet