📖 Guide

Kubernetes & kubectl Cheat Sheet — Complete Reference

Every kubectl command you need for managing Kubernetes clusters, pods, deployments, and services.

129 commands across 12 categories

Cluster Info

CommandDescription
kubectl cluster-info
Display cluster endpoint and services info
kubectl version
Show kubectl client and server versions
kubectl config view
Show merged kubeconfig settings
kubectl config current-context
Display the current context
kubectl config use-context <context>
e.g. kubectl config use-context production
Switch to a different cluster context
kubectl config get-contexts
List all available contexts
kubectl config set-context --current --namespace=<ns>
e.g. kubectl config set-context --current --namespace=my-app
Set the default namespace for the current context
kubectl api-resources
List all supported API resources and their short names
kubectl api-versions
List all supported API versions
kubectl get componentstatuses
Check health of cluster components (scheduler, etcd, controller-manager)

Pods

CommandDescription
kubectl get pods
List all pods in the current namespace
kubectl get pods -A
List pods across all namespaces
kubectl get pods -o wide
List pods with extra details (node, IP)
kubectl get pods -w
Watch pods in real time
kubectl get pods --sort-by=.metadata.creationTimestamp
List pods sorted by creation time
kubectl get pods --field-selector=status.phase=Running
List only running pods
kubectl describe pod <pod>
Show detailed info about a pod (events, containers, volumes)
kubectl run <name> --image=<image>
e.g. kubectl run nginx --image=nginx:latest
Create and run a pod from an image
kubectl run <name> --image=<image> --rm -it -- <cmd>
e.g. kubectl run debug --image=busybox --rm -it -- sh
Run a temporary interactive pod (deleted on exit)
kubectl delete pod <pod>
Delete a pod
kubectl delete pod <pod> --grace-period=0 --force
Force delete a stuck pod immediately
kubectl exec -it <pod> -- <cmd>
e.g. kubectl exec -it my-pod -- /bin/bash
Execute a command inside a running pod
kubectl exec -it <pod> -c <container> -- <cmd>
Execute a command in a specific container within a multi-container pod
kubectl cp <pod>:<path> <local-path>
e.g. kubectl cp my-pod:/var/log/app.log ./app.log
Copy files from a pod to local machine
kubectl cp <local-path> <pod>:<path>
Copy files from local machine to a pod
kubectl get pod <pod> -o yaml
Output pod definition as YAML
kubectl get pod <pod> -o jsonpath='{.status.podIP}'
Get a specific field using JSONPath
kubectl label pod <pod> <key>=<value>
e.g. kubectl label pod my-pod env=production
Add or update a label on a pod
kubectl annotate pod <pod> <key>=<value>
Add or update an annotation on a pod

Deployments

CommandDescription
kubectl get deployments
List all deployments in the current namespace
kubectl describe deployment <name>
Show detailed deployment info including strategy and events
kubectl create deployment <name> --image=<image>
e.g. kubectl create deployment web --image=nginx:1.25
Create a deployment
kubectl apply -f <file>
e.g. kubectl apply -f deployment.yaml
Apply a deployment from a YAML file
kubectl set image deployment/<name> <container>=<image>
e.g. kubectl set image deployment/web nginx=nginx:1.26
Update the image for a deployment (rolling update)
kubectl rollout status deployment/<name>
Watch rollout progress of a deployment
kubectl rollout history deployment/<name>
View rollout history and revisions
kubectl rollout undo deployment/<name>
Rollback to the previous revision
kubectl rollout undo deployment/<name> --to-revision=<n>
e.g. kubectl rollout undo deployment/web --to-revision=3
Rollback to a specific revision number
kubectl rollout restart deployment/<name>
Restart all pods in a deployment (rolling restart)
kubectl rollout pause deployment/<name>
Pause a rollout to batch multiple changes
kubectl rollout resume deployment/<name>
Resume a paused rollout
kubectl delete deployment <name>
Delete a deployment and all its pods
kubectl edit deployment <name>
Edit a deployment in your default editor
kubectl patch deployment <name> -p '{"spec":{"replicas":5}}'
Patch a deployment inline with JSON

Services

