Cheatography
https://cheatography.com
Cheat sheet for the difficult-to-remember kubectl commands for Kubernetes.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Common commands
kubectl get pods |
Get a list of the pods running in the default namespace |
kubectl get deployments |
Get a list of the deployments deployed to the default namespace |
kubectl logs <pod-id> |
Gets the latest logs from a pod with the specific id in the default namespace, obtained from kubectl get pods |
kubectl edit deployment <deployment-id> |
Opens a text editor with the YAML config from the deployment in the default namespace |
kubectl describe pod <pod-id> |
Displays detailed information about the pod with the specific id in the default namespace |
kubectl get pods <pod-id> |
Displays an overview of a specific pod in the default namespace |
|
|
Advanced commands
kubectl config current-context |
Get the currently selected cluster from the kube.config file on your pc |
kubectl config use-context <clustername> |
Change selection to the cluster you want to manage from the kube.config file on your pc |
Namespace
kubectl get namespaces |
Get namespaces |
kubectl create namespace <namespace-name> |
Create namespace |
kubectl delete namespace <namespace-name> |
Delete namespace |
Service
kubectl get services |
Get services |
kubectl describe service <service-id> |
Investigate service |
kubectl delete service <service-id> |
Delete service |
Resource types - short names
Short name |
Full name |
po |
pods |
deploy |
deployments |
svc |
services |
no |
nodes |
rs |
replicaset |
ds |
daemonsets |
System
kubectl get nodes |
Get system and user nodes |
kubectl top nodes |
Gets pod resource usage |
Pod
kubectl get pods |
List pods |
kubectl describe pod <pod-id> |
Investigate pod |
kubectl delete pod <pod-id> |
Delete pod based on id |
kubectl logs <pod-id> |
Gets logs for a pod |
Deployment
kubectl get deployments |
Get deployments |
kubectl describe deployment <deployment-id> |
Investigate deployment |
kubectl delete deployment <deployment-id> |
Delete deployment |
|