Advertisement
sandervanvugt

CKA day2 june22

Jun 22nd, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.03 KB | None | 0 0
  1. student@control:~/cka$ history
  2. 1 sudo -i
  3. 2 ls -l .kube/config
  4. 3 kubectl get all
  5. 4 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
  6. 5 kubectl get ns
  7. 6 kubectl get all -n kube-system
  8. 7 kubectl get nodes
  9. 8 kubectl create deploy testginx --image=nginx --replicas=3
  10. 9 kubectl get pods -o wide
  11. 10 sudo -i
  12. 11 history
  13. 12 kubectl get pods -n kube-system
  14. 13 kubectl describe etcd-control
  15. 14 kubectl describe etcd-control -n kube-system
  16. 15 kubectl -n kube-system describe deploy
  17. 16 cd cka
  18. 17 git clone https://github.com/sandervanvugt/cka
  19. 18 cd cka/
  20. 19 vim kubeadm-config.yaml
  21. 20 kubectl version
  22. 21 vim kubeadm-config.yaml
  23. 22 source <(kubectl completion bash)
  24. 23 kubectl create ns mynamespace
  25. 24 kubectl run mypod --image=alpine -n mynamespace -- sleep 3600
  26. 25 kubectl get pods -n mynamespace
  27. 26 kubectl get pods -n mynamespace -o yaml
  28. 27 sudo -i
  29. 28 kubectl get pods -n kube-system
  30. 29 kubectl get pods -n kube-system -o wide
  31. 30 kubectl get nodes
  32. 31 kubectl get all -n kube-system
  33. 32 kubectl describe daemonsets.apps calico-node
  34. 33 kubectl describe daemonsets.apps calico-node -n kube-system
  35. 34 kubectl get pods -n kube-system
  36. 35 kubectl describe -n kube-system pod calico-node-8kxht
  37. 36 kubectl logs -n kube-system calico-node-m4mj5
  38. 37 history
  39. 38 ./counter.sh 12
  40. 39 ./counter.sh 5
  41. 40 vim multi.yaml
  42. 41 kubectl create -f multi.yaml
  43. 42 kubectl get pods
  44. 43 kubectl describe pods three-containers
  45. 44 kubectl delete -f multi.yaml
  46. 45 vim multi.yaml
  47. 46 kubectl create -f multi.yaml
  48. 47 kubectl get pods
  49. 48 cat multi.yaml
  50. 49 vim wg.yaml
  51. 50 kubectl create -f wg.yaml
  52. 51 kubectl get pods
  53. 52 cat wg.yaml
  54. 53 ./counter.sh 18
  55. 54 kubectl create quota -h | less
  56. 55 kubectl set resources -h | less
  57. 56 ./counter.sh 7
  58. 57 cd
  59. 58 kubectl create ns restricted
  60. 59 kubectl get ns
  61. 60 kubectl create quota qtest --hard pods=3,cpu=100m,memory=500Mi -n restricted
  62. 61 kubectl describe quota -n restricted
  63. 62 kubectl create deploy rginx --image=nginx --replicas=3 -n restricted
  64. 63 kubectl describe quota -n restricted
  65. 64 kubectl get all -n restricted
  66. 65 kubectl describe deployments.apps rginx -n restricted
  67. 66 kubectl describe deployments.apps rginx-95d54596d -n restricted
  68. 67 kubectl describe -n restricted replicasets.apps rginx-95d54596d
  69. 68 kubectl set resources deploy rginx --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi -n restricted
  70. 69 kubectl get all -n restricted
  71. 70 kubectl describe -n restricted quota
  72. 71 kubectl -n restricted edit quota
  73. 72 kubectl describe -n restricted quota
  74. 73 kubectl edit deployments.apps -n restricted rginx
  75. 74 kubectl describe -n restricted quota
  76. 75 kubectl run -n restricted busybox -- sleep 3600
  77. 76 kubectl run bbox -n restricted --image=busybox -- sleep 3600
  78. 77 kubectl run -h
  79. 78 kubectl -n restricted get pods -o yaml
  80. 79 kubectl run bbox -n restricted --image=busybox --dry-run=client -o yaml -- sleep 3600 > bbox.yaml
  81. 80 vim bbox.yaml
  82. 81 kubectl create -f bbox.yaml
  83. 82 vim bbox.yaml
  84. 83 kubectl explain pod.spec --recursive | less
  85. 84 kubectl explain pod.spec | less
  86. 85 vim bbox.yaml
  87. 86 kubectl create -f bbox.yaml
  88. 87 history
  89. 88 cka/counter.sh 8
  90. 89 cka/counter.sh 12
  91. 90 vim rs.yaml
  92. 91 kubectl api-resources | less
  93. 92 vim rs.yaml
  94. 93 kubectl create -f rs.yaml
  95. 94 kubectl get pvc,pv
  96. 95 cd cka/
  97. 96 vim nwpolicy-complete-example.yaml
  98. 97 kubectl create -f nwpolicy-complete-example.yaml
  99. 98 kubectl get all
  100. 99 kubectl get nwp
  101. 100 kubectl get networkpolicy
  102. 101 kubectl expose pod nginx --port=80
  103. 102 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  104. 103 kubectl get pods --show-labels
  105. 104 kubectl get networkpolicy -o yaml
  106. 105 kubectl label pod busybox access=true
  107. 106 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  108. 107 rm ~/.kube/config
  109. 108 kubectl get all
  110. 109 ls ~/.kube/
  111. 110 sudo cp -i /etc/kubernetes/admin.conf ~/.kube/config
  112. 111 ls -l ~/.kube
  113. 112 kubectl get all
  114. 113 sudo chown student:student ~/.kube/config
  115. 114 kubectl get all
  116. 115 kubectl get pods -n kube-system
  117. 116 ps aux | grep apiserver
  118. 117 kubectl config view
  119. 118 less ~/.kube/config
  120. 119 history
  121. 120 sudo -i
  122. 121 exit
  123. 122 vim wg.yaml
  124. 123 kubectl create -f wg.yaml
  125. 124 kubectl get svc
  126. 125 kubectl get pods -n nwp-namespace
  127. 126 kubectl exec -it nwp-busybox -n nwp-namespace -- curl 10.98.168.234
  128. 127 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 10.98.168.234
  129. 128 kubectl get pods
  130. 129 kubectl exec -it busybox -- wget --spider --timeout=1 10.98.168.234
  131. 130 kubectl exec -it busybox -- wget --spider --timeout=1 10.96.137.90
  132. 131 cp wg.yaml wgnwp.yaml
  133. 132 vim wgnwp.yaml
  134. 133 kubectl get networkpolicy
  135. 134 kubectl delete -f wgnwp.yaml
  136. 135 kubectl exec -it busybox -- wget --spider --timeout=1 10.96.137.90
  137. 136 kubectl exec -it busybox -- wget --spider --timeout=1 10.98.168.234
  138. 137 cd cka/
  139. 138 vim nwp-lab11-1.yaml
  140. 139 vim nwp-lab11-2.yaml
  141. 140 vim ../wgnwp.yaml
  142. 141 vim nwp-lab11-2.yaml
  143. 142 vim ../wgnwp.yaml
  144. 143 kubectl create -f nwp-lab11-2.yaml
  145. 144 kubectl get networkpolicy
  146. 145 kubectl create -f nwp-lab11-2.yaml
  147. 146 kubectl exec -it busybox -- wget --spider --timeout=1 10.98.168.234
  148. 147 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 10.98.168.234
  149. 148 kubectl get svc
  150. 149 curl 10.96.137.90
  151. 150 source <(kubectl completion bash)
  152. 151 kubectl describe svc nginx
  153. 152 kubectl delete networkpolicy access-nginx
  154. 153 kubectl delete networkpolicies deny-from-other-namespaces
  155. 154 curl 10.96.137.90
  156. 155 kubectl get svc
  157. 156 kubectl edit svc nginx
  158. 157 kubectl get svc
  159. 158 kubectl edit svc nginx
  160. 159 kubectl get svc
  161. 160 kubectl get networkpolicy
  162. 161 kubectl get networkpolicy -A
  163. 162 kubectl get networkpolicies -A
  164. 163 ip a | less
  165. 164 kubectl get svc,pods --show-labels
  166. 165 kubectl describe svc nginx
  167. 166 kubectl edit svc nginx
  168. 167 kubectl describe svc nginx
  169. 168 history
  170. 169 ./counter.sh 5
  171. 170 kubectl -h | less
  172. 171 kubectl drain -h | less
  173. 172 kubectl cordon -h | less
  174. 173 kubectl drain worker2
  175. 174*
  176. 175 kubectl get nodes
  177. 176 kubectl get pods -A -o wide
  178. 177 kubectl uncordon worker2
  179. 178 kubectl get nodes
  180. 179 kubectl -h | less
  181. 180 kubectl get pods -o wide
  182. 181 kubectl get deploy
  183. 182 kubectl scale deployment testginx --replicas=4
  184. 183 kubectl get pods -o wide
  185. 184 ./counter.sh 20
  186. 185 kubectl top pods
  187. 186 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  188. 187 kubectl top pods
  189. 188 kubectl get pods -n kube-system
  190. 189 kubectl describe -n kube-system pod metrics-server-678f4bf65b-htllm
  191. 190 kubectl logs -n kube-system metrics-server-678f4bf65b-htllm
  192. 191 kubectl -n kube-system edit deployments.apps metrics-server
  193. 192 kubectl get pods -n kube-system
  194. 193 kubectl -n kube-system edit deployments.apps metrics-server
  195. 194 kubectl get pods -n kube-system
  196. 195 kubectl top pods
  197. 196 kubectl top pods --sort-by=cpu
  198. 197 ./counter.sh 5
  199. 198 kubectl taint -h | less
  200. 199 kubectl edit node control
  201. 200 kubectl create ttest --image=nginx --replicas=3
  202. 201 kubectl create deploy ttest --image=nginx --replicas=3
  203. 202 kubectl get pods -o wide
  204. 203 kubectl run nametest --image=nginx --dry-run=client -o yaml > nametest.yaml
  205. 204 kubectl explain pod.spec | less
  206. 205 vim nametest.yaml
  207. 206 kubectl create -f nametest.yaml
  208. 207 kubectl get pods
  209. 208 kubectl describe pod nametest
  210. 209 kubectl get poids
  211. 210 kubectl get pods
  212. 211 kubectl create -f nametest.yaml
  213. 212 kubectl describe pod nametest
  214. 213 kubectl label nodes worker2 disktype=ssd
  215. 214 vim selector-pod.yaml
  216. 215 kubectl create -f selector-pod.yaml
  217. 216 kubectl get pods -o wide
  218. 217 kubectl taint nodes worker1 example-key=value1:NoSchedule
  219. 218 kubectl describe nodes worker1
  220. 219 kubectl create deploy nginx-taint --image=nginx
  221. 220 kubectl scale deployment nginx-taint --replicas=3
  222. 221 kubectl get pods -o wide
  223. 222 vim taint-toleration.yaml
  224. 223 kubectl create -f taint-toleration.yaml
  225. 224 kubectl get pods -o wide | grep tolera
  226. 225 vim counter.sh
  227. 226 ./counter.sh 20
  228. 227 vim rs.yaml
  229. 228 kubectl get nodes --show-labels
  230. 229 kubectl create -f rs.yaml
  231. 230 vim rs.yaml
  232. 231 kubectl create -f rs.yaml
  233. 232 kubectl get pods -o wide | grep rsn
  234. 233 kubectl get nodes
  235. 234 grep -i nodename *
  236. 235 vim nametest.yaml
  237. 236 kubectl create -f nametest.yaml
  238. 237 kubectl get pods nametest2
  239. 238 kubectl describe pod nametest2
  240. 239 kubectl get pods nametest2 -o yaml | less
  241. 240 kubectl get nodes
  242. 241 kubectl describe node worker1 | less
  243. 242 vim counter.sh
  244. 243 ./counter.sh 5
  245. 244 kubectl get ds -A
  246. 245 kubectl create deploy dsginx --image=nginx --dry-run=client -o yaml > dsginx.yaml
  247. 246 vim dsginx.yaml
  248. 247 kubectl create -f dsginx.yaml
  249. 248 vim dsginx.yaml
  250. 249 kubectl create -f dsginx.yaml
  251. 250 kubectl get ds
  252. 251 kubectl get all --selector app=dsginx
  253. 252 kubectl get pods --selector app=dsginx -o wide
  254. 253 kubectl get nodes
  255. 254 kubectl edit node worker1
  256. 255 kubectl get pods --selector app=dsginx -o wide
  257. 256 kubectl create deploy upgrademe --image=nginx:1.14 --replicas=3
  258. 257 kubectl get all --selector app=upgrademe
  259. 258 kubectl get deployments.apps upgrademe -o yaml | less
  260. 259 kubectl get all --selector app=upgrademe
  261. 260 kubectl set image --help | less
  262. 261 #kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
  263. 262 kubectl set image deployment/upgrademe nginx=nginx:latest
  264. 263 kubectl get all --selector app=upgrademe
  265. 264 kubectl rollout history deployment upgrademe
  266. 265 kubectl rollout undo deployment upgrademe
  267. 266 kubectl get all --selector app=upgrademe
  268. 267 vim counter.sh
  269. 268 ./counter.sh 26
  270. 269 sudo -i
  271. 270 ls -lrt
  272. 271 cat nametest.yaml
  273. 272 kubectl get pods
  274. 273 vim counter.sh
  275. 274 ./counter.sh 8
  276. 275 sudo ETCDCTL_API=3 etcdctl snapshot save snapshot.db --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key
  277. 276 sudo apt install etcd-client
  278. 277 sudo ETCDCTL_API=3 etcdctl snapshot save snapshot.db --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key
  279. 278 ls -l snapshot.db
  280. 279 sudo ETCDCTL_API=3 etcdctl snapshot save snapshot2.db --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key --endpoints=https://127.0.0.1:2379
  281. 280 ls -l snap*
  282. 281 ps aux | grep apiserver
  283. 282 cd /etc/kubernetes/pki/etcd/
  284. 283 ls
  285. 284 sudo ETCDCTL_API=3 etcdctl get / --prefix --keys-only --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key --endpoints=https://127.0.0.1:2379
  286. 285 sudo ETCDCTL_API=3 etcdctl get / --prefix --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key --endpoints=https://127.0.0.1:2379
  287. 286 cd
  288. 287 cd cka/
  289. 288 vim counter.sh
  290. 289 ./counter.sh 10
  291. 290 sudo useradd -m -s /bin/bash -G sudo anna
  292. 291 sudo passwd anna
  293. 292 su - anna
  294. 293 vim podaccessrole.yaml
  295. 294 kubectl create -f podaccessrole.yaml
  296. 295 vim rolebinding.yaml
  297. 296 kubectl create -f rolebinding.yaml
  298. 297 kubectl run rolepod --image=nginx
  299. 298 kubectl get pods
  300. 299 su - anna
  301. 300 history
  302.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement