Kubernetes (kubectl) Cheat Sheet
A quick reference for common `kubectl` commands to manage your Kubernetes cluster.
| Command | Description |
|---|---|
kubectl cluster-info | Display information about the master and services in the cluster. |
kubectl version | Display the Kubernetes version running on the client and server. |
kubectl get nodes | List all nodes in the cluster. |
| Command | Description |
|---|---|
kubectl get pods | List all pods in the current namespace. |
kubectl get pods -n [namespace] | List all pods in a specific namespace. |
kubectl get pods -o wide | List all pods with more details (e.g., node name). |
kubectl get deployments | List all deployments. |
kubectl get services | List all services. |
kubectl describe pod [pod-name] | Show detailed information about a specific pod. |
| Command | Description |
|---|---|
kubectl create -f [file.yaml] | Create a resource from a YAML file. |
kubectl delete pod [pod-name] | Delete a pod. |
kubectl exec -it [pod-name] -- /bin/sh | Get a shell to a running container. |
kubectl logs [pod-name] | Print the logs for a pod. |
kubectl logs -f [pod-name] | Stream the logs for a pod. |