sandervanvugt

CKAD march 24 day2

Mar 5th, 2024
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.54 KB | None | 0 0
  1. student@student-virtual-machine:~/ckad$ history
  2. 1 cd ckad/
  3. 2 ./countdown 12
  4. 3 ./countdown 2
  5. 4 ./countdown 1
  6. 5 sudo apt install vim git -y
  7. 6 git clone https://github.com/sandervanvugt/ckad
  8. 7 cd ckad/
  9. 8 ls
  10. 9 ls *sh
  11. 10 ./minikube-docker-setup.sh
  12. 11 minikube start --memory=4G
  13. 12 kubectl get all
  14. 13 minikube status
  15. 14 minikube ssh
  16. 15 kubectl get all
  17. 16 kubectl create deployment firstnginx --image=nginx --replicas=3
  18. 17 kubectl get all
  19. 18 history
  20. 19 kubectl -h | less
  21. 20 kubectl completion -h | less
  22. 21 source <(kubectl completion bash)
  23. 22 history
  24. 23 cd ../.kube/
  25. 24 ls
  26. 25 less config
  27. 26 cd
  28. 27 kubectl config view
  29. 28 kubectl get pods
  30. 29 kubectl get pods -n kube-system
  31. 30 kubectl config set-context --current --namespace=kube-system
  32. 31 kubectl get pods
  33. 32 kubectl config set-context --current --namespace=default
  34. 33 kubectl config -h | less
  35. 34 kubectl config set-context -h | less
  36. 35 history
  37. 36 cd ckad/
  38. 37 ls
  39. 38 cd dockerfile/
  40. 39 ls
  41. 40 vim Dockerfile
  42. 41 docker build -t mymap .
  43. 42 docker images
  44. 43 docker build -h
  45. 44 docker save -h | less
  46. 45 docker images
  47. 46 docker save mymap
  48. 47 docker save mymap -o mymap.tar
  49. 48 cd
  50. 49 cd ckad/
  51. 50 history
  52. 51 kubectl get all
  53. 52 kubectl delete pod firstnginx-d8679d567-7zgv8
  54. 53 kubectl get all
  55. 54 kubectl run -h | less
  56. 55 kubectl run hazelcast --image=hazelcast/hazelcast --port=5701
  57. 56 kubectl get pods
  58. 57 kubectl describe pod hazelcast
  59. 58 history get pods
  60. 59 kubectl get pods
  61. 60 kubectl delete pod hazelcast
  62. 61 kubectl get all
  63. 62 kubectl get pods firstnginx-d8679d567-4gnkf -o yaml | less
  64. 63 kubectl describe pods firstnginx-d8679d567-4gnkf
  65. 64 kubectl run mypod --image=busybox
  66. 65 kubectl get pods
  67. 66 kubectl describe pod mypod | less
  68. 67 kubectl get pods mypod -o yaml | less
  69. 68 kubectl run --help | less
  70. 69 kubectl run yamginx --image=nginx --dry-run=client -o yaml
  71. 70 kubectl run yamginx --image=nginx --dry-run=client -o yaml > yamginx.yaml
  72. 71 vim yamginx.yaml
  73. 72 history
  74. 73 kubectl create deploy test --image=nginx --dry-run=client -o yaml
  75. 74 history
  76. 75 #kubectl create deploy mydb --image=mariadb
  77. 76 kubectl create deploy mydb --image=mariadb --dry-run=client -o yaml | less
  78. 77 vim yamginx.yaml
  79. 78 kubectl create -f yamginx.yaml
  80. 79 kubectl delete -f yamginx.yaml
  81. 80 kubectl apply -f yamginx.yaml
  82. 81 vim yamginx.yaml
  83. 82 kubectl apply -f yamginx.yaml
  84. 83 kubectl delete -f yamginx.yaml
  85. 84 kubectl apply -f yamginx.yaml
  86. 85 kubectl get pods
  87. 86 vim yamginx.yaml
  88. 87 kubectl describe pod yamginx
  89. 88 kubectl logs yamginx
  90. 89 history
  91. 90 vim sidecar.yaml
  92. 91 kubectl apply -f sidecar.yaml
  93. 92 kubectl exec -it sidecar-pod -- /bin/bash
  94. 93 kubectl exec -it sidecar-pod -c sidecar -- /bin/bash
  95. 94 vim sidecar.yaml
  96. 95 vim init-example1.yaml
  97. 96 kubectl apply -f init-example1.yaml
  98. 97 kubectl get pods
  99. 98 kubectl describe pod init-demo1
  100. 99 vim init-example2.yaml
  101. 100 kubectl apply -f init-example2.yaml
  102. 101 kubectl get pods
  103. 102 kubectl describe pod init-demo2
  104. 103 kubectl get ns
  105. 104 kubectl get pods -n default
  106. 105 kubectl get pods -n kube-system
  107. 106 kubectl describe ns default
  108. 107 history
  109. 108 kubectl get all -A
  110. 109 kubectl create ns secret
  111. 110 kubectl get ns
  112. 111 kubectl describe ns secret
  113. 112 vim busybox-ns.yaml
  114. 113 kubectl run pod busybox -- sleep 3600
  115. 114 kubectl run pod sleepyone --image=busybox -- sleep 3600
  116. 115 kubectl get pods
  117. 116 kubectl run secretginx --image=nginx -n secret
  118. 117 kubectl get pods
  119. 118 kubectl get pods -A
  120. 119 kubectl config set-context --current --namespace=secret
  121. 120 kubectl get pods
  122. 121 kubectl config set-context --current --namespace=default
  123. 122 history
  124. 123 kubectl run nginx-lab --image=nginx
  125. 124 kubectl get pods
  126. 125 kubectl describe pod pod
  127. 126 kubectl explain pods.spec | less
  128. 127 kubectl explain pods.spec.volumes | less
  129. 128 kubectl explain deploy.spec | less
  130. 129 kubectl get pods
  131. 130 kubectl exec -it mypod -- sh
  132. 131 kubectl exec -it yamginx -- sh
  133. 132 history
  134. 133 kubectl describe pod sidecar-pod | less
  135. 134 kubectl run faildb --image=mariadb
  136. 135 kubectl get pods
  137. 136 kubectl describe pod faildb | less
  138. 137 kubectl logs faildb
  139. 138 kubectl delete pod faildb
  140. 139 kubectl run --help | less
  141. 140 kubectl run successdb --image=mariadb --env=MARIADB_ROOT_PASSWORD=password
  142. 141 kubectl get pods
  143. 142 history
  144. 143 kubectl get pods
  145. 144 kubectl logs firstnginx-d8679d567-4gnkf
  146. 145 kubectl explain pod.spec | less
  147. 146 kubectl explain pod.spec.securityContext | less
  148. 147 kubectl explain pod.spec.containers.securityContext | less
  149. 148 vim securitycontextdemo2.yaml
  150. 149 kubectl apply -f securitycontextdemo2.yaml
  151. 150 kubectl get pods
  152. 151 kubectl exec -it security-context-demo -- sh
  153. 152 vim securitycontextdemo.yaml
  154. 153 kubectl apply -f securitycontextdemo.yaml
  155. 154 kubectl get pods
  156. 155 kubectl describe pod nginxsecure
  157. 156 history
  158. 157 kubectl delete all --all
  159. 158 sudo poweroff
  160. 159 history
  161. 160 minikube start
  162. 161 kubectl get all
  163. 162 source <(kubectl completion bash)
  164. 163 kubectl get all
  165. 164 kubectl get pods -A
  166. 165 kubectl explain jobs.spec
  167. 166 kubectl explain jobs.spec | less
  168. 167 kubectl create job -h | less
  169. 168 kubectl create job onejob --image=busybox -- date
  170. 169 kubectl get all
  171. 170 kubectl get jobs -o yaml | less
  172. 171 kubectl api-resources | less
  173. 172 kubectl create job another --image=busybox -- sleep 120
  174. 173 kubectl get jobs -o yaml | less
  175. 174 kubectl get jobs onejob -o yaml | grep restartP
  176. 175 kubectl get all
  177. 176 kubectl delete job onejob
  178. 177 kubectl get all
  179. 178 kubectl create job mynewjob --image=busybox --dry-run=client -o yaml -- sleep 5 > mynewjob.yaml
  180. 179 kubectl create job -h | less
  181. 180 vim mynewjob.yaml
  182. 181 kubectl apply -f mynewjob.yaml
  183. 182 kubectl explain --recursive jobs.spec
  184. 183 kubectl explain --recursive jobs.spec | grep -C 5 ttlSecondsA
  185. 184 vim mynewjob.yaml
  186. 185 kubectl apply -f mynewjob.yaml
  187. 186 kubectl get all
  188. 187 kubectl delete job another
  189. 188 kubectl get all
  190. 189 kubectl apply -f mynewjob.yaml
  191. 190 kubectl get all
  192. 191 kubectl create cronjob -h | less
  193. 192 kubectl explain cronjob.spec.schedule
  194. 193 kubectl create cronjob runme --image=busybox --schedule="*/1 * * * *" -- echo greetings from the cluster
  195. 194 kubectl get all
  196. 195 kubectl logs pod/runme-28494093-r2sjw
  197. 196 kubectl delete cronjobs.batch runme
  198. 197 kubectl create cronjob -h | less
  199. 198 kubectl create cronjob hellojob --image=busybox --schedule="*/4 * * * *" -- echo hello world
  200. 199 cd ckad/
  201. 200 ls
  202. 201 cd labs
  203. 202 ls
  204. 203 ./ckad-lab5-grade.sh
  205. 204 kubectl explain pods.spec.containers.resources
  206. 205 kubectl create ns limited
  207. 206 kubectl describe ns limited
  208. 207 kubectl create quota -h | less
  209. 208 #kubectl create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10
  210. 209 kubectl create quota limited-quota --hard=memory=1G,pods=3
  211. 210 kubectl describe ns limited
  212. 211 kubectl create deploy testing --image=nginx --replicas=5
  213. 212 kubectl get all
  214. 213 kubectl describe deploy testing
  215. 214 kubectl get all
  216. 215 kubectl describe replicasets.apps testing-748d4566d5
  217. 216 kubectl describe ns default
  218. 217 kubectl get quota
  219. 218 kubectl delete quota limited-quota
  220. 219 kubectl get all
  221. 220 kubectl scale deployment testing --replicas 4
  222. 221 kubectl get all
  223. 222 history
  224. 223 kubectl create quota limited-quota --hard=memory=1G,pods=3 -n limited
  225. 224 kubectl get ns limited
  226. 225 kubectl describe ns limited
  227. 226 kubectl create deploy another --image=nginx --replicas=5
  228. 227 kubectl delete deploy another
  229. 228 kubectl create deploy another --image=nginx --replicas=5 -n limited
  230. 229 kubectl get all -n limited
  231. 230 kubectl describe -n limited replicaset another-664d446fc6
  232. 231 kubectl set resources -h | less
  233. 232 #kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
  234. 233 kubectl get all -n limited
  235. 234 kubectl set -n limited resources deployment another --limits=memory=256Mi
  236. 235 kubectl get all -n limited
  237. 236 kubectl describe ns limited
  238. 237 history
  239. 238 kubectl get all -n limited
  240. 239 kubectl get pods -n limited another-5749bcc7dd-6nqcc
  241. 240 kubectl get pods -n limited another-5749bcc7dd-6nqcc -o yaml
  242. 241 history
  243. 242 kubectl get services
  244. 243 cd ..
  245. 244 vim busybox-ready.yaml
  246. 245 kubectl apply -f busybox-ready.yaml
  247. 246 kubectl get pods
  248. 247 kubectl describe pod busybox-ready
  249. 248 kubectl edit pods busybox-ready
  250. 249 kubectl exec -it busybox-ready -- sh
  251. 250 kubectl get pods
  252. 251 vim nginx-probes.yaml
  253. 252 kubectl apply -f nginx-probes.yaml
  254. 253 kubectl get pods
  255. 254 kubectl create deploy myweb --image=nginx --replicas=3
  256. 255 kubectl get all
  257. 256 kubectl describe deployments.apps myweb
  258. 257 kubectl get all --selector app=myweb
  259. 258 kubectl delete pod myweb-9794cbc77-85rd4
  260. 259 kubectl get all --selector app=myweb
  261. 260 kubectl run mypod --image=nginx
  262. 261 kubectl get all
  263. 262 kubectl delete pod mypod
  264. 263 kubectl get all
  265. 264 kubectl apply -f redis-deploy.yaml
  266. 265 vim redis-deploy.yaml
  267. 266 kubectl api-resources | less
  268. 267 vim redis-deploy.yaml
  269. 268 kubectl apply -f redis-deploy.yaml
  270. 269 history
  271. 270 kubectl get all
  272. 271 kubectl delete cronjobs.batch hellojob
  273. 272 kubectl edit deployments.apps redis
  274. 273 kubectl get all
  275. 274 kubectl delete rs
  276. 275 kubectl delete rs redis-65fbbd8f94
  277. 276 kubectl get all
  278. 277 history
  279. 278 kubectl create deploy nginxup --image=nginx:1.14
  280. 279 kubectl get all --selector app=nginxup
  281. 280 kubectl scale deployment nginxup --replicas=3
  282. 281 kubectl get all --selector app=nginxup
  283. 282 kubectl set image deploy nginxup nginx=nginx:1.17
  284. 283 kubectl get all --selector app=nginxup
  285. 284 kubectl get pods --show-labels
  286. 285 kubectl get pods myweb-9794cbc77-h45br -o yaml | less
  287. 286 kubectl get deploy redis -o yaml | less
  288. 287 kubectl create deploy bluelabel --image=nginx
  289. 288 kubectl label deploy bluelabel state=demo
  290. 289 kubectl get deploy --show-labels
  291. 290 kubectl get all --selector state=demo
  292. 291 kubectl get all --selector app=bluelabel
  293. 292 kubectl get deploy bluelabel -o yaml | less
  294. 293 kubectl describe pod bluelabel-59d6bcf7ff-p9h5p -o yaml | less
  295. 294 kubectl describe pod bluelabel-59d6bcf7ff-p9h5p
  296. 295 kubectl label pod bluelabel-59d6bcf7ff-p9h5p app-
  297. 296 kubectl get pods | grep blue
  298. 297 kubectl get pods --show-labels | grep blue
  299. 298 history
  300. 299 kubectl get deploy -o yaml
  301. 300 kubectl get deploy bluelabel -o yaml
  302. 301 kubectl scale deploy bluelabel --replicas=4
  303. 302 kubectl get all --selector app=bluelabel
  304. 303 kubectl set env deploy bluelabel type=blended
  305. 304 kubectl get all --selector app=bluelabel
  306. 305 vim rolling.yaml
  307. 306 kubectl apply -f rolling.yaml
  308. 307 kubectl rollout history deployment
  309. 308 kubectl edit deployments.apps rolling-nginx
  310. 309 kubectl rollout history deployment
  311. 310 kubectl describe deployments.apps rolling-nginx
  312. 311 kubectl rollout history deployment rolling-nginx --revision=2
  313. 312 kubectl rollout history deployment rolling-nginx --revision=1
  314. 313 kubectl rollout undo deployment rolling-nginx --to-revision=1
  315. 314 kubectl get all
  316. 315 kubectl delete all --all
  317. 316 kubectl create deploy nginxsvc --image=nginx
  318. 317 kubectl get all
  319. 318 kubectl scale deploy nginxsvc --replicas=3
  320. 319 kubectl expose deploy nginxsvc --port=80
  321. 320 kubectl get all
  322. 321 kubectl describe svc nginxsvc
  323. 322 kubectl get pods -o wide
  324. 323 kubectl get endpoints
  325. 324 kubectl get svc
  326. 325 curl 10.101.243.185
  327. 326 minikube ssh
  328. 327 kubectl edit svc nginxsvc
  329. 328 kubectl get svc
  330. 329 minikube ip
  331. 330 curl 192.168.49.2:32519
  332. 331 history
  333. 332 kubectl get svc
  334. 333 kubectl get all -n kube-system
  335. 334 kubectl get pods -o wide -n kube-system
  336. 335 kubectl get endpoints -A
  337. 336 kubectl run testpod --image=busybox -- sleep 3600
  338. 337 kubectl create ns other
  339. 338 kubectl run newginx --image=nginx -n other
  340. 339 kubectl expose pod -n other newginx --port=80
  341. 340 kubectl get svc -A
  342. 341 kubectl get svc,pods -n kube-system
  343. 342 kubectl get svc
  344. 343 kubectl exec -it testpod -- cat /etc/resolv.conf
  345. 344 kubectl exec -it testpod -- nslookup nginxsvc
  346. 345 kubectl exec -it testpod -- nslookup newginx
  347. 346 kubectl get svc -A
  348. 347 kubectl exec -it testpod -- nslookup newginx.other.svc.cluster.local
  349. 348 history
  350. 349 kubectl get svc
  351. 350 kubectl get svc -A
  352. 351 vim nwpolicy-complete-example.yaml
  353. 352 kubectl apply -f nwpolicy-complete-example.yaml
  354. 353 kubectl expose pod nginx --port=80
  355. 354 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  356. 355 kubectl get pods --show-labels
  357. 356 kubectl describe networkpolicies.networking.k8s.io
  358. 357 minikube addons list
  359. 358 kubectl get all -n kube-system
  360. 359 kubectl get ns
  361. 360 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
  362. 361 kubectl get pods -A
  363. 362 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  364. 363 minikube stop
  365. 364 minikube start
  366. 365 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  367. 366 kubectl get pods
  368. 367 kubectl get networkpolicy
  369. 368 kubectl get pods
  370. 369 kubectl apply -f nwpolicy-complete-example.yaml
  371. 370 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  372. 371 minikube stop
  373. 372 minikube start --cni=calico
  374. 373 kubectl get ns
  375. 374 kubectl get pods -n kube-system
  376. 375 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  377. 376 kubectl delete -f nwpolicy-complete-example.yaml
  378. 377 kubectl all
  379. 378 kubectl get all
  380. 379 kubectl apply -f nwpolicy-complete-example.yaml
  381. 380 kubectl get svc
  382. 381 kubectl describe svc nginx
  383. 382 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  384. 383 kubectl edit svc nginxsvc
  385. 384 history
  386.  
Advertisement
Add Comment
Please, Sign In to add comment