CommandDescription
kubectl get services
List all services in the current namespace
kubectl get svc
List services (short alias)
kubectl describe service <name>
Show detailed service info including endpoints
kubectl expose deployment <name> --port=<port> --type=ClusterIP
e.g. kubectl expose deployment web --port=80 --type=ClusterIP
Create a ClusterIP service for a deployment
kubectl expose deployment <name> --port=<port> --type=NodePort
Create a NodePort service accessible on every node
kubectl expose deployment <name> --port=<port> --type=LoadBalancer
Create a LoadBalancer service (cloud only)
kubectl get endpoints <service>
Show the endpoint IPs backing a service
kubectl delete service <name>
Delete a service
kubectl port-forward svc/<name> <local>:<remote>
e.g. kubectl port-forward svc/web 8080:80
Forward a local port to a service
kubectl port-forward pod/<name> <local>:<remote>
Forward a local port directly to a pod

ConfigMaps & Secrets

CommandDescription
kubectl get configmaps
List all ConfigMaps
kubectl create configmap <name> --from-literal=<key>=<value>
e.g. kubectl create configmap app-config --from-literal=DB_HOST=db.example.com
Create a ConfigMap from literal key-value pairs
kubectl create configmap <name> --from-file=<path>
e.g. kubectl create configmap nginx-conf --from-file=nginx.conf
Create a ConfigMap from a file or directory
kubectl describe configmap <name>
Show ConfigMap details and data
kubectl get configmap <name> -o yaml
Output ConfigMap as YAML
kubectl delete configmap <name>
Delete a ConfigMap
kubectl get secrets
List all secrets in the current namespace
kubectl create secret generic <name> --from-literal=<key>=<value>
e.g. kubectl create secret generic db-creds --from-literal=password=s3cret
Create a secret from literal values
kubectl create secret tls <name> --cert=<cert> --key=<key>
e.g. kubectl create secret tls my-tls --cert=tls.crt --key=tls.key
Create a TLS secret from cert and key files
kubectl get secret <name> -o jsonpath='{.data.<key>}' | base64 -d
e.g. kubectl get secret db-creds -o jsonpath='{.data.password}' | base64 -d
Decode and view a secret value
kubectl delete secret <name>
Delete a secret

Namespaces

CommandDescription
kubectl get namespaces
List all namespaces
kubectl create namespace <name>
e.g. kubectl create namespace staging
Create a new namespace
kubectl delete namespace <name>
Delete a namespace and all resources within it
kubectl get all -n <namespace>
List all resources in a specific namespace
kubectl get all -A
List all resources across all namespaces

Nodes

CommandDescription
kubectl get nodes
List all nodes in the cluster
kubectl get nodes -o wide
List nodes with extra info (OS, kernel, container runtime)
kubectl describe node <name>
Show detailed node info (capacity, conditions, pods)
kubectl top nodes
Show CPU and memory usage per node (requires metrics-server)
kubectl cordon <node>
Mark a node as unschedulable (no new pods)
kubectl uncordon <node>
Mark a node as schedulable again
kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
Evict all pods from a node for maintenance
kubectl taint nodes <node> <key>=<value>:<effect>
e.g. kubectl taint nodes node1 dedicated=gpu:NoSchedule
Add a taint to a node
kubectl taint nodes <node> <key>-
e.g. kubectl taint nodes node1 dedicated-
Remove a taint from a node

Logs & Debugging

CommandDescription
kubectl logs <pod>
View logs of a pod
kubectl logs <pod> -f
Stream logs in real time (follow)
kubectl logs <pod> --tail=100
Show only the last 100 log lines
kubectl logs <pod> --since=1h
Show logs from the last hour
kubectl logs <pod> -c <container>
View logs of a specific container in a multi-container pod
kubectl logs <pod> --previous
View logs of a previously crashed container
kubectl logs -l <label>=<value>
e.g. kubectl logs -l app=web
View logs from all pods matching a label
kubectl top pods
Show CPU and memory usage per pod
kubectl top pods --sort-by=cpu
Show pods sorted by CPU usage
kubectl get events --sort-by=.metadata.creationTimestamp
List cluster events sorted by time
kubectl get events --field-selector type=Warning
List only warning events
kubectl debug node/<node> -it --image=busybox
Start a debug container on a node
kubectl auth can-i <verb> <resource>
e.g. kubectl auth can-i create deployments
Check if you have permission to perform an action

