Advertisement
sandervanvugt

CKAD day2 dec23

Dec 12th, 2023
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.65 KB | None | 0 0
  1. student@student-virtual-machine:~/ckad$ history
  2. 1 sudo apt install -y git
  3. 2 git clone https://github.com/sandervanvugt/ckad
  4. 3 cd ckad
  5. 4 ls
  6. 5 minikube start --vm-driver=docker --cni=calico
  7. 6 ls
  8. 7 history
  9. 8 kubectl get all
  10. 9 minikube ssh
  11. 10 kubectl get all
  12. 11 kubectl create deployment firstningx --image=nginx
  13. 12 kubectl get all
  14. 13 ./countdown 13
  15. 14 kubectl -h
  16. 15 kubectl create -h | less
  17. 16 kubectl create deployment -h | less
  18. 17 kubectl completion -h | less
  19. 18 source <(kubectl completion bash)
  20. 19 kubectl get all
  21. 20 history
  22. 21 cd
  23. 22 cd .kube/
  24. 23 ls
  25. 24 less config
  26. 25 kubectl config view
  27. 26 cd
  28. 27 cd ckad/
  29. 28 l
  30. 29 cd dockerfile/
  31. 30 ls
  32. 31 vim Dockerfile
  33. 32 sudo apt install -y vim
  34. 33 nano Dockerfile
  35. 34 docker build -t helloworld .
  36. 35 docker images
  37. 36 docker run helloworld
  38. 37 docker save helloworld halloworld.tar
  39. 38 docker save helloworld
  40. 39 docker save helloworld -o helloworld.tar
  41. 40 ls -l helloworld.tar
  42. 41 kubectl run -h | less
  43. 42 kubectl run mynginx --image=nginx
  44. 43 kubectl get pods
  45. 44 kubectl get pods mynginx -o yaml | less
  46. 45 kubectl describe pod mynginx | less
  47. 46 history
  48. 47 kubectl get pods
  49. 48 kubectl describe pod mybb
  50. 49 echo BONUSLAB: start busybox as a pod and make sure it runs the command "sleep 3600" while starting
  51. 50 kubectl run -h | less
  52. 51 kubectl run sleepybox --image=busybox -- sleep 3600
  53. 52 kubectl get pods
  54. 53 kubectl delete pod mybb
  55. 54 history
  56. 55 kubectl run bbox --image=busybox
  57. 56 kubectl get pods
  58. 57 kubectl run -h | less
  59. 58 kubectl run gobox --image=busybox --restart=never
  60. 59 kubectl run -h | less
  61. 60 kubectl run gobox --image=busybox --restart=Never
  62. 61 kubectl get pods
  63. 62 kubectl get pods gobox -o yaml | less
  64. 63 kubectl get pods bbox -o yaml | less
  65. 64 history
  66. 65 kubectl get pods bbox -o yaml | less
  67. 66 ls
  68. 67 cd ..
  69. 68 ls
  70. 69 kubectl run mynginx --image=nginx --dry-run=client -o yaml
  71. 70 kubectl run mynginx --image=nginx --dry-run=client -o yaml > mynginx.yaml
  72. 71 vim mynginx.yaml
  73. 72 kubectl explain pods
  74. 73 kubectl explain pods.spec | less
  75. 74 vim mynginx.yaml
  76. 75 kubectl create -f mynginx.yaml
  77. 76 kubectl delete pod mynginx
  78. 77 kubectl create -f mynginx.yaml
  79. 78 kubectl delete -f mynginx.yaml
  80. 79 kubectl apply -f mynginx.yaml
  81. 80 vim mynginx.yaml
  82. 81 kubectl apply -f mynginx.yaml
  83. 82 vim mynginx.yaml
  84. 83 kubectl apply -f mynginx.yaml
  85. 84 vim mynginx.yaml
  86. 85 kubectl replace -f mynginx.yaml
  87. 86 history
  88. 87 kubectl run bbbox --image=busybox -- sleep 3600 --dry-run=client -o yaml
  89. 88 kubectl get pods
  90. 89 kubectl describe pods bbbox
  91. 90 kubectl logs bbbox
  92. 91 kubectl delete pods bbbox
  93. 92 kubectl run bbbox --image=busybox --dry-run=client -o yaml -- sleep 2600
  94. 93 history
  95. 94 history | grep git
  96. 95 vim sidecar.yaml
  97. 96 kubectl apply -f sidecar.yaml
  98. 97 kubectl get pods
  99. 98 kubectl exec -it sidecar-pod -c sidecar -- /bin/bash
  100. 99 vim init-example1.yaml
  101. 100 kubectl apply -f init-example1.yaml
  102. 101 kubectl get pods
  103. 102 kubectl describe pod init-demo1
  104. 103 vim init-example2.yaml
  105. 104 kubectl apply -f init-example2.yaml
  106. 105 kubectl get pods
  107. 106 vim init-example2.yaml
  108. 107 history
  109. 108 kubectl get pods
  110. 109 kubectl get pods -A
  111. 110 kubectl get all
  112. 111 kubectl get all -A
  113. 112 kubectl get ns
  114. 113 kubectl create ns secret
  115. 114 kubectl get ns
  116. 115 kubectl run pod busybox -n secret -- sleep infinity
  117. 116 kubectl run pod --image=busybox secretbox -n secret -- sleep infinity
  118. 117 kubectl get all
  119. 118 kubectl get all -n secret
  120. 119 kubectl get pods
  121. 120 kubectl config set-context --current -n secret
  122. 121 kubectl config set-context --current --namespace=secret
  123. 122 kubectl get pods
  124. 123 kubectl config set-context --current -ns default
  125. 124 kubectl config set-context --current --namespace=default
  126. 125 kubectl get pods
  127. 126 kubectl config set-context -h | less
  128. 127 kubectl describe ns secret
  129. 128 kubectl get pods
  130. 129 kubectl exec -it bbox -- sh
  131. 130 kubectl exec -it sleepybox -- sh
  132. 131 kubectl get pods
  133. 132 kubectl exec -it firstningx-5f489b9c69-lbp9z -- sh
  134. 133 kubectl run faildb --image=mariadb
  135. 134 kubectl get pods
  136. 135 kubectl describe pod faildb
  137. 136 kubectl logs faildb
  138. 137 kubectl run -h | less
  139. 138 kubectl run dodb --image=mariadb --env=MARIADB_ROOT_PASSWORD=password
  140. 139 kubectl get pods
  141. 140 kubectl delete pod faildb
  142. 141 history
  143. 142 vim securitycontextdemo2.yaml
  144. 143 kubectl apply -f securitycontextdemo2.yaml
  145. 144 kubectl exec -it security-context-demo -- sh
  146. 145 cat securitycontextdemo2.yaml
  147. 146 kubectl explain pod.spec.securityContext | less
  148. 147 vim securitycontextdemo.yaml
  149. 148 kubectl apply -f securitycontextdemo.yaml
  150. 149 kubectl get pods
  151. 150 kubectl describe pod nginxsecure
  152. 151 history
  153. 152 kubectl create job onejob --image=busybox -- date
  154. 153 kubectl get jobs,pods
  155. 154 kubectl get jobs onejob -o yaml | less
  156. 155 kubectl delete job onejob
  157. 156 kubectl get jobs,pods
  158. 157 kubectl create job mynewjob --image=busybox --dry-run=client -o yaml -- sleep 5 > mynewjob.yaml
  159. 158 vim mynewjob.yaml
  160. 159 kubectl apply -f mynewjob.yaml
  161. 160 kubectl get jobs,pods
  162. 161 history
  163. 162 kubectl get jobs,pods
  164. 163 kubectl create cronjob -h | less
  165. 164 kubectl create cronjob runme --image=busybox --schedule="1/* * * * *" -- echo greetings from the cluster
  166. 165 kubectl create cronjob -h | less
  167. 166 kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" -- date
  168. 167 kubectl get cronjobs,jobs,pods
  169. 168 kubectl logs my-job-28373240-4pmqs
  170. 169 kubectl get cronjobs,jobs,pods
  171. 170 kubectl delete cronjobs.batch my-job
  172. 171 kubectl api-resources | less
  173. 172 history
  174. 173 git pull
  175. 174 cd labs/
  176. 175 ls
  177. 176 ./ckad-lab5-grade.sh
  178. 177 kubectl create cronjob
  179. 178 ./ckad-lab5-grade.sh
  180. 179 kubectl create cronjob hellojob --image busybox --schedule "*/5 * * * *" -- echo hello
  181. 180 ./ckad-lab5-grade.sh
  182. 181 cd ..
  183. 182 kubectl get cronjobs
  184. 183 kubectl create job --from=cronjob hellojob
  185. 184 kubectl create job testjob --from=cronjob hellojob
  186. 185 kubectl create job -h | less
  187. 186 kubectl create job testjob --from=hellojob
  188. 187 kubectl create job testjob --from=cronjob
  189. 188 kubectl create job testjob --from=cronjob/hellojob
  190. 189 vim frontend-resources.yaml
  191. 190 kubectl apply -f frontend-resources.yaml
  192. 191 kubectl get pods
  193. 192 kubectl describe pod frontend
  194. 193 ls
  195. 194 docker login
  196. 195 ls ~/.docker/config.json -l
  197. 196 kubectl create secret docker-registry dockercreds --from-file=.dockerconfigjson=/home/student/.docker/config.json
  198. 197 kubectl get secrets
  199. 198 kubectl describe secrets dockercreds
  200. 199 vim frontend-resources.yaml
  201. 200 kubectl apply -f frontend-resources.yaml
  202. 201 kubectl get pods
  203. 202 kubectl delete pod frontend
  204. 203 kubectl apply -f frontend-resources.yaml
  205. 204 kubectl get pods
  206. 205 kubectl describe pod frontend
  207. 206 kubectl get pods
  208. 207 history
  209. 208 kubectl get sa
  210. 209 kubectl get sa default -o yaml
  211. 210 kubectl patch serviceaccount default -p '{"imagePullSecrets":[{"name":"dockercreds"}]}'
  212. 211 kubectl get sa default -o yaml
  213. 212 kubectl run testpod --image=nginx:1.17
  214. 213 kubectl get pods testpod
  215. 214 ls
  216. 215 less RESOURCE.TXT
  217. 216 kubectl delete -f frontend-resources.yaml
  218. 217 vim frontend-resources.yaml
  219. 218 kubectl apply -f frontend-resources.yaml
  220. 219 kubectl get pods frontend
  221. 220 kubectl describe pods frontend
  222. 221 kubectl delete -f frontend-resources.yaml
  223. 222 labs/ckad-lab6-grade.sh
  224. 223 kubectl run lab6pod --image=nginx
  225. 224 labs/ckad-lab6-grade.sh
  226. 225 kubectl delete pod lab6pod
  227. 226 kubectl run lab6pod --image=nginx --dry-run=client -o yaml > lab6pod.yaml
  228. 227 vim lab6pod.yaml
  229. 228 kubectl apply -f lab6pod.yaml
  230. 229 labs/ckad-lab6-grade.sh
  231. 230 kubectl get pods lab6pod -o yaml
  232. 231 labs/ckad-lab6-grade.sh
  233. 232 kubectl apply -f lab6pod.yaml
  234. 233 vim busybox-ready.yaml
  235. 234 kubectl apply -f busybox-ready.yaml
  236. 235 kubectl get pods
  237. 236 kubectl describe pods busybox-ready
  238. 237 kubectl edit pods busybox-ready
  239. 238 kubectl exec -it busybox-ready -- touch /tmp/nothing
  240. 239 kubectl get pods
  241. 240 kubectl create deploy myweb --image=nginx --replicas=3
  242. 241 kubectl describe deployments.apps myweb
  243. 242 kubectl get deploy,rs,pods
  244. 243 kubectl delete pod myweb-9794cbc77-5nqhl
  245. 244 kubectl get deploy,rs,pods
  246. 245 cat redis-deploy.yaml
  247. 246 kubectl apply -f redis-deploy.yaml
  248. 247 cat redis-deploy.yaml
  249. 248 kubectl api-resources | less
  250. 249 vim redis-deploy.yaml
  251. 250 kubectl apply -f redis-deploy.yaml
  252. 251 kubectl api-versions
  253. 252 kubectl get deploy
  254. 253 kubectl edit deployments.apps redis
  255. 254 kubectl get deploy
  256. 255 kubectl get deploy --show-labels
  257. 256 kubectl get all --selector app=redis
  258. 257 kubectl delete rs redis-65fbbd8f94
  259. 258 kubectl get all --selector app=redis
  260. 259 kubectl scale deployment redis --replicas=2
  261. 260 kubectl get all --selector app=redis
  262. 261 kubectl create deploy nginx-lab7 --image=nginx --replicas=3
  263. 262 kubectl explain deploy.spec | less
  264. 263 kubectl explain deploy.spec.strategy | less
  265. 264 kubectl create deploy nginxup --image=nginx:1.14
  266. 265 kubectl get al --selector app=nginx
  267. 266 kubectl get all --selector app=nginx
  268. 267 kubectl get all --selector app=nginxup
  269. 268 kubectl scale deployment nginxup --replicas=5
  270. 269 kubectl set image deploy nginxup nginx=nginx:1.17
  271. 270*
  272. 271* kubectl get deploy nginxup -o yaml | le
  273. 272 kubectl set image deploy nginxup nginx=nginx:1.19
  274. 273 kubectl get all --selector app=nginxup
  275. 274 history
  276. 275 kubectl explain deploy.spec.strategy | less
  277. 276 kubectl explain deploy.spec.strategy.rollingUpdate | less
  278. 277 kubectl get deploy myweb -o yaml | less
  279. 278 kubectl get deployments.apps redis -o yaml | less
  280. 279 kubectl create deploy bluelabel --image=nginx
  281. 280 kubectl label deployments.apps bluelabel state=demo
  282. 281 kubectl get deploy --show-labels
  283. 282 kubectl get deploy --selector state=demo
  284. 283 kubectl get all --selector app=bluelabel --show-labels
  285. 284 kubectl describe deployments.apps bluelabel
  286. 285 kubectl describe pod bluelabel-59d6bcf7ff-5th78
  287. 286 kubectl label pods bluelabel-59d6bcf7ff-5th78 app-
  288. 287 kubectl get all | grep blue
  289. 288 kubectl get all --show-labels | grep blue
  290. 289 kubectl scale deployment bluelabel --replicas=4
  291. 290 kubectl set env deploy bluelabel type=blended
  292. 291 kubectl get all --selector app=bluelabel
  293. 292 vim rolling.yaml
  294. 293 kubectl apply -f rolling.yaml
  295. 294 kubectl rollout history deployment
  296. 295 kubectl edit deployments.apps rolling-nginx
  297. 296 kubectl rollout history deployment rolling-nginx
  298. 297 kubectl rollout history deployment rolling-nginx --revision=2
  299. 298 kubectl rollout history deployment rolling-nginx --revision=1
  300. 299 kubectl rollout undo deployment rolling-nginx --to-revision=1
  301. 300 kubectl get all
  302. 301 history
  303. 302 kubectl explain deploy.spec | less
  304. 303 kubectl edit deployments.apps bluelabel
  305. 304 kubectl get all --selector app=bluelabel
  306. 305 kubectl get pods -n kube-system
  307. 306 kubectl get svc -n kube-system
  308. 307 kubectl exec bluelabel-798bf758fc-n66bb -- cat /etc/resolv.conf
  309. 308 kubectl create deploy nginxsvc --image=nginx
  310. 309 kubectl scale deployment nginxsvc --replicas=3
  311. 310 kubectl expose deployment nginxsvc --port=80
  312. 311 kubectl get all --selector app=nginxsvc
  313. 312 kubectl get pods --selector app=nginxsvc
  314. 313 kubectl get pods --selector=app=nginxsvc -o wide
  315. 314 kubectl describe svc nginxsvc
  316. 315 kubectl get endpoints
  317. 316 kubectl get svc
  318. 317 curl 10.104.25.69
  319. 318 minikube ssh
  320. 319 minikube ip
  321. 320 kubectl edit svc nginxsvc
  322. 321 kubectl get svc
  323. 322 curl 192.168.49.2:32000
  324. 323 kubectl run testpod --image=busybox -- sleep 3600
  325. 324 kubectl describe pods testpod
  326. 325 kubectl delete pod testpod
  327. 326 kubectl run testpod --image=busybox -- sleep 3600
  328. 327 kubectl create ns other
  329. 328 kubectl run newginx -n other
  330. 329 kubectl run newginx --image=nginx -n other
  331. 330 kubectl expose -n other pod newginx --port=80
  332. 331 kubectl get svc -A
  333. 332 kubectl get svc,pods -n kube-system
  334. 333 kubectl exec -it testpod -- cat /etc/resolv.conf
  335. 334 kubectl exec -it testpod -- nslookup nginxsvc
  336. 335 kubectl exec -it testpod -- nslookup newginx
  337. 336 kubectl exec -it testpod -- nslookup newginx.other.svc.cluster.local
  338. 337 minikube addons list
  339. 338 minikube addons enable ingress
  340. 339 kubectl get ns
  341. 340 kubectl get all -n ingress-nginx
  342. 341 kubectl get all --selector app=nginxsvc
  343. 342 curl 192.168.49.2:32000
  344. 343 kubectl create ing -h | less
  345. 344 kubectl create ing nginxsvc-ingress --rule="/=nginxsvc:80" --rule="/hello=newdep:8080"
  346. 345 kubectl describe ing nginxsvc-ingress
  347. 346 sudo vim /etc/hosts
  348. 347 kubectl get ingress
  349. 348 curl nginxsvc.info
  350. 349 curl nginxsvc.info/hello
  351. 350 kubectl create deploy newdep --image=gcr.io/google-samples/hello-app:2.0
  352. 351 kubectl expose deployment newdep --port=8080
  353. 352 kubectl describe ing nginxsvc-ingress
  354. 353 curl nginxsvc.info/hello
  355. 354 history
  356.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement