-
Notifications
You must be signed in to change notification settings - Fork 13
/
cheat-sheet
56 lines (48 loc) · 1.46 KB
/
cheat-sheet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#Install kubectl in any node and have the kubeconfig set so that kubectl can access the cluster API
Nodes
kubectl get nodes
kubectl get nodes --show-labels
Namespaces and Pods
kubectl get pods --all-namespaces -o wide
kubectl get pods -n <namespace>
#Get the pods detail in json
kubectl get pods -o=jsonpath="{.items[*]['metadata.name','metada.namespace']}"
#Start a nginx pod
kubectl run nginx --image=nginx --restart=Never -n <ns>
kubectl describe pod <podname>
kubectl get ns
#Change an image of the nginx pod on the fly
kubectl set image pod/nginx nginx=1.17.4
#watch the pod
kubectl get pod nginx -w
#Exec into a pod
kubectl exec -it <pod> sh
#Run a busybox pod with a command
kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c "sleep 3600"
#Get pod logs
kubectl pod logs <podname>
#List all pods with a label
kubectl get pods --show-labels
# Scale
kubectl scale deploy <deploymentname> --replicas=20
#Rollout status
kubectl rollout status deploy <deployment>
kubectl rollout history deploy <deployment>
#Autoscale
kubectl autoscale deploy <deployment> --min=2 --max=5 --cpu-percent=85
kubectl get hpa
#Services
kubectl get svc -n <ns>
#Endpoints
kubectl get ep --all-namepaces
#Admin Stuff
kubectl cordon <node>
kubectl uncordon <node>
#Taint nodes
kubectl taint nodes <node1> <node2> key=value:NoSchedule
#Untaint the node
kubectl taint nodes <node> key:NoSchedule-
#Label Nodes
kubectl label node <nodename> key=value
#Remove label
kubectl label node <nodename> key-