Show Menu
Cheatography

Kubectl Cheat Sheet Cheat Sheet (DRAFT) by

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 deploy­ments
Get a list of the deploy­ments deployed to the default namespace
kubectl logs <po­d-i­d>
Gets the latest logs from a pod with the specific id in the default namespace, obtained from kubectl get pods
kubectl edit deployment <de­plo­yme­nt-­id>
Opens a text editor with the YAML config from the deployment in the default namespace
kubectl describe pod <po­d-i­d>
Displays detailed inform­ation about the pod with the specific id in the default namespace
kubectl get pods <po­d-i­d>
Displays an overview of a specific pod in the default namespace
 

Advanced commands

kubectl config curren­t-c­ontext
Get the currently selected cluster from the kube.c­onfig file on your pc
kubectl config use-co­ntext <cl­ust­ern­ame>
Change selection to the cluster you want to manage from the kube.c­onfig file on your pc

Namespace

kubectl get namespaces
Get namespaces
kubectl create namespace <na­mes­pac­e-n­ame>
Create namespace
kubectl delete namespace <na­mes­pac­e-n­ame>
Delete namespace

Service

kubectl get services
Get services
kubectl describe service <se­rvi­ce-­id>
Invest­igate service
kubectl delete service <se­rvi­ce-­id>
Delete service

Resource types - short names

Short name
Full name
po
pods
deploy
deploy­ments
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 <po­d-i­d>
Invest­igate pod
kubectl delete pod <po­d-i­d>
Delete pod based on id
kubectl logs <po­d-i­d>
Gets logs for a pod

Deployment

kubectl get deploy­ments
Get deploy­ments
kubectl describe deployment <de­plo­yme­nt-­id>
Invest­igate deployment
kubectl delete deployment <de­plo­yme­nt-­id>
Delete deployment