Kubernetes Cheat Sheet (Kubectl)
Basic Pod Management:
kubectl get pods
: List all podskubectl describe pod <pod_name>
: View details of a podkubectl delete pod <pod_name>
: Delete a podkubectl run <pod_name> --image=<image>
: Create a simple pod from an image
Viewing Resources:
kubectl get nodes
: List all nodes in the clusterkubectl get deployments
: List all deploymentskubectl get services
: List all services
Logs:
kubectl logs <pod_name>
: View logs of a running pod
Advanced:
kubectl exec -it <pod_name> bash
: Get an interactive shell in a podkubectl apply -f <yaml_file>
: Apply configurations from a YAML file
Remember: <pod_name>
, <image>
, and <yaml_file>
are placeholders for your specific names.
Bonus:
kubectl port-forward <pod_name> <local_port>:<container_port>
: Forward a port from your machine to a podkubectl get events
: View recent events in the clusterkubectl top pods
: View resource usage of pods