forked from esp0xdeadbeef/cheat.sheets
-
Notifications
You must be signed in to change notification settings - Fork 5
/
kubernetes.cheat
85 lines (55 loc) · 2.32 KB
/
kubernetes.cheat
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% kubectl cheats
# get node info
kubectl get nodes -o wide
## echo Y3VybCBodHRwczovL2JhbHRvY2RuLmNvbS9oZWxtL3NpZ25pbmcuYXNjIHwgc3VkbyBhcHQta2V5IGFkZCAtCnN1ZG8gYXB0LWdldCBpbnN0YWxsIGFwdC10cmFuc3BvcnQtaHR0cHMgLS15ZXMKZWNobyAiZGViIGh0dHBzOi8vYmFsdG9jZG4uY29tL2hlbG0vc3RhYmxlL2RlYmlhbi8gYWxsIG1haW4iIHwgc3VkbyB0ZWUgL2V0Yy9hcHQvc291cmNlcy5saXN0LmQvaGVsbS1zdGFibGUtZGViaWFuLmxpc3QKc3VkbyBhcHQtZ2V0IHVwZGF0ZQpzdWRvIGFwdC1nZXQgaW5zdGFsbCBoZWxtCg== | base64 -d | sh
# download helm3 (debian) multiline download
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
# disable node spawning on master(s)
kubectl get nodes -o wide | grep master | cut -d ' ' -f 1 | xargs -I {} kubectl taint nodes {} node-role.kubernetes.io/master=:NoSchedule
# Print all contexts
kubectl config get-contexts
# Print current context of kubeconfig
kubectl config current-context
# Set context of kubeconfig
kubectl config use-context <context>
# Print resource documentation
kubectl explain <resource>
# Get nodes (add option '-o wide' for details)
kubectl get nodes
# Get namespaces
kubectl get namespaces
# Get pods from namespace (add option '-o wide' for details)
kubectl get pods -n <namespace>
# Get pods from all namespace (add option '-o wide' for details)
kubectl get pods --all-namespaces
# Get services from namespace
kubectl get services -n <namespace>
# Get details from resource on namespace
kubectl describe <resource>/<name> -n <namespace>
# Print logs from namespace
kubectl logs -f pods/<name> -n <namespace>
# Get deployments
kubectl get deployments -n <namespace>
# Edit deployments
kubectl edit deployment/<name> -n <namespace>
# Drain node in preparation for maintenance
kubectl drain <name>
# Mark node as schedulable
kubectl uncordon <name>
# Mark node as unschedulable
kubectl cordon <name>
# Display resource (cpu/memory/storage) usage
kubectl top <type>
# List the namespaces in the current context
kubens
# Change the active namespace of current context
kubens <namespaces>
# Switch to the previous namespace in this context
kubens -
# Show the current namespace
kubens -c
$ namespaces: kubens --- --headers 1 --column 3