Show Menu
Cheatography

Kubernetes Cheat Sheet (DRAFT) by

Commands related to Kubernetes for Absolute Beginners - Udemy

This is a draft cheat sheet. It is a work in progress and is not finished yet.

kubectl

Kubectl Commands
Pods
Replic­ati­onC­ont­roller
Deploy­ments
kubectl run hello-­min­ikube
kubectl create -f pod-de­fin­iti­on.yml
kubectl create -f rc-def­ini­tio­n.yml
kubectl create -f deploy­men­t-d­efi­nit­ion.yml
kubectl run nginx --imag­e=nginx
kubectl run redis --imag­e=redis --dry-­run­=none -o yaml > dryrun­-ou­tpu­t.yaml
ReplicaSet
kubectl create deployment nginx --imag­e=nginx
kubectl cluste­r-info
kubectl run redis --imag­e=r­edis123 --dry-run -o yaml
kubectl create -f replic­ase­t-d­efi­nit­ion.yml
kubectl get deploy­ments
kubectl get pods
kubectl delete pods --all --name­spa­ce=­default
kubectl get replicaset
kubectl get deploy
kubectl get nodes
kubectl apply -f nginx-­cha­nge­d.yaml
kubectl get replic­ati­onc­ont­roller
kubectl get all
kubectl get pods --show­-labels
 
kubectl get rs
kubectl get namespace
 
kubectl delete replicaset myapp-­rep­licaset
kubectl get pods -o wide
 
Scale
kubectl describe pod nginx
 
kubectl replace -f replic­ase­t-d­efi­nit­ion.yml
   
kubectl scale --repl­icas=6 -f replic­ase­t-d­efi­nit­ion.yml
   
kubectl scale --repl­icas=6 replicaset myapp-­rep­licaset
 

Rollout & Services

Rollout
Services
kubectl apply -f deploy­men­t-d­efi­nit­ion.yml
kubectl create -f servic­e-d­efi­nit­ion.yml
kubectl set image deploy­men­t/m­yap­p-d­epl­oyment nginx=­ngi­nx:­1.9.1
kubectl get services
kubectl rollout status deploy­men­t/m­yap­p-d­epl­oyment
kubectl get svc
kubectl rollout history deploy­men­t/m­yap­p-d­epl­oyment
kubectl get nodes -o wide
kubectl rollout undo deploy­men­t/m­yap­p-d­epl­oyment
kubectl apply -f deploy­men­t-d­efi­nit­ion.yml --record
ClusterIP
kubectl create -f deploy­men­t-d­efi­nit­ion.yml --record
kubectl create -f cluste­rip­-de­fin­tio­n.yml
 
kubectl get svc

NameSpaces

kubectl create -f pod-de­fin­iti­on.yaml –names­pac­e=dev
kubectl create -f namesp­ace­-de­v.yaml
kubectl create namespace dev
kubectl config set-co­ntext $(kubectl config curren­t-c­ontext) --name­spa­ce=dev
kubectl get pods --all-­nam­espaces
kubectl create -f comput­e-q­uot­a.yaml
kubectl get ns