Connection
kubectl config use-context [context-name]
Switch to a specific Kubernetes cluster context
kubectl config current-context
Check the current context you're connected to
kubectl config get-contexts
List all available contexts
kubectl cluster-info
Display cluster connection information
Pod Health Checking
kubectl get pods
List all pods in the current namespace
kubectl get pods -A
List pods across all namespaces
kubectl describe pod [pod-name]
Show detailed information about a specific pod
kubectl logs [pod-name]
View logs for a pod
kubectl logs [pod-name] -c [container-name]
View logs for a specific container in a pod
Resource Monitoring
kubectl top pods
Display CPU/Memory usage of pods
kubectl top nodes
Display CPU/Memory usage of nodes
kubectl get events
List events in the current namespace
kubectl get events --sort-by=.metadata.creationTimestamp
List events sorted by creation time
Health and Readiness Probes
kubectl get pod [pod-name] -o jsonpath='{.spec.containers[*].livenessProbe}'
Check liveness probe configuration
kubectl get pod [pod-name] -o jsonpath='{.spec.containers[*].readinessProbe}'
Check readiness probe configuration
kubectl get pod [pod-name] -o jsonpath='{.spec.containers[*].startupProbe}'
Check startup probe configuration
Debugging
kubectl exec -it [pod-name] -- sh
Open a shell inside a pod
kubectl port-forward [pod-name] [local-port]:[pod-port]
Forward a local port to a port on the pod
kubectl debug [pod-name] --image=busybox --target=[container-name]
Create a debugging container in a running pod