sandervanvugt

cka day2 jan21

Jan 15th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.02 KB | None | 0 0
  1. 1 mkdir -p $HOME/.kube
  2. 2 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  3. 3 ls -l .kube/config
  4. 4 sudo chown $(id -u):$(id -g) $HOME/.kube/config
  5. 5 ls -l .kube/config
  6. 6 kubectl get nodes
  7. 7 kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
  8. 8 kubectl get pods -o kube-system
  9. 9 kubectl get pods -n kube-system
  10. 10 exit
  11. 11 history | less
  12. 12 kubectl get nodes
  13. 13 id
  14. 14 su -
  15. 15 git clone https://github.com/sandervanvugt/cka
  16. 16 cd cka
  17. 17 kubectl -h
  18. 18 kubectl completion -h
  19. 19 source <(kubectl completion bash)
  20. 20 kubectl create -h | less
  21. 21 kubectl create ns -h | less
  22. 22 kubectl create ns mynamespace
  23. 23 kubectl get get ns
  24. 24 kubectl get ns
  25. 25 kubectl run -h | less
  26. 26 kubectl run mypod --image=alpine --command -- sleep 3600
  27. 27 kubectl get pods -A
  28. 28 kubectl run mypod --image=alpine --command -- sleep 3600 -n mynamespace
  29. 29 kubectl run mypod --image=alpine -n mynamespace --command -- sleep 3600
  30. 30 kubectl get pods -A
  31. 31 history
  32. 32 kubectl get pods -n mynamespace -o yaml
  33. 33 kubectl create deployment nginx-ex5 --image=nginx --replicas=5
  34. 34 kubectl get all
  35. 35 ./counter.sh 15
  36. 36 vim mo.yaml
  37. 37 vim mo2.yaml
  38. 38 kubectl create -f mo2.yaml
  39. 39 kubectl get pods
  40. 40 kubectl describe pods init-demo
  41. 41 kubectl run -h | less
  42. 42 history
  43. 43 kubectl run mypod --image=alpine -n mynamespace --command -- sleep 3600 --dry-run
  44. 44 kubectl run mypodss --image=alpine -n mynamespace --dry-run --command -- sleep 3600
  45. 45 kubectl run mypodss --image=alpine -n mynamespace --dry-run=client -o yaml --command -- sleep 3600
  46. 46 kubectl run mypodss --image=alpine -n mynamespace --dry-run=client -o yaml --command -- sleep 3600 > mypodss.yaml
  47. 47 vim mypodss.yaml
  48. 48 ./counter.sh 4
  49. 49 vim wv.yaml
  50. 50 kubectl create -f wv.yaml
  51. 51 kubectl get pods
  52. 52 kubectl describe pods s3
  53. 53 vim ra.yaml
  54. 54 kubectl create -f ra.yaml
  55. 55 kubectl get pods
  56. 56 ./counter.sh 4
  57. 57 vim ih.yaml
  58. 58 kubectl create -f ih.yaml
  59. 59 kubectl get all --selector app=mydeploy
  60. 60 kubectl describe pod mydeploy-868547495d-5f7dg
  61. 61 kubectl create deploy -h
  62. 62 kubectl create deployment ex6 --image=busybox --replicas=3 --dry-run=client -o=yaml -- sleep 10000 > ex6.yaml
  63. 63 vim ex6.yaml
  64. 64 kubectl create -f ex6.yaml
  65. 65 kubectl get all --selector app=ex6
  66. 66 kubectl delete -f ex6.yaml
  67. 67 ./counter.sh 18
  68. 68 vim jp.yaml
  69. 69 sudo yum provides */etcdctl
  70. 70 sudo yum install etcd
  71. 71 sudo -i
  72. 72 ./counter.sh 4
  73. 73 vim jf.yaml
  74. 74 kubectl create -f jf.yaml
  75. 75 kubectl get pods
  76. 76 ./counter.sh 15
  77. 77 vim mo2.yaml
  78. 78 vim mo3.yaml
  79. 79 kubectl run auto-web --image=nginx --dry-run=client -o yaml > static
  80. 80 scp static root@worker2:/var/lib/kubelet/static/static.yaml
  81. 81 systemctl get pods
  82. 82 kubectl get pods -A
  83. 83 sudo -i
  84. 84 ./counter.sh 6
  85. 85 vim md.yaml
  86. 86 kubectl create ns myvol
  87. 87 kubectl create -f md.yaml
  88. 88 kubectl get pv
  89. 89 kubectl get pvc
  90. 90 kubectl get pvc -n myvol
  91. 91 kubectl get pv
  92. 92 history
  93. 93 su -
  94. 94 history
  95. 95 vim md.yaml
  96. 96 ip a
  97. 97 ./counter.sh 3
  98. 98 kubectl run -n run-once xxazz-pod --image=alpine --restart=Never -- sleep 3600
  99. 99 kubectl create ns run-once
  100. 100 kubectl run -n run-once xxazz-pod --image=alpine --restart=Never -- sleep 3600
  101. 101 kubectl get pods -n run-once -o yaml
  102. 102 ./counter.sh 5
  103. 103 cat jf.txt
  104. 104 vim jf.txt
  105. 105 kubectl create deploy newnginx --image=nginx:1.14
  106. 106 kubectl get all --selector app=newnginx
  107. 107 kubectl describe pod newnginx-b844f5586-s5q97
  108. 108 kubectl set -h | less
  109. 109 kubectl set image -h
  110. 110 kubectl set image deploy my-deploy nginx=nginx:latest --record
  111. 111 kubectl set image deploy newnginx nginx=nginx:latest --record
  112. 112 kubectl rollout history
  113. 113 kubectl rollout history deploy newnginx
  114. 114 kubectl rollout undo deployment newnginx
  115. 115 kubectl get pods -o wide
  116. 116 vim nwpolicy-complete-example.yaml
  117. 117 kubectl create -f nwpolicy-complete-example.yaml
  118. 118 kubectl get networkpolicy
  119. 119 kubectl expose pod nginx --port=80
  120. 120 kubectl get svc
  121. 121 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  122. 122 kubectl label pod busybox access=true
  123. 123 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  124. 124 ./counter.sh 10
  125. 125 kubectl create ns nwp-namespace
  126. 126 vim nwp-lab11-1.yaml
  127. 127 kubectl create -f nwp-lab11-1.yaml
  128. 128 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  129. 129 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  130. 130 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  131. 131 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default
  132. 132 kubectl expose pod nwp-nginx
  133. 133 kubectl expose pod nwp-nginx --port=80
  134. 134 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  135. 135 vim nwp-lab11-2.yaml
  136. 136 kubectl create -f nwp-lab11-2.yaml
  137. 137 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  138. 138 history
  139. 139 kubectl get pods -o wide
  140. 140 kubectl get nodes -o wide
  141. 141 kubectl describe node worker2.example.com
  142. 142 kubectl logs -h
  143. 143 kubectl describe node worker2.example.com | less
  144. 144 kubectl get pod -A -o wide
  145. 145 ./counter.sh 15
  146. 146 kubectl top -h
  147. 147 kubectl top pod
  148. 148 git clone https://github.com/kubernetes-sigs/metrics-server.git
  149. 149 kuebctl create -f metrics-server/manifests/base/
  150. 150 kubectl create -f metrics-server/manifests/base/
  151. 151 kubectl -n kube-system get pods
  152. 152 pwd
  153. 153 ls
  154. 154 cd metrics-server/
  155. 155 ls
  156. 156 cd manifests/
  157. 157 ls
  158. 158 cd base/
  159. 159 ls
  160. 160 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  161. 161 kubectl -n kube-system get pods
  162. 162 kubectl -n kube-system get deploy
  163. 163 kubectl -n kube-system edit deployment metrics-server
  164. 164 kubectl -n kube-system logs metrics-server-56c59cf9ff-wdswn
  165. 165 kubectl -n kube-system get pods
  166. 166 kubectl top pods
  167. 167 cd
  168. 168 git clone https://github.com/kubernetes-sigs/metrics-server
  169. 169 cd metrics-server/
  170. 170 ls
  171. 171 cd
  172. 172 cd cka
  173. 173 ./counter.sh 4
  174. 174 kubectl get pods -h
  175. 175 kubectl get pods -A --selector=app --sort-by=.medatada.name
  176. 176 kubectl get pods -A --sort-by=.medatada.name
  177. 177 kubectl get pods -A --sort-by={.spec.nodeName}
  178. 178 kubectl get pods -o wide --sort-by='{.spec.nodeName}' --all-namespaces
  179. 179 kubectl get pods -h
  180. 180 kubectl get pods nginx -o json | less
  181. 181 history
  182. 182 ./counter.sh 3
  183. 183 kubectl get pods
  184. 184 kubectl get deploy
  185. 185 kubectl delete mydeploy
  186. 186 kubectl delete deploy mydeploy
  187. 187 kubectl expose -h
  188. 188 kubectl expose deployment nginx-ex5 --port=80
  189. 189 kubectl get svc
  190. 190 kubectl describe svc nginx-ex5
  191. 191 ./counter.sh 12
  192. 192 ./counter.sh 19
  193. 193 vim jf4.yaml
  194. 194 cd ..
  195. 195 git clone https://github.com/sandervanvugt/ckad
  196. 196 cd ckad
  197. 197 vim variables
  198. 198 kubectl create cm variables --from-env-file=variables
  199. 199 kubectl describe cm variables
  200. 200 vim cm-test-pod.yaml
  201. 201 kubectl create -f cm-test-pod.yaml
  202. 202 kubectl logs test1
  203. 203 kubectl create cm morevars --from-literal=VAR3=planets --from-literal=VAR4=moon
  204. 204 kubectl get cm morevars
  205. 205 kubectl get cm morevars -o yaml
  206. 206 vim cm-test-pod.yaml
  207. 207 kubectl apply -f cm-test-pod.yaml
  208. 208 kubectl replace -f cm-test-pod.yaml
  209. 209 kubectl delete -f morevolumes.yaml
  210. 210 kubectl delete -f cm-test-pod.yaml
  211. 211 kubectl create -f cm-test-pod.yaml
  212. 212 kubectl logs test1
  213. 213 vim nginx-custom-config.conf
  214. 214 kubectl create cm nginx-cm --from-file nginx-custom-config.conf
  215. 215 kubectl describe cm nginx-cm
  216. 216 vim nginx-cm.yml
  217. 217 kubectl create -f nginx-cm.yml
  218. 218 kubectl exec -it nginx-cm /bin/bash
  219. 219 ./countdown 5
  220. 220 kubectl create -h | less
  221. 221 cd ../cka
  222. 222 vim ra4.yaml
  223. 223 kubectl explain daemonset.spec | less
  224. 224 vim ra4.yaml
  225. 225 kubectl create -f ra4.yaml
  226. 226 kubectl get ds --show-labels
  227. 227 kubectl get all --selector app=nginx=ds
  228. 228 kubectl get all --selector app=nginx-ds
  229. 229 kubectl get pods -o wide --selector app=nginx-ds
  230. 230 ./counter.sh 4
  231. 231 kubectl cordon -h
  232. 232 kubectl drain -h
  233. 233 kubectl drain worker2 --ignore-daemonsets --force
  234. 234 kubectl drain worker2.example.com --ignore-daemonsets --force
  235. 235 kubectl get pods -o wide -A | less
  236. 236 kubectl uncordon worker2.example.com
  237. 237 kubectl get nodes
  238. 238 vim breaklab.txt
  239. 239 kubectl edit node control.example.com
  240. 240 kubectl taint -h | less
  241. 241 sudo useradd anna
  242. 242 sudo cd /home/anna
  243. 243 pwd
  244. 244 su -
  245. 245 cd /home/student/
  246. 246 cd /home/anna
  247. 247 kubectl config set-credentials anna --client-certificate=/home/anna/.certs/anna.crt --client-key=/home/anna/.certs/anna.key
  248. 248 kubectl config set-context anna-context --cluster=kubernetes --user=anna
  249. 249 mkdir .kube
  250. 250 cp /etc/kubernetes/admin.conf /home/anna/.kube/config
  251. 251 sudo cp /etc/kubernetes/admin.conf /home/anna/.kube/config
  252. 252 vim .kube/config
  253. 253 sudo chown student:student .kube/config
  254. 254 vim .kube/config
  255. 255 pwd
  256. 256 cd
  257. 257 cd -
  258. 258 sudo chown -R anna:anna /home/anna/
  259. 259 exit
  260. 260 cd cka
  261. 261 vim podacessrole.yaml
  262. 262 kubectl create -f podacessrole.yaml
  263. 263 kubectl get roles
  264. 264 vim rolebinding.yaml
  265. 265 kubectl create -f rolebinding.yaml
  266. 266 kubectl run rolepod --image=nginx
  267. 267 kubectl get pods
  268. 268 su - anna
  269. 269 sudo passwd anna
  270. 270 su - anna
  271. 271 kubectl create sa whatever
  272. 272 kubectl create ns trouble
  273. 273 kubectl run nginx --image=nginx --namespace=trouble
  274. 274 kubectl delete ns trouble
  275. 275 kubectl get ns
  276. 276 kubectl get ns trouble -o json > trouble.json
  277. 277 kubectl get ns
  278. 278 kubectl get ns run-once -o json > trouble.json
  279. 279 vim trouble.json
  280. 280 kubectl replace --raw "/api/v1/namespaces/trouble/finalize" -f trouble.json
  281. 281 kubectl replace --raw "/api/v1/namespaces/run-once/finalize" -f trouble.json
  282. 282 kubectl get ns
  283. 283 ls
  284. 284 cd
  285. 285 rm .kube/config
  286. 286 kubectl get all
  287. 287 kubectl get-credential
  288. 288 cp /etc/kubernetes/admin.conf .kube/
  289. 289 sudo cp /etc/kubernetes/admin.conf .kube/
  290. 290 sudo cp /etc/kubernetes/admin.conf .kube/config
  291. 291 kubectl get all
  292. 292 sudo chown student:student .kube/config
  293. 293 kubectl get all
  294. 294 history
  295.  
Add Comment
Please, Sign In to add comment