Scaling

CommandDescription
kubectl scale deployment/<name> --replicas=<n>
e.g. kubectl scale deployment/web --replicas=5
Scale a deployment to N replicas
kubectl autoscale deployment/<name> --min=<n> --max=<n> --cpu-percent=<n>
e.g. kubectl autoscale deployment/web --min=2 --max=10 --cpu-percent=70
Create a Horizontal Pod Autoscaler
kubectl get hpa
List all Horizontal Pod Autoscalers
kubectl describe hpa <name>
Show HPA details including current/target metrics
kubectl delete hpa <name>
Delete a Horizontal Pod Autoscaler
kubectl scale statefulset/<name> --replicas=<n>
Scale a StatefulSet

Networking

CommandDescription
kubectl get ingress
List all Ingress resources
kubectl describe ingress <name>
Show detailed Ingress info (rules, backends)
kubectl get networkpolicies
List all NetworkPolicies
kubectl apply -f ingress.yaml
Create or update an Ingress from a YAML file
kubectl run tmp --image=busybox --rm -it -- wget -qO- <service>:<port>
e.g. kubectl run tmp --image=busybox --rm -it -- wget -qO- web:80
Test service connectivity from within the cluster
kubectl run tmp --image=busybox --rm -it -- nslookup <service>
Test DNS resolution inside the cluster
kubectl get svc -n kube-system
Check core DNS and system services

RBAC

CommandDescription
kubectl get roles
List Roles in the current namespace
kubectl get clusterroles
List all ClusterRoles
kubectl get rolebindings
List RoleBindings in the current namespace
kubectl get clusterrolebindings
List all ClusterRoleBindings
kubectl create role <name> --verb=<verbs> --resource=<resources>
e.g. kubectl create role pod-reader --verb=get,list,watch --resource=pods
Create a Role with specific permissions
kubectl create rolebinding <name> --role=<role> --user=<user>
e.g. kubectl create rolebinding read-pods --role=pod-reader --user=jane
Bind a Role to a user
kubectl create clusterrolebinding <name> --clusterrole=<role> --serviceaccount=<ns>:<sa>
Bind a ClusterRole to a service account
kubectl auth can-i --list
List all permissions for the current user
kubectl auth can-i <verb> <resource> --as=<user>
e.g. kubectl auth can-i create pods --as=jane
Check permissions as another user (impersonate)

Helm

CommandDescription
helm repo add <name> <url>
e.g. helm repo add bitnami https://charts.bitnami.com/bitnami
Add a Helm chart repository
helm repo update
Update all Helm repo indexes
helm search repo <keyword>
e.g. helm search repo nginx
Search for charts in added repos
helm install <release> <chart>
e.g. helm install my-nginx bitnami/nginx
Install a Helm chart as a release
helm install <release> <chart> -f values.yaml
Install with custom values file
helm install <release> <chart> --set <key>=<value>
e.g. helm install my-nginx bitnami/nginx --set replicaCount=3
Install with inline value overrides
helm upgrade <release> <chart>
Upgrade a release to a new chart version or values
helm rollback <release> <revision>
e.g. helm rollback my-nginx 1
Rollback a release to a previous revision
helm list
List all Helm releases in the current namespace
helm list -A
List releases across all namespaces
helm status <release>
Show status and notes for a release
helm history <release>
Show revision history of a release
helm uninstall <release>
Uninstall a release
helm template <release> <chart>
Render chart templates locally without installing
helm show values <chart>
e.g. helm show values bitnami/nginx
Show default values of a chart

More Guides

