Cheatography
https://cheatography.com
kubernetes command cheat sheet
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Contexts
kubectl config get-contexts |
Show contexts |
kubectl config current-context |
Show current context |
kubectl config use-context <my-cluster-name> |
Switch contet to another cluster |
kubectl config set-context --current --namespace=<namespace> |
Change namespace |
|
|
Logs
kubectl logs <pod> |
Show logs (stdout) of a pod |
kubectl logs -l <label>=<value> |
Show logs (stdout) of pods that match a label |
kubectl logs <pod> --previous |
Show logs of a previous instantiation of a container |
kubectl logs <pod> -c <container> |
Show logs for a specific container in a pod (i.e. init container) |
kubectl logs -f <pod> |
Following logs from a pod |
kubectl logs -f -l <label>=<value> --all-containers |
Follow all logs from a pod that match a label |
kubectl logs <pod> --v=<0:9> |
Show logs with verbosity level of logs from 0 - 9 |
Services
kubectl get services |
Get all services in the current namespace |
kubectl get service --all-namespaces |
Get services in all namespaces |
kubectl get service -o wide |
Get services with more details |
kubectl get service <service> -o yaml |
Get the yaml for a services |
kubectl describe service <service> |
Inspect a service |
kubectl get service --show-labels |
Get service's labels |
kubectl get service -l <label>=<value> |
Get services that match a labels |
|