Connection
kubectl config use-context
Switch to a specific Kubernetes context
kubectl config get-contexts
List available contexts
kubectl config current-context
Show current active context
kubectl cluster-info
Display cluster information
Pod Operations
kubectl get pods
List all pods in the current namespace
kubectl get pods -n
List pods in a specific namespace
kubectl get pods --all-namespaces
List pods across all namespaces
kubectl describe pod
Show detailed information about a pod
kubectl logs
Show logs for a pod
kubectl logs -c
Show logs for a specific container in a pod
kubectl exec -it --
Execute a command in a pod's container
Resource Management
kubectl get
List resources (nodes, deployments, services, etc.)
kubectl describe
Show detailed information about a resource
kubectl get events
Show events in the current namespace
kubectl top pod
Show CPU/Memory usage of pods
kubectl top node
Show CPU/Memory usage of nodes
Deployment Operations
kubectl get deployments
List all deployments
kubectl rollout status deployment/
Check deployment rollout status
kubectl rollout history deployment/
View rollout history
kubectl rollout undo deployment/
Rollback to previous deployment version
Configuration & Settings
kubectl get configmaps
List all ConfigMaps
kubectl get secrets
List all Secrets
kubectl get namespaces
List all namespaces
Troubleshooting
kubectl get componentstatuses
Check components health
kubectl get nodes
Check node status
kubectl debug -it --image=busybox
Debug a pod with a temporary container
kubectl port-forward :
Forward port from pod to local machine
Resource Creation/Editing
kubectl apply -f
Create/update resources from a YAML file
kubectl edit
Edit a resource directly
kubectl delete
Delete a resource