🌿
Git Commands
Complete Git command reference — from basics to advanced workflows. Searchable, with examples.
📝
Vim Commands
Complete Vim/Vi command reference — modes, motions, editing, search, and advanced features.
🐳
Docker Commands
Complete Docker & Docker Compose command reference — containers, images, volumes, networks, and orchestration.
🔤
Regex Reference
Complete regular expression reference — syntax, patterns, quantifiers, groups, lookaheads, and common recipes.
🐧
Linux Commands
Complete Linux/Bash command reference — file management, text processing, networking, system admin, and shell scripting.
🐍
Python Reference
Complete Python reference — syntax, data structures, string methods, file I/O, comprehensions, and common patterns.
🗃️
SQL Reference
Complete SQL reference — queries, joins, aggregation, subqueries, indexes, and database management.
🌐
Nginx Reference
Complete Nginx configuration reference — server blocks, locations, proxying, SSL, load balancing, and caching.
🔐
SSH Commands
Complete SSH reference — connections, key management, tunneling, config, SCP/SFTP, and security hardening.
👷
Jenkins Reference
Complete Jenkins reference — pipeline syntax, Jenkinsfile, plugins, CLI, agents, and CI/CD patterns.
📨
HTTP Headers Reference
Complete HTTP headers reference — request headers, response headers, caching, security, CORS, and content negotiation. Searchable, with examples.
🐘
PostgreSQL Reference
Comprehensive PostgreSQL reference — from connection basics to advanced features like JSONB, full-text search, window functions, and performance tuning.
Async Patterns Reference
Multi-language async/concurrency patterns — JavaScript, Python, Go, Rust, Java, and universal concurrency patterns.
📡
Protobuf & gRPC Reference
Comprehensive reference for Protocol Buffers (proto3) and gRPC — message definitions, services, streaming, and common patterns.
📚
JS Array Methods
Complete JavaScript Array methods reference — creating, searching, transforming, sorting, iterating, and common patterns. Searchable, with examples.
🌊
Tailwind CSS Reference
Complete Tailwind CSS reference — layout, spacing, typography, colors, responsive design, states, and common patterns. Searchable, with examples.
GraphQL Reference
Complete GraphQL reference — schema definition, types, queries, mutations, directives, fragments, and common patterns. Searchable, with examples.
💻
VS Code Shortcuts
Complete VS Code keyboard shortcuts — editing, navigation, search, multi-cursor, terminal, debug, and more. Searchable, with Cmd/Ctrl notation.
🔲
CSS Grid Reference
Complete CSS Grid reference — container properties, item placement, grid functions, and common layout patterns. Searchable, with examples.
📦
CSS Flexbox Reference
Complete CSS Flexbox reference — container properties, item properties, and common layout patterns. Searchable, with examples.
⚛️
React Hooks Reference
Complete React Hooks reference — useState, useEffect, useContext, custom hooks, and common patterns. Searchable, with examples.
🔷
TypeScript Reference
Complete TypeScript reference — types, interfaces, generics, utility types, and advanced patterns. Searchable, with examples.
☁️
AWS CLI Reference
Complete AWS CLI reference — EC2, S3, IAM, Lambda, ECS, RDS, CloudFormation, and common operations.
🐹
Go Reference
Complete Go (Golang) reference — syntax, types, functions, concurrency, error handling, and common patterns.
💠
PowerShell Reference
Complete PowerShell reference — cmdlets, pipelines, scripting, file operations, remote management, and Active Directory.
💾
Redis Commands
Complete Redis command reference — strings, hashes, lists, sets, sorted sets, pub/sub, transactions, and server management.
🏗️
Terraform Commands
Complete Terraform reference — init, plan, apply, state management, modules, workspaces, and HCL syntax.
⚙️
Ansible Commands
Complete Ansible reference — playbooks, modules, inventory, roles, vault, and ad-hoc commands.
🟨
JavaScript
Complete JavaScript reference — variables, types, operators, strings, arrays, objects, functions, async, DOM, ES6+, and more.
🎨
CSS
Complete CSS reference — selectors, box model, positioning, typography, animations, media queries, custom properties, and more.
📄
HTML
Complete HTML reference — document structure, text content, forms, media, semantic elements, accessibility, and more.
Java
Complete Java reference — data types, strings, collections, OOP, interfaces, exceptions, file I/O, streams, lambdas, and more.
💻
Bash
Complete Bash reference — variables, strings, arrays, conditionals, loops, functions, file tests, I/O redirection, process management, and more.
🦀
Rust
Comprehensive Rust language cheat sheet covering ownership, traits, pattern matching, concurrency, and more.
📝
Markdown
Complete Markdown syntax reference for headings, formatting, links, tables, code blocks, and extensions.
📋
YAML
YAML syntax reference covering scalars, collections, anchors, multi-line strings, and common patterns.
🌐
Curl
Curl command-line reference for HTTP requests, authentication, file transfers, debugging, and common API patterns.
Cron
Cron scheduling reference covering syntax, field values, crontab management, and common schedule patterns.
🖥️
Tmux
Terminal multiplexer for managing multiple sessions, windows, and panes from a single terminal.
🔧
Awk
Powerful text processing language for pattern scanning, data extraction, and report generation.
✂️
Sed
Stream editor for filtering and transforming text, line by line.
🔍
Find
Search for files and directories in a directory hierarchy with powerful filtering options.
🔎
Grep
Search text using patterns. Filter lines from files, command output, or streams with regular expressions.
🐘
PHP
Complete PHP cheat sheet covering syntax, OOP, arrays, PDO, and modern PHP 8.x features.
⚙️
C
Complete C programming cheat sheet covering syntax, pointers, memory management, and standard library.
🔷
C++
Complete C++ cheat sheet covering STL containers, OOP, templates, smart pointers, and modern C++ features.
🐬
MySQL
Complete MySQL cheat sheet covering queries, joins, indexes, transactions, and administration.
💅
Sass
Complete Sass/SCSS cheat sheet covering variables, mixins, functions, nesting, and modern module system.
🔐
Chmod
Linux file permission commands and patterns for chmod.
🔢
NumPy
Essential NumPy commands for array manipulation and numerical computing in Python.
🐼
Pandas
Pandas cheat sheet for data manipulation, analysis, and transformation in Python.
🎯
Dart
Dart language cheat sheet covering syntax, types, OOP, null safety, and async patterns.
🔺
Laravel
Laravel PHP framework cheat sheet for routing, Eloquent, Blade, Artisan, and more.
🟩
Node.js
Comprehensive Node.js runtime reference covering modules, file system, HTTP, streams, and more.
Next.js
Next.js App Router reference covering routing, data fetching, server components, and deployment.
🍃
MongoDB
MongoDB reference covering CRUD operations, aggregation, indexes, and administration.
🔥
Firebase
Firebase reference covering Authentication, Firestore, Realtime Database, Cloud Functions, and Hosting.
🐳
Docker Compose
Docker Compose reference covering CLI commands, service configuration, networking, volumes, and more.
💲
jQuery
Quick reference for jQuery selectors, DOM manipulation, events, AJAX, and more.
📐
LaTeX
Quick reference for LaTeX document structure, math mode, formatting, and common packages.
🎯
XPath
Quick reference for XPath expressions, axes, predicates, and functions for XML/HTML querying.
Emmet
Quick reference for Emmet abbreviations for lightning-fast HTML and CSS coding.
📦
TOML
Quick reference for TOML configuration file syntax, types, tables, and common patterns.
💎
Prisma
Complete Prisma ORM cheat sheet — schema, queries, migrations, and CLI.
🤖
GitHub Actions
Complete GitHub Actions cheat sheet — workflows, triggers, jobs, and CI/CD patterns.
📦
npm
Complete npm cheat sheet — package management, scripts, publishing, and configuration.
Supabase
Complete Supabase cheat sheet — auth, database, realtime, storage, and edge functions.
🪶
Apache
Complete Apache HTTP Server cheat sheet — virtual hosts, modules, rewrite rules, and SSL.
📡
HTTP Status Codes
Complete reference of all standard HTTP response status codes with descriptions and use cases.
🔤
ASCII Table
Complete ASCII character reference with decimal, hexadecimal, and character values.
🔧
Chrome DevTools
Essential Chrome DevTools shortcuts, commands, and workflows for web developers.
💧
Drizzle ORM
Complete Drizzle ORM reference for schema definition, queries, relations, migrations, and common patterns.
Vercel CLI
Complete Vercel CLI reference for deployment, project management, domains, environment variables, and configuration.
🔄
PM2
Production process manager for Node.js applications with built-in load balancer, monitoring, and zero-downtime reloads.
📺
Screen
GNU Screen terminal multiplexer for persistent sessions, window management, and remote work.
📦
Webpack
Module bundler for JavaScript applications — loaders, plugins, code splitting, optimization, and dev server.
Vite
Next-generation frontend build tool with instant HMR, native ES modules, and optimized production builds via Rollup.

📖 Free, searchable command reference. Bookmark this page for quick access.