321 lines
14 KiB
Plaintext
321 lines
14 KiB
Plaintext
1 sudo apt install -y vim git
|
|
2 git clone https://github.com/sandervanvugt/cka
|
|
3 cd cka
|
|
4 ls *sh
|
|
5 ./setup-container.sh
|
|
6 systemctl status containerd
|
|
7 vim setup-container.sh
|
|
8 cd /etc/sysctl.d/
|
|
9 ls
|
|
10 cat 99-kubernetes-cri.conf
|
|
11 cd
|
|
12 cd cka
|
|
13 ls *
|
|
14 ls *sh
|
|
15 ./setup-kubetools-previousversion.sh
|
|
16 sudo kubeadm init -h | less
|
|
17 sudo kubeadm init
|
|
18 mkdir -p $HOME/.kube
|
|
19 less ~/.kube/config
|
|
20 kubectl get all
|
|
21 ls
|
|
22 less RESOURCES.txt
|
|
23 kubectl config view
|
|
24 kubectl get pods -n kube-system
|
|
25 kubectl describe -n kube-system pod coredns-674b8bbfcf-fbkd8
|
|
26 history
|
|
27 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
|
|
28 kubectl api-resources | less
|
|
29 kubectl get pods -n kube-system
|
|
30 history
|
|
31 kubectl get nodes
|
|
32 kubectl create deploy testdploy --image=nginx --replicas=3
|
|
33 kubectl get all
|
|
34 sudo kubeadm config print init-defaults > config.yaml
|
|
35 vim config.yaml
|
|
36 source <(kubectl completion bash)
|
|
37 kubectl get pods -n kube-system
|
|
38 kubectl edit node control
|
|
39 kubectl create deploy removeme --image=nginx --replicas=20
|
|
40 kubectl get all
|
|
41 kubectl get pods -o wide
|
|
42 kubectl edit node control
|
|
43 kubectl get pods -o wide
|
|
44 kubectl scale deploy removeme --replicas=1
|
|
45 kubectl scale deploy removeme --replicas=20
|
|
46 kubectl get pods -o wide
|
|
47 kubectl delete deploy removeme
|
|
48 history | grep create
|
|
49 kubectl get all
|
|
50 kubectl edit deploy testdploy
|
|
51 kubectl get pods -o wide
|
|
52 kubectl expose deploy testdploy
|
|
53 kubectl expose deploy testdploy --port 80
|
|
54 kubectl get all
|
|
55 curl 10.104.105.141
|
|
56 kubectl get all
|
|
57 kubectl edit svc testdploy
|
|
58 kubectl get all
|
|
59 history
|
|
60 kubectl set resources -h | less
|
|
61 kubectl get deploy
|
|
62 kubectl set resources deploy testdploy --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
|
|
63 source <(kubectl completion bash)
|
|
64 kubectl edit deploy testdploy
|
|
65 kubectl create ns limited
|
|
66 kubectl create quota -h | less
|
|
67 kubectl create quota qtest --hard pods=3,cpu=100m,memory=500Mi --namespace limited
|
|
68 kubectl describe quota -n limited
|
|
69 kubectl describe quota
|
|
70 kubectl describe ns limited
|
|
71 kubectl create deploy nginx --image=nginx --replicas=3 -n limited
|
|
72 kubectl get all -n limited
|
|
73 kubectl describe -n limited rs nginx-5869d7778c
|
|
74 history
|
|
75 kubectl set resources -n limited deploy nginx --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi
|
|
76 kubectl get pods -n limited
|
|
77 kubectl get all -n limited
|
|
78 kubectl describe ns limited
|
|
79 kubectl edit -n limited quota qtest
|
|
80 kubectl get all -n limited
|
|
81 kubectl -n limited scale deploy nginx --replicas=1
|
|
82 kubectl -n limited scale deploy nginx --replicas=3
|
|
83 kubectl get all -n limited
|
|
84 vim limitrange.yaml
|
|
85 kubectl apply -f limitrange.yaml
|
|
86 kubectl describe ns limited
|
|
87 cat limitrange.yaml
|
|
88 kubectl describe ns default
|
|
89 kubectl delete -f limitrange.yaml
|
|
90 kubectl apply -f limitrange.yaml -n limited
|
|
91 kubectl describe ns limited
|
|
92 kubectl run limitpod --image=nginx -n limited
|
|
93 kubectl delete quota -n limited qtest
|
|
94 kubectl run limitpod --image=nginx -n limited
|
|
95 kubectl describe pod -n limited limitpod
|
|
96 history
|
|
97 kubectl create priorityclass high-priority --value=1000 --description="high priority" --preemption-policy="Never"
|
|
98 kubectl create priorityclass high-priority --value=125 --description="mid priority" --global-default=true
|
|
99 kubectl create priorityclass mid-priority --value=125 --description="mid priority" --global-default=true
|
|
100 kubectl run testpod --image=nginx
|
|
101 kubectl get testpod -o yaml | grep -B2 -i priority
|
|
102 kubectl get pod testpod -o yaml | grep -B2 -i priority
|
|
103 kubectl create deploy highprio --image=nginx
|
|
104 kubectl edit deploy highprio
|
|
105 kubectl get all --selector app=highprio
|
|
106 kubectl get pods highprio-57ccd94998-ddjjl -o yaml | grep prio
|
|
107 history
|
|
108 kubectl create quota -h | less
|
|
109 kubectl run -h | less
|
|
110 kubectl run busypod --image=busybox -- sleep 3600
|
|
111 kubectl get pods
|
|
112 kubectl get pod busypod -o yaml | less
|
|
113 kubectl get ds -A
|
|
114 kubectl get nodes
|
|
115 kubectl cordon worker1
|
|
116 kubectl create deploy many --image=nginx --replicas=10
|
|
117 kubectl get pods -o wide
|
|
118 kubectl uncordon worker1
|
|
119 kubectl get pods -o wide
|
|
120 kubectl scale deploy many --replicas=4
|
|
121 kubectl scale deploy many --replicas=10
|
|
122 kubectl get pods -o wide
|
|
123 kubectl delete deploy many
|
|
124 history > /tmp/oct25.txt
|
|
125 cd
|
|
126 arch
|
|
127 kubectl cordon worker2
|
|
128 kubectl get nodes
|
|
129 kubectl get node worker2 -o yaml | less
|
|
130 df -h
|
|
131 kubectl create deploy filledup --image=nginx --replicas=5
|
|
132 kubectl get all --selector app=filledup
|
|
133 kubectl describe pod filledup-689c9df88d-vrxrq
|
|
134 kubectl edit node worker2
|
|
135 kubectl edit node worker1
|
|
136 kubectl get pods
|
|
137 kubectl get nodes
|
|
138 kubectl uncordon worker2
|
|
139 kubectl get nodes
|
|
140 kubectl get pods -n kube-system
|
|
141 kubectl get nodes
|
|
142 helm
|
|
143 snap install helm
|
|
144 sudo snap install helm
|
|
145 sudo snap install helm --classic
|
|
146 helm version
|
|
147 helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
|
|
148 helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
|
|
149 kubectl get ns
|
|
150 kubectl get all -n kubernetes-dashboard
|
|
151 kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443
|
|
152 helm repo add bitnami https://charts.bitnami.com/bitnami
|
|
153 helm repo list
|
|
154 helm search repo bitnami
|
|
155 helm search repo file
|
|
156 helm search repo nginx --versions
|
|
157 helm install bitnami/mysql --generate-name --create-namespace --namespace bsql
|
|
158 helm show chart bitnami/mysql
|
|
159 helm list -A
|
|
160 helm status mysql-1761834656
|
|
161 helm status mysql-1761834656 -n bsql
|
|
162 kubectl -n bsql
|
|
163 kubectl get all -n bsql
|
|
164 kubectl describe pods -n bsql mysql-1761834656-0
|
|
165 helm repo list
|
|
166 helm show values bitnami/nginx
|
|
167 helm show values bitnami/nginx | grep commonLa
|
|
168 helm show values bitnami/nginx | grep replicaC
|
|
169 vim values.yaml
|
|
170 helm list
|
|
171 helm install bitnami/nginx --generate-name --values=values.yaml
|
|
172 helm list
|
|
173 kubectl get deploy
|
|
174 helm get values nginx-1761835222
|
|
175 helm get values --all nginx-1761835222
|
|
176 helm get values --all nginx-1761835222 | wc -l
|
|
177 helm repo add argo https://argoproj.github.io/argo-helm
|
|
178 helm repo update
|
|
179 helm search repo argo/argo-cd
|
|
180 helm template my-argo-cd argo/argo-cd > argo-cd-template.yaml
|
|
181 vim argo-cd-template.yaml
|
|
182 helm show values argo/argo-cd > values.yaml
|
|
183 vim values.yaml
|
|
184 helm template my-argocd argo/argo-cd -f values.yaml > argo-cd-template.yaml
|
|
185 kubectl apply -f argo-cd-template.yaml
|
|
186 kubectl get svc
|
|
187 kubectl delete -f argo-cd-template.yaml
|
|
188 kubectl get storageclass
|
|
189 cd cka
|
|
190 ls
|
|
191 vim pvc.yaml
|
|
192 kubectl apply -f pvc.yaml
|
|
193 kubectl get pvc
|
|
194 kubectl describe pvc pv-claim
|
|
195 ls pv*
|
|
196 vim pv.yaml
|
|
197 kubectl apply -f pv.yaml
|
|
198 kubectl get pvc
|
|
199 kubectl explain pvc.spec | less
|
|
200 history
|
|
201 sudo apt install nfs-server -y
|
|
202 sudo mkdir /nfsexport
|
|
203 sudo vim /etc/exports
|
|
204 sudo systemctl restart nfs-server
|
|
205 showmount -e localhost
|
|
206 sudo vim /etc/hosts
|
|
207 helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
|
|
208 helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner --set nfs.server=192.168.29.101 --set nfs.path=/nfsexport
|
|
209 kubectl get pods
|
|
210 kubectl get pv
|
|
211 vim nfs-provisioner-pvc-test.yaml
|
|
212 kubectl get storageclass
|
|
213 kubectl describe storageclass nfs-client
|
|
214 kubectl apply -f nfs-provisioner-pvc-test.yaml
|
|
215 kubectl get pvc,pv
|
|
216 kubectl describe pv pvc-f808333d-7ec1-44af-a24a-3ddf89eff2d7
|
|
217 ls /nfsexport/
|
|
218 history
|
|
219 vim another-pvc-test.yaml
|
|
220 kubectl apply -f another-pvc-test.yaml
|
|
221 kubectl get pvc
|
|
222 kubectl patch storageclass nfs-client -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
|
|
223 kubectl get pvc
|
|
224 kubectl edit sc nfs-client
|
|
225 kubectl get svc
|
|
226 kubectl get pods
|
|
227 kubectl exec -it highprio-57ccd94998-ddjjl -- cat /etc/resolv.conf
|
|
228 kubectl get svc -A
|
|
229 kubectl get svc
|
|
230 kubectl exec -it highprio-57ccd94998-ddjjl -- ping testdploy
|
|
231 kubectl get cm -n kube-system coredns -o yaml
|
|
232 kubectl get all
|
|
233 kubectl delete deploy filledup highprio nginx-1761835222 testdploy
|
|
234 kubectl run webserver --image=nginx
|
|
235 kubectl expose pod webserver --port=80
|
|
236 kubectl run testpod --image=busybox -- sleep 3600
|
|
237 kubectl run testpod2 --image=busybox -- sleep 3600
|
|
238 kubectl get svc
|
|
239 kubectl exec -it testpod -- wget webserver
|
|
240 kubectl exec -it testpod2 -- wget webserver
|
|
241 kubectl create ns remote
|
|
242 kubectl run interginx --image=nginx
|
|
243 kubectl run remotebox -n remote --image=busybox -- sleep 3600
|
|
244 kubectl expose pod interginx --port=80
|
|
245 kubectl exec -it remotebox -n remote -- cat /etc/resolv.conf
|
|
246 kubectl exec -it remotebox -n remote -- nslookup interginx
|
|
247 kubectl exec -it remotebox -n remote -- nslookup interginx.default.svc.cluster.local
|
|
248 history
|
|
249 vim nwpolicy-complete-example.yaml
|
|
250 kubectl apply -f nwpolicy-complete-example.yaml
|
|
251 kubectl expose pod nginx --port=80
|
|
252 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
|
|
253 vim nwpolicy-complete-example.yaml
|
|
254 kubectl label pod busybox access=true
|
|
255 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
|
|
256 history
|
|
257 kubectl create ns nwp-namespace
|
|
258 vim nwp-lab10-1.yaml
|
|
259 kubectl apply -f nwp-lab10-1.yaml
|
|
260 kubectl expose pod nwp-nginx --port=80
|
|
261 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
|
|
262 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
|
|
263 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
|
|
264 vim nwp-lab10-2.yaml
|
|
265 kubectl apply -f nwp-lab10-2.yaml
|
|
266 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
|
|
267 kubectl create deploy busybox --image=busybox -- sleep 3600
|
|
268 kubectl exec -it busybox-5c684d4858-pzdjl -- wget --spider --timeout=1 nwp-nginx
|
|
269 vim nwp-lab10-2.yaml
|
|
270 vim examplenwp.yaml
|
|
271 vim vm.yaml
|
|
272 vim vm.yaml
|
|
273 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
|
|
274 kubectl get deploy
|
|
275 kubectl get ns
|
|
276 kubectl get deploy -n kube-system
|
|
277 kubectl get pods -n kube-system
|
|
278 kubectl edit deployments.apps -n kube-system metrics-server
|
|
279 kubectl get pods -n kube-system
|
|
280 kubectl top pods
|
|
281 sudo apt update
|
|
282 sudo apt-cache madison kubeadm
|
|
283 pager /etc/apt/sources.list.d/kubernetes.list
|
|
284 vim /etc/apt/sources.list.d/kubernetes.list
|
|
285 sudo vim /etc/apt/sources.list.d/kubernetes.list
|
|
286 #sudo apt-mark unhold kubeadm && \
|
|
287 sudo apt-get update && sudo apt-get install -y kubeadm='1.34.x-*' && sudo apt-mark hold kubeadm
|
|
288 sudo apt-cache madison kubeadm
|
|
289 sudo apt-get update && sudo apt-get install -y kubeadm='1.34.1-1.1' && sudo apt-mark hold kubeadm
|
|
290 sudo apt-mark unhold kubeadm && sudo apt-get update && sudo apt-get install -y kubeadm='1.34.1-1.1' && sudo apt-mark hold kubeadm
|
|
291 kubeadm version
|
|
292 sudo kubeadm upgrade plan
|
|
293 sudo kubeadm upgrade apply v1.34.1
|
|
294 kubectl drain control --ignore-daemonsets
|
|
295 sudo apt-mark unhold kubelet kubectl && sudo apt-get update && sudo apt-get install -y kubelet='1.34.1-1.1' kubectl='1.34.1-1.1' && sudo apt-mark hold kubelet kubectl
|
|
296 sudo systemctl daemon-reload
|
|
297 sudo systemctl restart kubelet
|
|
298 kubectl uncordon control
|
|
299 kubectl get nodes
|
|
300 history
|
|
301 kubectl drain worker2
|
|
302 kubectl drain worker2 --ignore-daemonsets
|
|
303 kubectl drain worker2 --ignore-daemonsets --force
|
|
304 kubectl drain worker2 --ignore-daemonsets --force --delete-emptydir-data
|
|
305 kubectl uncordon worker2
|
|
306 kubectl get nodes
|
|
307 kubectl drain worker1 --ignore-daemonsets --force --delete-emptydir-data
|
|
308 kubectl uncordon worker1
|
|
309 kubectl get nodes
|
|
310 kubectl create deploy webstress --image=nginx
|
|
311 kubectl autoscale deploy webstress --min=2 --max=5 --cpu-percent=80
|
|
312 kubectl get hpa
|
|
313 kubectl get all --selector app=webstress
|
|
314 sudo vim /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
315 ls /etc/kubernetes/manifests/
|
|
316 kubectl get pods -n kube-system
|
|
317 sudo vim /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
318 kubectl get pods -n kube-system
|
|
319 sudo vim /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
320 history > /tmp/oct25.txt
|