sandervanvugt

CKAD day3 march21

Mar 17th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.45 KB | None | 0 0
  1. student@student-virtual-machine:~/ckad$ history
  2. 1 sudo apt install vim git
  3. 2 git clone https://github.com/sandervanvugt/ckad
  4. 3 cd ckad
  5. 4 sudo ls -l /root
  6. 5 ls
  7. 6 ./kube-setup.sh
  8. 7 sudo reboot
  9. 8 cd ckad/
  10. 9 cat kube-setup.sh
  11. 10 minikube start --memory 4096 --vm-driver=kvm2
  12. 11 kubectl get all
  13. 12 history
  14. 13 free -m
  15. 14 sudo grep vmx /proc/cpuinfo
  16. 15 free -m
  17. 16 df -h
  18. 17 ls
  19. 18 vim kube-setup.sh
  20. 19 vim other-options.txt
  21. 20 minikube -h
  22. 21 minikube status
  23. 22 minikube ssh
  24. 23 kubectl get all
  25. 24 minikube dashboard
  26. 25 bg
  27. 26 ./countdown 12
  28. 27 kubectl get all
  29. 28 kubectl delete pod myfirstnginx-bc9b6d4d7-g9fz2
  30. 29 kubectl get all
  31. 30 kubectl -h
  32. 31 kubectl completion -h
  33. 32 source <(kubectl completion bash)
  34. 33 kubectl create deployment newnginx --image=nginx -h
  35. 34 kubectl create deployment newnginx --image=nginx --replicase=3
  36. 35 kubectl create deployment newnginx --image=nginx --replicas=3
  37. 36 kubectl get all
  38. 37 kubectl version
  39. 38 history
  40. 39 kubectl api-resources | less
  41. 40 kubectl explain priorityclasses
  42. 41 kubectl explain priorityclasses | less
  43. 42 kubectl -h | less
  44. 43 kubectl -h |less
  45. 44 kubectl api-resources | less
  46. 45 kubectl api-versions | less
  47. 46 kubectl explain pod | less
  48. 47 history
  49. 48 ./countdown 12
  50. 49 kubectl proxy --port=8001 &
  51. 50 curl http://localhost:8001/version
  52. 51 kubectl get pods
  53. 52 curl http://localhost:8001/api/v1/namespaces/default/pods
  54. 53 curl http://localhost:8001/api/v1/namespaces/default/pods/newnginx-757c575454-8x76n/
  55. 54 curl -XDELETE http://localhost:8001/api/v1/namespaces/default/pods/newnginx-757c575454-8x76n/
  56. 55 kubectl get pods
  57. 56 kubectl -h | less
  58. 57 kubectl completion -h | less
  59. 58 kubectl explain pod
  60. 59 kubectl explain pod.spec
  61. 60 kubectl explain pod.spec | less
  62. 61 kubectl run -h | less
  63. 62 kubectl run nginx --image=nginx
  64. 63 kubectl get all
  65. 64 kubectl delete pod newnginx-757c575454-zft7m
  66. 65 kubectl get all
  67. 66 kubectl delete pod nginx
  68. 67 kubectl get all
  69. 68 kubectl scale deployment --replicas=4 newnginx
  70. 69 kubectl get all
  71. 70 kubectl delete deployments.apps myfirstnginx
  72. 71 kubectl run --image=mariadb
  73. 72 kubectl run mydb --image=mariadb
  74. 73 kubectl get pods
  75. 74 kubectl describe pod mydb
  76. 75 kubectl logs mydb
  77. 76 kubectl run -h | less
  78. 77 kubectl run mydb --image=mariadb --env=MYSQL_ROOT_PASSWORD=password
  79. 78 kubectl delete pod mydb
  80. 79 kubectl run mydb --image=mariadb --env=MYSQL_ROOT_PASSWORD=password
  81. 80 kubectl get pod
  82. 81 history
  83. 82 ls
  84. 83 vim busybox.yaml
  85. 84 kubectl create -f busybox.yaml
  86. 85 kubectl get pods
  87. 86 vim busybox.yaml
  88. 87 kubectl api-resources | less
  89. 88 kubectl explain pods
  90. 89 kubectl explain pods.spec
  91. 90 kubectl explain pods.spec | less
  92. 91 kubectl explain pods.spec.containers
  93. 92 kubectl explain --recursive pods.spec.containers
  94. 93 ./countdown 12
  95. 94 vim busybox.yaml
  96. 95 kubectl create -f busybox.yaml
  97. 96 vim busybox.yaml
  98. 97 kubectl create -f busybox.yaml
  99. 98 vim busybox.yaml
  100. 99 kubectl create -f busybox.yaml
  101. 100 kubectl run mywhatever --image=nginx --dry-run=client -o yaml > whatever.yaml
  102. 101 vim whatever.yaml
  103. 102 kubectl run busypod --image=busybox --restart=Never --command -- /bin/sh
  104. 103 kubectl get pods
  105. 104 kubectl get pods busypod -o yaml > busypod.yaml
  106. 105 vim busypod.yaml
  107. 106 kubectl run busypod --image=busybox --restart=Never --dry-run=client -o yaml --command -- /bin/sh
  108. 107 vim ~/.vimrc
  109. 108 vim sidecar.yaml
  110. 109 kubectl create -f sidecar.yaml
  111. 110 kubectl get pods
  112. 111 history
  113. 112 https://pastebin.com/u/sandervanvugt
  114. 113 top
  115. 114 kubectl get all
  116. 115 vim sidecar.yaml
  117. 116 kubectl get pods
  118. 117 kubectl exec -it sidecar-pod -c sidecar /bin/bash
  119. 118 vim new-init.yaml
  120. 119 kubectl create -f new-init.yaml
  121. 120 kubectl get pods
  122. 121 vim initpod.yaml
  123. 122 kubectl create -f initpod.yaml
  124. 123 kubectl get pods
  125. 124 kubectl describe pod init-demo
  126. 125 kubectl get events
  127. 126 ./countdown
  128. 127 kubectl run -h | less
  129. 128 kubectl explain pods.spec.securityContext
  130. 129 kubectl explain pods.spec.containers.securityContext
  131. 130 kubectl explain --recursive pods
  132. 131 kubectl explain --recursive pods | less
  133. 132 vim securitycontextdemo2.yaml
  134. 133 kubectl apply -f securitycontextdemo2.yaml
  135. 134 kubectl exec -it security-context-demo -- sh
  136. 135 kubectl create -f securitycontextdemo.yaml
  137. 136 kubectl get pods
  138. 137 kubectl describe pods nginxsecure
  139. 138 kubectl explain pods.spec.containers.securityContext
  140. 139 vim simplejob.yaml
  141. 140 kubectl create -f simplejob.yaml
  142. 141 kubectl get all
  143. 142 kubectl explain jobs.spec
  144. 143 vim simplejob.yaml
  145. 144 kubectl create -f simplejob.yaml
  146. 145 kubectl delete jobs simple-job
  147. 146 kubectl get pods
  148. 147 kubectl create -f simplejob.yaml
  149. 148 kubectl get all
  150. 149 vim simplejob.yaml
  151. 150 kubectl apply -f simplejob.yaml
  152. 151 kubectl delete -f simplejob.yaml
  153. 152 vim simplejob.yaml
  154. 153 kubectl apply -f simplejob.yaml
  155. 154 kubectl get all
  156. 155 vim simplejob.yaml
  157. 156 kubectl apply -f simplejob.yaml
  158. 157 kubectl edit jobs simple-job
  159. 158 ./countdown 12
  160. 159 vim cron-example.yaml
  161. 160 kubectl create -f cron-example.yaml
  162. 161 kubectl get all
  163. 162 date
  164. 163 kubectl get all
  165. 164 kubectl describe cronjobs.batch hello
  166. 165 kubectl get all
  167. 166 kubectl create cronjob -h | less
  168. 167 kubectl create cronjob my-job --image=busybox --schedule="*/5 * * * *" -- logger "hello world" --dry-run=client -o yaml > lab6.yaml
  169. 168*
  170. 169 kubectl create cronjob my-job --image=busybox --schedule="*/5 * * * *" --dry-run=client -o yaml -- logger "hello world"
  171. 170 kubectl get pods
  172. 171 minikube ssh
  173. 172 kubectl get all -A
  174. 173 kubectl get pods -A
  175. 174 kubectl get ns
  176. 175 kubectl create ns secret
  177. 176 vim busybox-ns.yaml
  178. 177 kubectl create -f busybox-ns.yaml
  179. 178 vim busybox-ns.yaml
  180. 179 kubectl create -f busybox-ns.yaml
  181. 180 kubectl get pods
  182. 181 kubectl get pods -n secret
  183. 182 kubectl config set-context --current --namespace=secret
  184. 183 kubectl config view
  185. 184 kubectl config set-context --current --namespace=default
  186. 185 kubectl config view
  187. 186 kubectl config view | grep namespace
  188. 187 kubectl config get-contexts
  189. 188 kubectl config set-context --current --namespace=kube-systemn
  190. 189 kubectl config set-context --current --namespace=kube-system
  191. 190 kubectl get pods
  192. 191 kubectl config set-context --current --namespace=default
  193. 192 kubectl edit pod busypod
  194. 193 kubectl edit pod busypod -n secret
  195. 194 kubectl create quota -h
  196. 195 ubectl create quota my-quota
  197. 196 kubectl create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10 -n secret
  198. 197 kubectl describe ns secret
  199. 198 kubectl create failginx --image=nginx --replicas=3 -n secret
  200. 199 kubectl create deployment failginx --image=nginx --replicas=3 -n secret
  201. 200 kubectl describe deployments.apps failginx -n secret
  202. 201 kubectl get all -n secret
  203. 202 kubectl describe rs -n secret failginx-6d74bcdc5d
  204. 203 kubectl delete -n secret deployments.apps failginx
  205. 204 vim frontend-resources.yaml
  206. 205 kubectl create -f frontend-resources.yaml
  207. 206 kubectl get all -n secret
  208. 207 kubectl get all -n secret\
  209. 208 kubectl get all -n secret
  210. 209 kubectl describe -n secret pod frontend
  211. 210 kubectl get all -n secret
  212. 211 vim frontend-resources.yaml
  213. 212 kubectl create -f frontend-resources.yaml
  214. 213 kubectl get pods
  215. 214 kubectl describe pods frontend
  216. 215 kubectl create quota -h
  217. 216 vim frontend-resources.yaml
  218. 217 kubectl explain deploy.spec
  219. 218 kubectl explain deploy.spec.template
  220. 219 kubectl explain deploy.spec.template.spec
  221. 220 kubectl explain deploy.spec.template.spec.containers
  222. 221 kubectl create deployment nginxvlah --image=nginx
  223. 222 kubectl get deployments.apps nginxvlah -o yaml
  224. 223 vim redis-deploy.yaml
  225. 224 kubectl create -f redis-deploy.yaml
  226. 225 vim redis-deploy.yaml
  227. 226 kubectl explain deploy
  228. 227 kubectl create -f redis-deploy.yaml
  229. 228 kubectl get all
  230. 229 kubectl edit deployments.apps redis
  231. 230 kubectl get all
  232. 231 kubectl delete pod redis-6fb5b985bc-vfgj7
  233. 232 kubectl get all
  234. 233 ./countdown 12
  235. 234 vim rolling.yaml
  236. 235 kubectl create -f rolling.yaml
  237. 236 kubectl rollout history deployment rolling-nginx
  238. 237 kubectl rollout history deployment rolling-nginx --revision=1
  239. 238 kubectl edit deployments.apps rolling-nginx
  240. 239 kubectl get all
  241. 240 kubectl rollout history deployment
  242. 241 kubectl describe deployments.apps rolling-nginx
  243. 242 kubectl rollout history deployment rolling-nginx --revision=1
  244. 243 kubectl rollout history deployment rolling-nginx --revision=2
  245. 244 kubectl rollout undo deployment rolling-nginx --to-revision=1
  246. 245 kubectl get all
  247. 246 kubectl get all --show-labels
  248. 247 kubectl get all --selector app=newnginx
  249. 248 kubectl create deployment ghost --image=ghost
  250. 249 kubectl get all --selector app=ghost
  251. 250 kubectl get all --selector app=ghost --show-labels
  252. 251 kubectl label deployments.apps ghost state=demo
  253. 252 kubectl get all --selector app=ghost --show-labels
  254. 253 kubectl create deployment nginx --image=nginx
  255. 254 kubectl describe deployments.apps nginx
  256. 255 kubectl describe pod nginx-6799fc88d8-qsn74
  257. 256 kubectl scale deployment nginx --replicas=3
  258. 257 kubectl get all --selector app=nginx
  259. 258 kubectl label pod nginx-6799fc88d8-4h6q6 app-
  260. 259 kubectl get all --selector app=nginx
  261. 260 kubectl get pods
  262. 261 ./countdown 5
  263. 262 kubectl get cron.spec
  264. 263 kubectl explain cron.spec
  265. 264 kubectl explain cronjob.spec
  266. 265 kubectl explain cronjob.spec.jobTemplate
  267. 266 kubectl explain cronjob.spec.jobTemplate.spec
  268. 267 kubectl get pods -o wide
  269. 268 ./countdown 12
  270. 269 kubectl create cronjob -h | less
  271. 270 kubectl get deployments.apps
  272. 271 kubectl delete deploy newnginx,nginxvlah
  273. 272 kubectl delete deploy newnginx
  274. 273 kubectl delete deploy nginxvlah
  275. 274 kubectl delete deploy rolling-nginx
  276. 275 kubectl delete deploy redis
  277. 276 kubectl delete deploy ghost
  278. 277 kubectl get deployments.apps
  279. 278 kubectl expose -h
  280. 279 kubectl expose -h | less
  281. 280 kubectl expose deployment nginx --port=80 --type=NodePort
  282. 281 kubectl get svc
  283. 282 kubectl get svc nginx -o yaml
  284. 283 kubectl describe service nginx
  285. 284 kubectl create deployment nginxsvc --image=nginx --replicas=3
  286. 285 kubectl expose deployment nginxsvc
  287. 286 kubectl expose deployment nginxsvc --port 80
  288. 287 kubectl describe svc nginxsvc
  289. 288 kubectl get endpoints
  290. 289 curl http://10.98.138.32
  291. 290 minikube ssh
  292. 291 kubectl edit svc nginxsvc
  293. 292 kubectl get svc
  294. 293 curl http://$(minikube ip):32000
  295. 294 minikube ip
  296. 295 curl http://192.168.39.192:32000
  297. 296 kubectl get pods
  298. 297 kubectl get svc
  299. 298 kubectl exec -it busybox2 -- cat /etc/resolv.conf
  300. 299 kubectl exec -it busybox2 -- nslookup nginxsvc
  301. 300 kubectl exec -it busybox2 -- nslookup myfirstnginx
  302. 301 minikube addons list
  303. 302 minikube addons enable ingress
  304. 303 history
  305. 304 history
  306. 305 history -d 304
  307. 306 history
  308. 307 minikube addons list
  309. 308 kubectl get deployments.apps
  310. 309 kubectl get svc
  311. 310 curl http://$(minikube ip):32000
  312. 311 vim nginxsvc-ingress.yaml
  313. 312 kubectl create -f nginxsvc-ingress.yaml
  314. 313 kubectl get ingress
  315. 314 minikube ip
  316. 315 sudo vim /etc/hosts
  317. 316 kubectl get ingress
  318. 317 curl nginxsvc.info
  319. 318 kubectl create deployment newdep --image=gcr.io/google-samples/hello-app:2.0
  320. 319 kubectl get deploy
  321. 320 kubectl get svc
  322. 321 kubectl expose deployment newdep --port=8080
  323. 322 vim nginxsvc-ingress.yaml
  324. 323 curl nginxsvc.info/hello
  325. 324 kubectl create -h
  326. 325 kubectl create ingress -h
  327. 326 ls
  328. 327 cd ..
  329. 328 git clone https://github.com/sandervanvugt/cka
  330. 329 cd cka
  331. 330 ls
  332. 331 vim nwpolicy-complete-example.yaml
  333. 332 kubectl explain networkpolicy.spec
  334. 333 vim nwpolicy-complete-example.yaml
  335. 334 kubectl create -f nwpolicy-complete-example.yaml
  336. 335 kubectl get nwp
  337. 336 kubectl get networkpolicy
  338. 337 kubectl describe networkpolicy
  339. 338 kubectl expose pod nginx --port=80
  340. 339 kubectl delete svc nginx
  341. 340 kubectl expose pod nginx --port=80
  342. 341 kubectl describe svc nginx
  343. 342 kubectl get pods -o wide --show-labels
  344. 343 kubectl describe svc nginx
  345. 344 kubectl get deploy
  346. 345 kubectl delete deploy nginx
  347. 346 kubectl describe svc nginx
  348. 347 vim nwpolicy-complete-example.yaml
  349. 348 kubectl get busybox
  350. 349 kubectl get pods
  351. 350 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  352. 351 vim nwpolicy-complete-example.yaml
  353. 352 kubectl get pods --show-labels
  354. 353 kubectl label pod busybox access=true
  355. 354 kubectl get pods --show-labels
  356. 355 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  357. 356 kubectl explain deployment.spec
  358. 357 kubectl explain deployment.spec.strategy
  359. 358 kubectl explain deployment.spec.strategy.rollingupdate
  360. 359 kubectl explain deployment.spec.strategy.rollingUpdate
  361. 360 cd ../ckad/
  362. 361 vim morevolumes.yaml
  363. 362 kubectl create -f morevolumes.yaml
  364. 363 kubectl describe pod morevol2
  365. 364 kubectl get pods
  366. 365 kubectl exec -it morevol2 -c centos1 -- touch /centos1/test
  367. 366 kubectl exec -it morevol2 -c centos2 -- ls /centos2/
  368. 367 ./countdown 14
  369. 368 ssh sander@192.168.50.136
  370. 369 ls
  371. 370 vim pv.yaml
  372. 371 kubectl explain persistentvolume.spec
  373. 372 q
  374. 373 kubectl explain pods.spec.volumes
  375. 374 kubectl create -f pv.yaml
  376. 375 kubectl get pv
  377. 376 vim pvc.yaml
  378. 377 kubectl create -f pvc.yaml
  379. 378 kubectl get pvc
  380. 379 kubectl get pv
  381. 380 kubectl get storageclass
  382. 381 kubectl describe pv pv-volume
  383. 382 kubectl describe pv pvc-6d1e86f1-05d0-43da-b793-9da7990b982d
  384. 383 vim pv-pod.yaml
  385. 384 kubectl create -f pv-pod.yaml
  386. 385 kubectl describe pod pv-pod
  387. 386 kubectl exec -it pv-pod -- touch /usr/share/nginx/html/hello
  388. 387 minikube ssh
  389. 388 history
  390. 389 kubectl get pv
  391. 390 cd ../cka
  392. 391 ls
  393. 392 vim pv-pvc-pod.yaml
  394. 393 kubectl create -f pv-pvc-pod.yaml
  395. 394 kubectl create ns myvol
  396. 395 kubectl create -f pv-pvc-pod.yaml
  397. 396 kubectl get pvc -n myvol
  398. 397 kubectl get pv
  399. 398 vim pv-pvc-pod.yaml
  400. 399 cd ../ckad/
  401. 400 ./countdown 5
  402. 401 ./countdown 12
  403. 402 vim variables
  404. 403 kubectl create cm -h | less
  405. 404 kubectl create cm variables --from-env-file=variables
  406. 405 kubectl describe cm variables
  407. 406 vim cm-test-pod.yaml
  408. 407 kubectl create -f cm-test-pod.yaml
  409. 408 kubectl logs po/test1
  410. 409 kubectl get pods
  411. 410 kubectl delete pod init-demo
  412. 411 kubectl create cm morevars --from-literal=VAR3=goat --from-literal=VAR4=cow
  413. 412 kubectl get cm/morevars
  414. 413 kubectl get cm/morevars -o yaml
  415. 414 kubectl get deploy
  416. 415 kubectl set -h | less
  417. 416 kubectl set env -h | less
  418. 417 kubectl get deploy
  419. 418 kubectl set env --from-configmap=morevars deploy/nginxsvc
  420. 419 kubectl set env -h | less
  421. 420 kubectl set env --from=configmap/morevars deploy/nginxsvc
  422. 421 kubectl exec -it nginxsvc-6865457fbc-956dt -- env
  423. 422 history
  424. 423 kubectl get pods --selector app=nginxsvc
  425. 424 vim nginx-custom-config.conf
  426. 425 kubectl create cm nginx-cm --from-file nginx-custom-config.conf
  427. 426 kubectl describe cm nginx-cm
  428. 427 vim nginx-cm.yml
  429. 428 kubectl create -f nginx-cm.yml
  430. 429 kubectl exec -it nginx-cm -- cat /etc/nginx/conf.d/default.conf
  431. 430 kubectl create deploy mydb --image=mariadb
  432. 431 kubectl get pods
  433. 432 kubectl delete pod mydb
  434. 433 kubectl logs mydb-6875fcdfbd-zpm5c
  435. 434 history
  436. 435 #kubectl create configmap --from-literal MYSQL_ROOT_PASSWORD=password mydb-cm && kubectl create deployment mydb --image=mariadb && kubectl set env --from=configmap/mydb-cm deploy/mydb
  437. 436 kubectl get deploy
  438. 437 kubectl delete deploy mydb
  439. 438 kubectl create configmap --from-literal MYSQL_ROOT_PASSWORD=password mydb-cm && kubectl create deployment mydb --image=mariadb && kubectl set env --from=configmap/mydb-cm deploy/mydb
  440. 439 kubectl get pods
  441. 440 #kubectl create secret generic my-secret --from-file=ssh-private-key=/home/student/.ssh/id_rsa --from-literal=passphrase=password
  442. 441 ssh-keygen
  443. 442 kubectl create secret generic my-secret --from-file=ssh-private-key=/home/student/.ssh/id_rsa --from-literal=passphrase=password
  444. 443 kubectl describe secrets my-secret
  445. 444 kubectl get secrets my-secret -o yaml
  446. 445 echo cGFzc3dvcmQ= | base64 -d
  447. 446 kubectl create secret generic secretstuff --from-literal=password=password --from-literal=user=linda
  448. 447 kubectl get secret secretstuff -o yaml
  449. 448 vim pod-secret.yaml
  450. 449 kubectl create -f pod-secret
  451. 450 kubectl create -f pod-secret.yaml
  452. 451 kubectl describe pod secretbox2
  453. 452 kubectl exec -it secretbox2 -- sh
  454. 453 kubectl create secret generic mysql --from-literal=password=root
  455. 454 vim pod-secret-as-var.yaml
  456. 455 kubectl create -f pod-secret-as-var.yaml
  457. 456 kubectl exec -it mymysql -- sh
  458. 457 ./countdown 12
  459. 458 vim mypod.yaml
  460. 459 kubectl apply -f mypod.yaml
  461. 460 kubectl get pods mypod -o yaml | less
  462. 461 kubectl exec -it mypod -- sh
  463. 462 vim mysa.yaml
  464. 463 kubectl create -f mysa.yaml
  465. 464 vim list-pods.yaml
  466. 465 kubectl apply -f list-pods.yaml
  467. 466 vim list-pods-mysa-binding.yaml
  468. 467 kubectl create -f list-pods-mysa-binding.yaml
  469. 468 vim mysapod.yaml
  470. 469 kubectl create -f mysapod.yaml
  471. 470 kubectl exec -it mysapod -- sh
  472. 471 vim busybox-ready.yaml
  473. 472 kubectl create -f busybox-ready.yaml
  474. 473 kubectl get pods
  475. 474 kubectl describe pods busybox-ready
  476. 475 kubectl edit pods busybox-ready
  477. 476 kubectl exec -it busybox-ready -- /bin/sh
  478. 477 kubectl get pods
  479. 478 vim nginx-probes.yaml
  480. 479 kubectl create -f nginx-probes.yaml
  481. 480 kubectl get pods
  482. 481 history
  483.  
Add Comment
Please, Sign In to add comment