Advertisement
sandervanvugt

CKA oct 23

Oct 20th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.24 KB | None | 0 0
  1. student@control:~/cka$ history
  2. 1 free -m
  3. 2 lscspu
  4. 3 lscpu
  5. 4 df -h
  6. 5 sudo apt install vim git -y
  7. 6 git clone https://github.com/sandervanvugt/cka
  8. 7 cd cka
  9. 8 ls
  10. 9 ./setup-container.sh
  11. 10 ./setup-kubetools.sh
  12. 11 sudo ./setup-kubetools.sh
  13. 12 history
  14. 13 sudo kubeadm init
  15. 14 mkdir -p $HOME/.kube
  16. 15 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  17. 16 sudo chown $(id -u):$(id -g) $HOME/.kube/config
  18. 17 kubectl get all
  19. 18 kubectl get pods -n kube-system
  20. 19 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
  21. 20 kubectl get ns
  22. 21 kubectl get all -n kube-system
  23. 22 kubectl get nodes
  24. 23 history
  25. 24 kubectl get all -n kube-system
  26. 25 history
  27. 26 kubectl create deploy testdeploy --image=nginx --replicas=3
  28. 27 sleep 10; kubectl get pods -o wide
  29. 28 kubectl run task2pod --image=nginx -n mynamespace -- sleep 3600
  30. 29 kubectl create ns mynamespace
  31. 30 kubectl run task2pod --image=nginx -n mynamespace -- sleep 3600
  32. 31 kubectl delete pod task2pod
  33. 32 kubectl get pods
  34. 33 source <(kubectl completion bash)
  35. 34 kubectl delete pod task2pod -n mynamespace
  36. 35 kubectl run task2pod --image=alpine -n mynamespace -- sleep 3600
  37. 36 kubectl get pods -n mynamespace
  38. 37 kubectl get pods -n mynamespace -o yaml | less
  39. 38 history
  40. 39 kubectl run task3pod --image=nginx --image=redis --image=busybox
  41. 40 kubectl get pods
  42. 41 kubectl get pods task3pod -o yaml | less
  43. 42 kubectl describe pod task3pod
  44. 43 kubectl delete pod task3pod
  45. 44 history
  46. 45 kubectl run task3pod --image=busybox --dry-run=client -o yaml -- sleep infinity
  47. 46 kubectl run task3pod --image=busybox --dry-run=client -o yaml -- sleep infinity > task3.yaml
  48. 47 vim task3.yaml
  49. 48 kubectl apply -f task3.yaml
  50. 49 kubectl get pods
  51. 50 cat task3.yaml
  52. 51 history
  53. 52 cat task3.yaml
  54. 53 history
  55. 54 vim task4pod.yaml
  56. 55 vim md4.yaml
  57. 56 kubectl apply -f md4.yaml
  58. 57 kubectl get pods
  59. 58 vim md4.yaml
  60. 59 history
  61. 60 kubectl create quota --help | less
  62. 61 kubectl create ns limited
  63. 62 kubectl create quota qtest --hard pods=3,cpu=100m,memory=500Mi --namespace limited
  64. 63 kubectl get quota
  65. 64 kubectl get quota -n limited
  66. 65 kubectl describe ns limited
  67. 66 kubectl create deploy nginx --image=nginx --replicas=3 -n limited
  68. 67 kubectl get all -n limited
  69. 68 kubectl describe rs -n limited nginx-7854ff8877
  70. 69 kubectl set resources --help | less
  71. 70 kubectl set resources deploy nginx -n limited --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi
  72. 71 history
  73. 72 kubectl get all -n limited
  74. 73 kubectl describe ns limited
  75. 74 kubectl edit -n limited quota
  76. 75 kubectl get all -n limited
  77. 76 kubectl scale -n limited deployment nginx --replicas=3
  78. 77 kubectl get all -n limited
  79. 78 kubectl scale -n limited deployment nginx --replicas=4
  80. 79 kubectl get all -n limited
  81. 80 kubectl scale -n limited deployment nginx --replicas=3
  82. 81 history
  83. 82 kubectl config view
  84. 83 history
  85. 84 less ~/.kube/config
  86. 85 kubectl config view
  87. 86 kubectl config --help
  88. 87 kubectl config current-context
  89. 88 kubectl config set-context --current --namespace=limited
  90. 89 kubectl config current-context
  91. 90 kubectl config view
  92. 91 kubectl config set-context --current --namespace=default
  93. 92 kubectl config view
  94. 93 history
  95. 94 kubectl create deploy nginxex5 --image=nginx --replicas=2
  96. 95 kubectl scale deployment nginxex5 --replicas=4
  97. 96 vim resize_pvc.yaml
  98. 97 history
  99. 98 vim nwpolicy-complete-example.yaml
  100. 99 kubectl apply -f nwpolicy-complete-example.yaml
  101. 100 kubectl expose pod nginx --port=80
  102. 101 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  103. 102 kubectl label pod busybox access=true
  104. 103 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  105. 104 kubectl create ns nwp-namespace
  106. 105 vim nwp-lab9-1.yaml
  107. 106 kubectl apply -f nwp-lab9-1.yaml
  108. 107 kubectl expose pod nwp-nginx --port=80
  109. 108 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  110. 109 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  111. 110 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx.default.svc.cluster.local
  112. 111 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  113. 112 vim nwp-lab9-2.yaml
  114. 113 kubectl apply -f nwp-lab9-2.yaml
  115. 114 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  116. 115 kubectl create deploy busybox --image=busybox -- sleep 36000
  117. 116 kubectl exec -it busybox-6b56f788cb-qsgj2 -- wget --spider --timeout=1 nwp-nginx
  118. 117 kubectl delete -f nwp-lab9-2.yaml
  119. 118 history
  120. 119 vim selector-pod.yaml
  121. 120 kubectl apply -f selector-pod.yaml
  122. 121 kubectl get pods
  123. 122 vim selector-pod.yaml
  124. 123 kubectl apply -f selector-pod.yaml
  125. 124 kubectl get all
  126. 125 kubectl describe pod nginxxx
  127. 126 kubectl label nodes worker2 disktype=ssd
  128. 127 kubectl get pods
  129. 128 kubectl edit nodes control
  130. 129 kubectl get pods -n kube-system -o wide
  131. 130 kubectl -n kube-system get daemonsets.apps calico-node -o yaml | less
  132. 131 kubectl taint nodes worker1 example-key=value1:NoSchedule
  133. 132 kubectl describe nodes worker1 | less
  134. 133 kubectl create deploy nginx-taint --image=nginx --replicas=3
  135. 134 kubectl get pods -o wide
  136. 135 vim taint-toleration.yaml
  137. 136 kubectl apply -f taint-toleration.yaml
  138. 137 kubectl get pods
  139. 138 kubectl get pods -o wide
  140. 139 kubectl taint nodes worker1 example-key=value1:NoSchedule-
  141. 140 kubectl get pods -o wide
  142. 141 kubectl scale deployment nginx-taint --replicas=1
  143. 142 kubectl scale deployment nginx-taint --replicas=3
  144. 143 kubectl get pods -o wide
  145. 144 history
  146. 145 lsns
  147. 146 sudo -i
  148. 147 minikube stop
  149. 148 echo those who joined late: we're doing lab 6 now, please have a look at the slides and start working :-)
  150. 149 echo 'those who joined late: we're doing lab 6 now, please have a look at the slides and start working :-)'
  151. 150 echo 'those who joined late: we are doing lab 6 now, please have a look at the slides and start working :-)'
  152. 151 nano kd.yaml
  153. 152 vim kd.yaml
  154. 153 kubectl aply -f kd.yaml
  155. 154 kubectl apply -f kd.yaml
  156. 155 kubectl get all --selector app=nginx-sidecar
  157. 156 kubectl describe pod task6pod
  158. 157 kubectl delete -f kd.yaml
  159. 158 vim kd.yaml
  160. 159 kubectl apply -f kd.yaml
  161. 160 vim kd.yaml
  162. 161 kubectl apply -f kd.yaml
  163. 162 kubectl get all --selector app=nginx-sidecar
  164. 163 kubectl get all -o wide --selector app=nginx-sidecar
  165. 164 curl 192.168.29.23:30000
  166. 165 curl 192.168.29.22:30000
  167. 166 curl 192.168.29.21:30000
  168. 167 history
  169. 168 cat kd.yaml
  170. 169 kubectl get all -n kube-system
  171. 170 kubectl get -n kube-system pod calico-kube-controllers-7ddc4f45bc-w9bcs -o yaml | less
  172. 171 kubectl get clusterroles
  173. 172 kubectl get clusterroles | grep calico
  174. 173 kubectl get clusterroles calico-kube-controllers -o yaml | less
  175. 174 kubectl get clusterrolebindings
  176. 175 kubectl get clusterrolebindings | grep calico
  177. 176 kubectl get clusterrolebindings calico-kube-controllers -o yaml | less
  178. 177 kubectl create role --help | less
  179. 178 kubectl create rolebinding --help | less
  180. 179 kubectl get clusterroles
  181. 180 kubectl get clusterroles | grep -v system
  182. 181 kubectl describe clusterroles edit
  183. 182 history
  184. 183 kubectl create serviceaccount test
  185. 184 kubectl get sa
  186. 185 kubectl get pods
  187. 186 kubectl get pods task3pod -o yaml
  188. 187 history\
  189. 188 history
  190. 189 kubectl create ns roles
  191. 190 kubectl create role --help
  192. 191 kubectl create role viewers --verb=get --verb=list --verb=watch --resource=pods -n roles
  193. 192 kubectl create sa viewers -n roles
  194. 193 kubectl create rolebinding --help
  195. 194 kubectl create rolebinding -n roles viewersbinding --role=viewers --serviceaccount=viewers
  196. 195 kubectl create rolebinding -n roles viewersbinding --role=viewers --serviceaccount=roles:viewers
  197. 196 kubectl create pod -n roles viewpod --dry-run=client -o yaml > viewpod.yaml
  198. 197 kubectl run -n roles viewpod --dry-run=client -o yaml > viewpod.yaml
  199. 198 kubectl run -n roles viewpod --image=nginx --dry-run=client -o yaml > viewpod.yaml
  200. 199 vim viewpod.yaml
  201. 200 kubectl create -f viewpod.yaml
  202. 201 history
  203. 202 kubectl create deploy nginxdaemon --image=nginx --dry-run=client -o yaml > nginxdaemon.yaml
  204. 203 vim nginxdaemon.yaml
  205. 204 kubectl apply -f nginxdaemon.yaml
  206. 205 kubectl get all --selector app=nginxdaemon
  207. 206 history
  208. 207 cat viewpod.yaml
  209. 208 kubectl get nodes
  210. 209 kubectl get pods -o wide
  211. 210 kubectl drain worker1
  212. 211 kubectl drain worker1 --force --ignore-daemonsets
  213. 212 kubectl get pods -o wide
  214. 213 kubectl get nodes worker1 -o yaml | less
  215. 214 kubectl uncordon worker1
  216. 215 kubectl get pods -o wide
  217. 216 kubectl get nodes
  218. 217 kubectl top
  219. 218 kubectl top pod
  220. 219 kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  221. 220 kubectl -n kube-system get pods
  222. 221 kubectl -n kube-system describe pods metrics-server-fbb469ccc-95xx8
  223. 222 kubectl -n kube-system logs metrics-server-fbb469ccc-95xx8
  224. 223 kubectl -n kube-system edit deploy metrics-server
  225. 224 kubectl get pods -n kube-system
  226. 225 kubectl top pods
  227. 226 kubectl top nodes
  228. 227 history
  229. 228 kubectl -n kube-system edit deploy metrics-server
  230. 229 kubectl top pods --sort-by='cpu' --no-header | head -1 | awk '{ print $1 }'
  231. 230 kubectl top pods --sort-by='cpu' --no-headers | head -1 | awk '{ print $1 }'
  232. 231 kubectl top pods --sort-by='cpu' --no-headers | head -1 | awk '{ print $1 }' > /var/cpu-pods.txt
  233. 232 kubectl top pods
  234. 233 kubectl top pods | sort -k 2
  235. 234 sudo -i
  236. 235 sudo vim /var/lib/kubelet/config.yaml
  237. 236 kubectl run auto-web --image=nginx --dry-run=client -o yaml
  238. 237 kubectl get pods
  239. 238 history
  240. 239 sudo apt install etcd-client
  241. 240 sudo etcdctl --help
  242. 241 sudo ETCDCTL_API=3 etcdctl --help
  243. 242 ps aux | grep etcd
  244. 243 sudo ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key get / --prefix --keys-only
  245. 244 sudo ETCDCTL_API=3 etcdctl --endpoints=localhost:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key snapshot save /tmp/etcdbackup.db
  246. 245 sudo ETCDCTL_API=3 etcdctl --write-out=table snapshot status /tmp/etcdbackup.db
  247. 246 sudo cp /tmp/etcdbackup.db /tmp/etcdbackup.db.2
  248. 247 history
  249. 248 kubectl get deploy
  250. 249 kubectl delete --all deploy
  251. 250 cd /etc/kubernetes/manifests/
  252. 251 ls
  253. 252 sudo mv * ..
  254. 253 sudo crictl ps
  255. 254 sudo ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcdbackup.db --data-dir /var/lib/etcd-backup
  256. 255 sudo ls -l /var/lib/etcd-backup
  257. 256 sudo ls -l /var/lib/etcd-backup/member
  258. 257 vim ../etcd.yaml
  259. 258 sudo vim ../etcd.yaml
  260. 259 sudo mv ../*.yaml .
  261. 260 sudo crictl ps
  262. 261 kubectl get deploy -A
  263. 262 kubectl get deploy
  264. 263 history
  265. 264 cd
  266. 265 ls
  267. 266 tar xvf helm-v3.13.1-linux-amd64.tar.gz
  268. 267 sudo mv linux-amd64/helm /usr/local/bin/
  269. 268 helm
  270. 269 helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace
  271. 270 kubectl get pods -n ingress-nginx
  272. 271 kubectl create deploy nginxsvc --image=nginx --port=80
  273. 272 kubectl expose deploy nginxsvc
  274. 273 kubectl get all --selector app=nginxsvc
  275. 274 kubectl create ing nginxsvc --class=nginx --rule=nginxsvc.info/*=nginxsvc:80
  276. 275 kubectl port-forward -n ingress-nginx svc/ingress-nginx-controller 8080:80
  277. 276 bg
  278. 277 sudo vim /etc/hosts
  279. 278 curl nginxsvc.info:8080
  280. 279 kubectl edit svc nginxsvc
  281. 280 curl nginxsvc.info:8080
  282. 281 kubectl describe ing nginxsvc
  283. 282 kubectl describe svc nginxsvc
  284. 283 kubectl edit svc nginxsvc
  285. 284 kubectl describe ing nginxsvc
  286. 285 kubectl run faildb --image=mariadb
  287. 286 kubectl logs faildb
  288. 287 kubectl logs faildb > /tmp/mariadb-error.txt
  289. 288 cd cka/
  290. 289 vim pod-with-node-a
  291. 290 vim pod-with-node-affinity.yaml
  292. 291 vim pod-with-node-antiaffinity.yaml
  293. 292 kubectl get nodes --show-labels
  294. 293*
  295. 294 vim pod-with-node-antiaffinity.yaml
  296. 295 kubectl apply -f pod-with-node-antiaffinity.yaml
  297. 296 kubect get pods -o wide
  298. 297 kubectl get pods -o wide
  299. 298 vim pod-with-pod-affinity.yaml
  300. 299 vim redis-with-pod-affinity.yaml
  301. 300 kubectl apply -f redis-with-pod-affinity.yaml
  302. 301 kubectl get pods
  303. 302 kubectl describe pod redis-cache-8478cbdc86-
  304. 303 kubectl get pods
  305. 304 kubectl describe pod redis-cache-8478cbdc86-65ht9
  306. 305 vim web-with-pod-affinity.yaml
  307. 306 kubectl apply -f web-with-pod-affinity.yaml
  308. 307 kubectl get pods
  309. 308 history
  310.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement