0% found this document useful (0 votes)
59 views2 pages

Kubernetes Cheat Sheet

Uploaded by

Joselito Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

Kubernetes Cheat Sheet

Uploaded by

Joselito Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Kubernetes Cheat Dep loy m ent s

$ kubectl get deploy


ReplicaSets
$ kubectl get rs

Sheet $ kubectl describe deploy


$ kubectl get deploy -o wide
$ kubectl describe rs
$ kubectl get rs -o wide
$ kubectl get deploy -o yaml $ kubectl get rs -o yaml

What is Kubernetes?
Kubernetes is a platform for managing containerized Services Roles
workloads. Kubernetes orchestrates computing, $ kubectl get svc $ kubectl get roles --al $
networking and storage to provide a seamless portability l -namespaces
$ kubectl describe svc kubectl get roles --al
across infrastructure providers. l-namespaces -o yaml
$ kubectl get svc -o wide
$ kubectl get svc -o yaml
Secrets
$ kubectl get svc --show-labels
Viewing Resource Information $ kubectl get secrets $ kubectl get secrets --
all-namespaces $ kubectl get secrets -o yaml
Nodes
$ kubectl get no DaemonSets ConfigMaps
$ kubectl get no -o wide $ kubectl get ds $ kubectl get cm $ kubectl get cm --al $
$ kubectl describe no $ kubectl get ds --all-namespaces kubectl get cm --al
$ kubectl get no -o yaml $ kubectl describe ds [daemonset_name] -n
[ namespace_name]
$ kubectl get node --selector=[label_name]
$ kubectl get ds [ds_name] -n [ns_name] -o l -namespaces
$ kubectl get nodes -o
j sonpat h=' {. i t ems[ *] . st at us. addresses yaml l-namespaces -o yaml
[ ?(@. t ype=="Ext ernal I P")] . address}'
$ kubectl top node [node_name] Events Ing re s s
$ kubectl get ing
Pods $ kubectl get events
$ kubectl get ing --al
$ kubectl get po $ kubectl get events -n kube-system l -namespaces
$ kubectl get po -o wide $ kubectl get events -w
$ kubectl describe po PersistentVolume
$ kubectl get po --show-labels $ kubectl get pv
Logs
$ kubectl get po -l app=nginx $ kubectl describe pv
$ kubectl logs [pod_name]
$ kubectl get po -o yaml
$ kubectl logs --since=1h [pod_name]
$ kubectl get pod [pod_name] -o yaml
--export
$ kubectl logs --tail=20 [pod_name] PersistentVolumeClaim
$ kubectl get pod [pod_name] -o yaml $ kubectl logs -f -c [container_name] $ kubectl get pvc
[ pod_name]
--export > nameoffile.yaml $ kubectl describe pvc
$ kubectl logs [pod_name] > pod.log
$ kubectl get pods --field-selector
st at us. phase=Runni ng Service Accounts
Nam esp ac es $ kubectl get sa
$ kubectl get ns $ kubectl get sa -o yaml
$ kubectl get ns -o yaml $ kubectl get serviceaccounts default -o
$ kubectl describe ns yaml > ./sa.yaml
$ kubectl replace serviceaccount default -f
. / sa. yaml
Kubernetes Cheat Dep loy m ent s/ Nam esp ac es
$ kubectl edit deploy [deploy_name] $ kubectl
Creating a Deployment
$ kubectl create -f [name_of_file] $ kubectl apply -f

Sheet delete deploy [deploy_name] $ kubectl expose


deploy [deploy_name]
[name_of_file] $ kubectl create deploy
[deploy_name]
--port=80 --type=NodePort --i mage=ngi nx
$ kubectl scale deploy [deploy_name]
Viewing Resource Information --repl i cas=5 Interactive Pod
$ kubectl delete ns
(cont.) $ kubectl run [pod_name] --image=busybox --rm -it --
$ kubectl edit ns [ns_name] restart=Never -- sh
StorageClass Output YAML to a File
$ kubectl get sc $ kubectl get sc -o yaml $ kubectl create deploy [deploy_name] --image=nginx --dry-
Services run -o yaml > depl oy. yaml
Multiple Resources $ kubectl edit svc [svc_name] $ kubectl delete svc
$ kubectl get svc, po $ kubectl get deploy, no $ $ kubectl get po [pod_name] -o yaml --export
[svc_name] > pod.yaml
kubectl get all $ kubectl get all --all-namespaces
DaemonSets
$ kubectl edit ds [ds_name] -n kube-system $ kubectl
delete ds [ds_name]
Service Accounts Getting Help
$ kubectl edit sa [sa_name] $ kubectl delete sa [sa_name] $ kubectl -h $ kubectl create -h $
kubectl run -h $ kubectl explain
Anno t at e
deploy.spec
Changing Resource Attributes $ kubectl annotate po [pod_name] [ annot at i on]
Taint $ kubectl annotate no [node_name]
$ kubectl taint [node_name] [taint_name]
Labels
$ kubectl label [node_name] disktype=ssd $ kubrectl
Requests
label [pod_name] env=prod API Call
$ kubectl get --raw /apis/metrics.k8s.io/

Adding Resources
Cordon/Uncordon Cluster Info
$ kubectl cordon [node_name] $ kubectl
Creating a Pod $ kubectl config $ kubectl cluster-info
$ kubectl create -f [name_of_file] $ kubectl apply -f
uncordon [node_name] $ kubectl get componentstatuses
[name_of_file] $ kubectl run [pod_name] --
Dra in image=nginx
--rest art =Never
$ kubectl drain [node_name]
$ kubectl run [pod_name]
--generator=run-pod/v1 --image=nginx
$ kubectl run [pod_name] --image=nginx
Nodes/Pods --rest art =Never
$ kubectl delete node [node_name] $ Creating a Service
kubectl delete pod [pod_name] $ kubectl $ kubectl create svc nodeport [svc_name] --t cp=8080:
edit node [node_name] $ kubectl edit pod 80
[pod_name]

You might also like