Advertisement
sandervanvugt

CKA may23 day2

May 31st, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.55 KB | None | 0 0
  1. student@control:~/cka$ history
  2. 1 sudo apt install vim git -y
  3. 2 vim /etc/hosts
  4. 3 sudo -i
  5. 4 git clone https://github.com/sandervanvugt/cka
  6. 5 ip a
  7. 6 ip route show
  8. 7 sudo -i
  9. 8 top
  10. 9 ./cka/
  11. 10 ./cka/counter.sh 10
  12. 11 exit
  13. 12 history
  14. 13 git clone https://github.com/sandervanvugt/cka
  15. 14 cd cka
  16. 15 ls *sh
  17. 16 sudo ./setup-container.sh
  18. 17 ls *sh
  19. 18 sudo ./setup-kubetools.sh
  20. 19 history
  21. 20 sudo kubeadm init
  22. 21 kubectl get all
  23. 22 kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/tigera-operator.yaml
  24. 23 kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/custom-resources.yaml
  25. 24 kubectl get ns
  26. 25 kubectl get pods
  27. 26 kubectl get pods -n tigera-operator
  28. 27 kubectl get pods -n kube-system
  29. 28 kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/custom-resources.yaml
  30. 29 kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/custom-resources.yaml
  31. 30 kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml
  32. 31 kubectl get ns
  33. 32 kubectl get pods
  34. 33 kubectl get pods -n kube-system
  35. 34 kubectl get nodes
  36. 35 kubectl create deploy testginx --image=nginx
  37. 36 kubectl get pods
  38. 37 kubectl get nodes
  39. 38 history
  40. 39 kubectl get pods -n kube-system
  41. 40 source <(kubectl completion bash)
  42. 41 kubectl create ns mynamespace
  43. 42 kubectl run task2pod --image=alpine -- sleep 3600
  44. 43 kubectl run -n mynamespace task2pod --image=alpine -- sleep 3600
  45. 44 kubectl get pods -n mynamespace
  46. 45 kubectl edit -n mynamespace pod task2pod
  47. 46 history
  48. 47 vim lab3.yaml
  49. 48 kubectl apply -f lab3.yaml
  50. 49 kubectl get pods
  51. 50 kubectl describe pod task3pod
  52. 51 kubectl run failingbox --image=busybox
  53. 52 kubectl get pods
  54. 53 kubectl delete pod failingbox
  55. 54 kubectl run succesfulbox --image=busybox -- sleep 3600
  56. 55 kubectl get pods
  57. 56 kubectl get pods -o yaml
  58. 57 kubectl get pods succesfulbox -o yaml | less
  59. 58 kubectl create quota -h | less
  60. 59 kubectl create ns limited
  61. 60 kubectl create quota qtest --hard pods=3,cpu=100m.memory=500Mi -n limited
  62. 61 kubectl create quota qtest --hard pods=3,cpu=100m,memory=500Mi -n limited
  63. 62 kubectl describe quota -n limited
  64. 63 kubectl create deploy nginx --image=nginx:latest --replicas=3 -n limited
  65. 64 kubectl get all -n limited
  66. 65 kubectl describe -n limited rs/nginx-7bf8c77b5b
  67. 66 kubectl set -h
  68. 67 kubectl set resources -h
  69. 68 kubectl set resources -n limited --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi
  70. 69 kubectl set resources -n limited --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi deploy nginx
  71. 70 kubectl get all -n limited
  72. 71 kubectl describe -n limited
  73. 72 kubectl describe ns limited
  74. 73 kubectl edit ns limited
  75. 74 kubectl edit -n limited quota qtest
  76. 75 kubectl get all -n limited
  77. 76 kubectl scale -n limited deploy nginx --replicas=3
  78. 77 kubectl get all -n limited
  79. 78 ./counter.sh 8
  80. 79 history
  81. 80 cat /etc/os-release
  82. 81 history | less
  83. 82 vim nwpolicy-complete-example.yaml
  84. 83 kubectl apply -f nwpolicy-complete-example.yaml
  85. 84 kubectl expose pod nginx --port=80
  86. 85 kubectl describe svc nginx
  87. 86 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  88. 87 kubectl label pod busybox access=true
  89. 88 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  90. 89 kubectl create ns nwp-namespace
  91. 90 vim nwp-lab9-1.yaml
  92. 91 kubectl create -f nwp-lab9-1.yaml
  93. 92 kubectl expose pod nwp-nginx --port=80
  94. 93 kubectl exec -it newp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  95. 94 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  96. 95 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  97. 96 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx.default.svc.cluster.local
  98. 97 kubectl get svc
  99. 98 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  100. 99 vim nwp-lab9-1.yaml
  101. 100 vim nwp-lab9-2.yaml
  102. 101 kubectl create -f nwp-lab9-2.yaml
  103. 102 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  104. 103 kubectl create deployment busybox --image=busybox --sleep 3600
  105. 104 kubectl create deployment busybox --image=busybox -- sleep 3600
  106. 105 kubectl exec -it busybox-c95495658-ljctl -- wget --spider --timeout=1 nwp-nginx
  107. 106 kubectl delete -f nwp-lab9-2.yaml
  108. 107 echo google for ahmetdb
  109. 108 ./counter.sh 20
  110. 109 vim rh.yaml
  111. 110 ./counter.sh 5
  112. 111 vim rh.yaml
  113. 112 vim wz.yaml
  114. 113 history
  115. 114 vim wz-lab6.yaml
  116. 115 kubectl get pods
  117. 116 kubectl get pods busybox -o yaml | less
  118. 117 vim wz-lab6.yaml
  119. 118 kubectl apply -f wz-lab6.yaml
  120. 119 vim wz-lab6.yaml
  121. 120 kubectl apply -f wz-lab6.yaml
  122. 121 kubectl expose pod task6pod --port=80
  123. 122 kubectl get svc
  124. 123 kubectl edit svc task6pod
  125. 124 kubectl get svc
  126. 125 curl 192.168.29.81:31761
  127. 126 kubectl get pods task6pod -o yaml | less
  128. 127 kubectl exec -it task6pod -- sh
  129. 128 kubectl exec -it task6pod -c nginx -- sh
  130. 129 curl 192.168.29.81:31761
  131. 130 kubectl delete -f wz-lab6.yaml
  132. 131 vim wz-lab6.yaml
  133. 132 kubectl apply -f wz-lab6.yaml
  134. 133 kubectl expose pod task6podsvv --type=NodePort
  135. 134 kubectl expose pod task6podsvv --type=NodePort --port=80
  136. 135 kubectl get svc
  137. 136 curl 192.168.29.81:30130
  138. 137 history
  139. 138 history -d 134
  140. 139 ./counter.sh 5
  141. 140 vim task4pod.yaml
  142. 141 kubectl apply -f task4pod.yaml
  143. 142 vim task4pod.yaml
  144. 143 kubectl apply -f task4pod.yaml
  145. 144 kubectl get pods
  146. 145 vim wz4.yaml
  147. 146 kubectl apply -f wz4.yaml
  148. 147 kubectl get pods
  149. 148 cd
  150. 149 ls
  151. 150 tar -xvf helm-v3.12.0-linux-amd64.tar.gz
  152. 151 sudo cp linux-amd64/helm /usr/local/bin/
  153. 152 helm --version
  154. 153 helm version
  155. 154 helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace
  156. 155 kubectl get pods -n ingress-nginx
  157. 156 kubectl get ns
  158. 157 kubectl create deploy nginxsvc --image=nginx --port=80 --replicas=3
  159. 158 kubectl get all --selector app=nginxsvc
  160. 159 kubectl get all --selector app=nginxsvc -o wide
  161. 160 kubectl expose deploy nginxsvc
  162. 161 kubectl get all --selector app=nginxsvc -o wide
  163. 162 kubectl describe svc nginxsvc
  164. 163 kubectl create ingress nginxsvc --class=nginx --rule=nginxsvc.info/*=nginxsvc:80
  165. 164 kubectl port-forward -n ingress-nginx svc/ingress-nginx-controller 8080:80
  166. 165 bg
  167. 166 sudo vim /etc/hosts
  168. 167 curl nginxsvc.info:8080
  169. 168 kubectl edit svc nginxsvc
  170. 169 curl nginxsvc.info:8080
  171. 170 kubectl get ingress
  172. 171 kubectl describe ingress nginxsvc
  173. 172 kubectl describe svc nginxsvc
  174. 173 kubectl edit svc nginxsvc
  175. 174 kubectl describe svc nginxsvc
  176. 175 kubectl describe ingress nginxsvc
  177. 176 curl nginxsvc.info:8080
  178. 177 history
  179. 178 kubectl get pods
  180. 179 kubectl get pods busybox -o yaml | less
  181. 180 kubectl get pods -n kube-system
  182. 181 kubectl get pods -n kube-system calico-node-5pmxr -o yaml | less
  183. 182 kubectl get roles
  184. 183 kubectl get clusterroles
  185. 184 kubectl get clusterroles | grep calico
  186. 185 kubectl get clusterrole calico-node -o yaml | less
  187. 186 kubectl get clusterrolebinding
  188. 187 kubectl get clusterrolebinding | grep calic
  189. 188 kubectl get clusterrolebinding calico-node -o yaml | less
  190. 189 kubectl create role --help | less
  191. 190 history
  192. 191 vim wz10.txt
  193. 192 kubectl create sa mysa
  194. 193 kubectl get sa
  195. 194 kubectl run mypod --dry-run=client -o yaml > mypod.yaml
  196. 195 kubectl run mypod --dry-run=client --image=nginx -o yaml > mypod.yaml
  197. 196 vim mypod.yaml
  198. 197 kubectl apply -f mypod.yaml
  199. 198 kubectl get pod mypod -o yaml | less
  200. 199 history
  201. 200 kubectl get pods -o wide
  202. 201 kubectl get pods -n kube-system -o wide
  203. 202 kubectl edit node control
  204. 203 kubectl get pods -n kube-system etcd-control -o yaml | less
  205. 204 cd cka/
  206. 205 ./counter.sh 5
  207. 206 kubectl edit
  208. 207 kubectl edit node control
  209. 208 kubectl create deploy taintdeploy --image=nginx --replicas=3
  210. 209 kubectl get pods -o wide | grep taintd
  211. 210 kubectl taint -h | less
  212. 211 kubectl get nodes
  213. 212 kubectl cordon -h | less
  214. 213 kubectl drain -h | less
  215. 214 kubectl cordon worker1
  216. 215 kubectl get nodes
  217. 216 kubectl edit node worker1
  218. 217 kubectl uncordon worker1
  219. 218 kubectl edit node worker1
  220. 219 top
  221. 220 kubectl top
  222. 221 kubectl top pod
  223. 222 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  224. 223 kubectl -n kube-system get pods
  225. 224 kubectl -n kube-system edit deployments.apps metrics-server
  226. 225 kubectl -n kube-system get pods
  227. 226 kubectl top pods
  228. 227 history
  229. 228 kubectl -n kube-system get pods
  230. 229 kubectl top pod
  231. 230 cd /etc/kubernetes/manifests/
  232. 231 ls
  233. 232 vim etcd.yaml
  234. 233 sudo vim etcd.yaml
  235. 234 cd
  236. 235 sudo apt install etcd-client
  237. 236 sudo reboot
  238. 237 kubectl get all
  239. 238 sudo etcdctl --help
  240. 239 sudo ETCDCTL_API=3 etcdctl --help
  241. 240 sudo ETCDCTL_API=3 etcdctl snapshot save --help
  242. 241 sudo ls -l /etc/kubernetes/pki/etcd/
  243. 242 ps aux | grep etcd
  244. 243 sudo ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key get / --prefix --keys-only
  245. 244 sudo ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key get snapshot save /tmp/etcdbackup.db
  246. 245 sudo ETCDCTL_API=e etcdctl --write-out=table snapshot status /tmp/etcdbackup.db
  247. 246 sudo ETCDCTL_API=3 etcdctl --write-out=table snapshot status /tmp/etcdbackup.db
  248. 247 ls -l /tmp/
  249. 248 sudo ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key snapshot save /tmp/etcdbackup.db
  250. 249 sudo ETCDCTL_API=3 etcdctl --write-out=table snapshot status /tmp/etcdbackup.db
  251. 250 cp /tmp/etcdbackup.db /tmp/etcdbackup.db.2
  252. 251 cp /tmp/etcdbackup.db /tmp/etcdbackup.db.3
  253. 252 history
  254. 253 kubectl get deploy
  255. 254 kubectl delete --all deploy
  256. 255 cd /etc/kubernetes/manifests/
  257. 256 ls
  258. 257 sudo mv * ..
  259. 258 sudo crictl ps
  260. 259 sudo ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcdbackup.db --data-dir /var/lib/etcd-backup
  261. 260 ls -l /var/lib/etcd-backup/
  262. 261 sudp ls -l /var/lib/etcd-backup/
  263. 262 sudo ls -l /var/lib/etcd-backup/
  264. 263 sudo vi /etc/kubernetes/etcd.yaml
  265. 264 sudo mv ../*.yaml .
  266. 265 sudo crictl ps
  267. 266 kubectl get deploy
  268. 267 history
  269. 268 cd
  270. 269 cd cka/
  271. 270 ./counter.sh 22
  272. 271 kubectl --version
  273. 272 kubectl version
  274. 273 ./counter.sh 12
  275. 274 vim je.yaml
  276. 275 kubectl taint nodes worker1 nosched=true:NoSchedule
  277. 276 kubectl get nodes
  278. 277 kubectl create deploy tt image=nginx --replicas=3
  279. 278 kubectl create deploy tt --image=nginx --replicas=3
  280. 279 kubectl get pods --selector app=tt
  281. 280 kubectl get pods --selector app=tt -o wide
  282. 281 kubect get nodes
  283. 282 kubectl get nodes
  284. 283 kubectl get nodes -o wide
  285. 284 kubectl edit node worker1
  286. 285 vim je.yaml
  287. 286 kubectl apply -f je.yaml
  288. 287 kubectl get pod nginxtaint -o wide
  289. 288 kubectl edit node worker1
  290. 289 kubectl get nodes
  291. 290 kubectl describe node worker2
  292. 291 kubectl describe node worker2 | less
  293. 292 kubect get nodes
  294. 293 kubectl get nodes
  295. 294 kubectl label nodes worker2 disktype=ssd
  296. 295 vim selector-pod.yaml
  297. 296 kubectl apply -f selector-pod.yaml
  298. 297 kubectl get pods nginx -o wide
  299. 298 vim selector-pod.yaml
  300. 299 kubectl apply -f selector-pod.yaml
  301. 300 kubectl get pods nginxxxx
  302. 301 source <(kubectl completion bash)
  303. 302 kubectl describe pod nginxxxx
  304. 303 kubectl label nodes worker1 disktype=xxd
  305. 304 kubectl get pods nginxxxx -w
  306. 305 ./counter.sh 5
  307. 306 kubectl get pods
  308. 307 kubectl get pods -o wide
  309. 308 history
  310.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement