-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubernetes-cheatsheet.txt
119 lines (81 loc) · 2.81 KB
/
kubernetes-cheatsheet.txt
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
-----------------------
Kubernetes
-----------------------
- Notes:
- Object Types
- Pods
- Deployments
- Services
- ClusterIP
- NodePort
- Only for development
- LoadBalancer
- Ingress
- Secrets
- kubectl
- Check version
kubectl version
- Cluster Info
kubectl cluster-info
- Namespace:
https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-organizing-with-namespaces
Create:
kubectl create namespace <namespace>
Switch namespace:
kubectl config set-context --current --namespace=<namespace>
kubectl config set-context --current --namespace=default
Delete:
kubectl delete namespace <namespace>
- Apply Objectinto K8s
Generically provide k8s responsibilities
kubectl apply -f <configfile.yaml> [--namespace=<namespace>]
kubectl apply -f <directory> [--namespace=<namespace>]
- List object status
kubectl get pods|services
kubectl get pods -o wide
- List machines/nodes in k8s cluster
kubectl get node
- List docker status
kubectl get po -A
- Check objects
kubectl describe <object_type> <name>
- Delete object
kubectl delete -f <configfile.yaml>
- Delete deployment and services:
kubectl delete deployment <name>
kubectl delete service <name>
- Delete all object at once
kubectl delete all --all
kubectl delete all --all -n <namespace>
Or create/delete everything under a namespace
kubectl delete namespace <namespace>
kubectl create namespace <namespace>
- Logs
kubectl logs <pod_name>
- Shh
kubectl exec -it <pod_name> bash
- Imperative Commands
- Update container image
kubectl set image <object_type>/<object_name> <container_name>=<image_name>
kubectl set image deployment/client-deployment client=gagan144/udemy_complex_client:1.0.6
- Get storage
kubectl get storageclass
kubectl describe storageclass
- List persistent volumes claims
kubectl get pvc
- List persistent volumes
kubectl get pv
- Get PV details (Path on HHD)
kubectl describe pv <name>
- Create secret:
kubectl create secret <secret_type:generic|docker-reg|tls> <name> --from-literal <key>=<value>
- List secrets
kubectl get secrets
kubectl get secret -n <namespace>
- Ingress
- Get ingress pods
kubectl get pods -n ingress-nginx
- Get ingress services:
kubectl get services -n ingress-nginx
- Describe
kubectl describe ingress ingress-service