sandervanvugt

CKAD march22 day2

Mar 31st, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.99 KB | None | 0 0
  1. root@control:/etc/kubernetes/pki# history
  2. 1 git clone https://github.com/sandervanvugt/cka
  3. 2 cd cka
  4. 3 ls
  5. 4 vim setup-container.sh
  6. 5 ./setup-container.sh
  7. 6 ./setup-kubetools.sh
  8. 7 kubeadm init
  9. 8 vim /tmp/todo.txt
  10. 9 exit
  11. 10 kubeadm token create --help
  12. 11 kubeadm token create --print-join-command
  13. 12 exit
  14. 13 cd /etc/kubernetes/manifests/
  15. 14 ls
  16. 15 exit
  17. 16 etcdctl --help
  18. 17 etcdctl --help | less
  19. 18 ETCDCTL_APT=3 etcdctl -h | less
  20. 19 ETCDCTL_API=3 etcdctl -h | less
  21. 20 ETCDCTL_API=3 etcdctl snapshot save mysnap.bak
  22. 21 ps aux | grep etcd
  23. 22 #ETCDCTL_API=3 etcdctl snapshot --endpoints=127.0.0.1:2379 save mysnap.bak
  24. 23 cd /etc/kubernetes/pki/
  25. 24 ls
  26. 25 ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert="/etc/kubernetes/pki/etcd/ca.crt" --cert="/etc/kubernetes/pki/apiserver-etcd-client.crt" --key="/etc/kubernetes/pki/apiserver-etcd-client.key" snapshot save /tmp/etcd-backup
  27. 26 history
  28.  
  29.  
  30. student@control:~/cka$ history
  31. 1 cat /etc/hosts
  32. 2 free -m
  33. 3 sudo vim /etc/fstab
  34. 4 swapoff /swap.img
  35. 5 sudo swapoff /swap.img
  36. 6 free -m
  37. 7 sudo -i
  38. 8 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  39. 9 sudo chown $(id -u):$(id -g) $HOME/.kube/config
  40. 10 kubectl get all
  41. 11 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
  42. 12 kubectl get ns
  43. 13 kubectl get pods -A
  44. 14 cat /tmp/todo.txt
  45. 15 kubectl get nodes
  46. 16 history
  47. 17 git clone https://github.com/sandervanvugt/cka
  48. 18 cka/counter.sh 15
  49. 19 cd cka
  50. 20 ls
  51. 21 ./counter.sh 15
  52. 22 sudo -i
  53. 23 kubectl get nodes
  54. 24 history
  55. 25 wget https://docs.projectcalico.org/manifests/calico.yaml
  56. 26 vim calico.yaml
  57. 27 kubectl get daemonset
  58. 28 kubectl get daemonset -A
  59. 29 kubectl get pods -A
  60. 30 kubectl get pods -A -o wide
  61. 31 kubectl get pods -A -o wide | grep calico
  62. 32 history
  63. 33 kubectl create ns mynamespace
  64. 34 kubectl run alpine --image=alpine -- sleep 3600 -n mynamespace
  65. 35 kubectl get pods -A
  66. 36 kubectl run alpine --image=alpine -n mynamespace -- sleep 3600
  67. 37 kubectl get pods -A
  68. 38 kubectl completion -h
  69. 39 source <(kubectl completion bash)
  70. 40 kubectl describe pod alpine
  71. 41 kubectl logs alpine
  72. 42 kubectl run alpine --image=alpine -- sleep 3600 -n mynamespace
  73. 43 kubectl delete pod alpine
  74. 44 ./counter.sh 15
  75. 45 vim bi-doesnwork.yaml
  76. 46 kubectl create -f bi-doesnwork.yaml
  77. 47 kubectl get all
  78. 48 kubectl get pods -A
  79. 49 history | grep calico
  80. 50 ./counter.sh 5
  81. 51 vim knabc.yaml
  82. 52 vim ex4.yaml
  83. 53 kubectl run blah --image=busybox --dry-run=client -o yaml -- mkdir /data; touch /data/myfile.txt
  84. 54 kubectl run blah --image=busybox --dry-run=client -o yaml -- "mkdir /data; touch /data/myfile.txt"
  85. 55 vim ex4.yaml
  86. 56 kubectl create -f ex4.yaml
  87. 57 kubectl get pods
  88. 58 kubectl delete -f ex4.yaml
  89. 59 vim ex4.yaml
  90. 60 kubectl create -f ex4.yaml
  91. 61 kubectl get pods
  92. 62 kubectl describe pod init-demo
  93. 63 vim ex4.yaml
  94. 64 kubectl delete pod init-demo
  95. 65 kubectl create -f ex4
  96. 66 kubectl create -f ex4.yaml
  97. 67 kubectl get pods
  98. 68 kubectl describe pod init-demo
  99. 69 kubectl delete pod init-demo
  100. 70 vim ex4.yaml
  101. 71 kubectl create -f ex4.yaml
  102. 72 kubectl get pods
  103. 73 kubectl describe pod init-demo
  104. 74 kubectl delete pod init-demo
  105. 75 vim ex4.yaml
  106. 76 kubectl create -f ex4.yaml
  107. 77 kubectl get pods
  108. 78 kubectl delete pod init-demo
  109. 79 vim ex4.yaml
  110. 80 kubectl create -f ex4.yaml
  111. 81 kubectl get pods
  112. 82 vim ex4.yaml
  113. 83 kubectl describe pod init-demo
  114. 84 vim ex4.yaml
  115. 85 kubectl delete pod init-demo
  116. 86 kubectl create -f ex4.yaml
  117. 87 kubectl get pods
  118. 88 vim ex4.yaml
  119. 89 ./counter.sh 18
  120. 90 ./counter.sh 7
  121. 91 sudo -i
  122. 92 kubectl get pods
  123. 93 kubectl --help | less
  124. 94 kubectl cordon --help | less
  125. 95 kubectl drain --help | less
  126. 96 kubectl get pods -A
  127. 97 kubectl get pods -A -o wide
  128. 98 kubectl drain worker2
  129. 99 kubectl drain worker2 --ignore-daemonsets --force
  130. 100 kubectl get pods -o wide -A
  131. 101 kubectl describe node worker2
  132. 102 kubectl describe node worker2 | less
  133. 103 kubectl get nodes
  134. 104 kubectl uncordon worker2
  135. 105 ./counter.sh 12
  136. 106 ./counter.sh 5
  137. 107 kubectl get nodes
  138. 108 ls -l ~/.kube/
  139. 109 sudo cp /etc/kubernetes/admin.conf ~/.kube/config
  140. 110 ls -l ~/.kube/
  141. 111 chown student:student ~/.kube/config
  142. 112 sudo chown student:student ~/.kube/config
  143. 113 ls -l ~/.kube/
  144. 114 kubectl get nodes
  145. 115 kubectl edit node control
  146. 116 kubectl create deploy --image=nginx --replicas=3 tttest
  147. 117 kubectl get pods -o wide
  148. 118 kubectl config view
  149. 119 vim ~/.kube/config
  150. 120 kubectl label nodes worker2 disktype=ssd
  151. 121 kubectl get nodes --show-labels
  152. 122 vim selector-pod.yaml
  153. 123 kubectl apply -f selector-pod.yaml
  154. 124 kubectl get pods -o wide
  155. 125 kubectl delete pod nginx
  156. 126* kubectl label node worker2 disktype=ssd
  157. 127 kubectl edit node worker2
  158. 128 kubectl apply -f selector-pod.yaml
  159. 129 kubectl get pods
  160. 130 kubectl describe pod nginx
  161. 131 kubectl label nodes worker2 disktype=ssd
  162. 132 kubectl get pods
  163. 133 kubectl get daemonset
  164. 134 kubectl get daemonset -A
  165. 135 kubectl get daemonset -n kube-system calico-node -o yaml | less
  166. 136 kubectl taint nodes worker1 example-key=value1:NoSchedule
  167. 137 kubectl describe nodes worker1 | less
  168. 138 kubectl create deploy nginx-taint --image=nginx --replicas=3
  169. 139 kubectl get pods --selector app=nginx-taint
  170. 140 kubectl get pods --selector app=nginx-taint -o wide
  171. 141 vim taint-toleration.yaml
  172. 142 kubectl create -f taint-toleration.yaml
  173. 143 kubectl get pods -o wide | grep tolera
  174. 144 kubectl get pods -o wide
  175. 145 ./counter.sh 5
  176. 146 kubectl edit node worker1
  177. 147 history
  178. 148 https://github.com/kubernetes-sigs/metrics-server
  179. 149 cd
  180. 150 git clone https://github.com/kubernetes-sigs/metrics-server
  181. 151 cd metrics-server/
  182. 152 ls
  183. 153 less README.md
  184. 154 cd manifests/
  185. 155 ls
  186. 156 cd base/
  187. 157 vim
  188. 158 vim deployment.yaml
  189. 159 kubectl create -f .
  190. 160 kubectl get pods -n kube-system
  191. 161 kubectl top pods
  192. 162 cd cka
  193. 163 ./counter.sh 5
  194. 164 kubectl create deploy nginx-ds --image=nginx --dry-run=client -o yaml nginx-ds.yaml
  195. 165 kubectl create deploy nginx-ds --image=nginx --dry-run=client -o yaml >nginx-ds.yaml
  196. 166 vim nginx-ds.yaml
  197. 167 kubectl create -f nginx-ds.yaml
  198. 168 vim nginx-ds.yaml
  199. 169 kubectl create -f nginx-ds.yaml
  200. 170 vim newds.yaml
  201. 171 kubectl create -f newds.yaml
  202. 172 kubectl create -f nginx-ds.yaml --validate=false
  203. 173 kubectl get ds,pods
  204. 174 kubectl get ds,pods -o wide
  205. 175 kubectl top pods
  206. 176 history
  207. 177 kubectl top pods
  208. 178 kubectl get all -n kube-system
  209. 179 kubectl describe svc -n kube-system metrics-server
  210. 180 kubectl -n kube-system get pods --show-labels
  211. 181 kubectl describe svc kubernetes
  212. 182 kubectl get svc kubernetes -o yaml
  213. 183 kubectl edit -n kube-system svc metrics-server
  214. 184 kubectl describe svc -n kube-system metrics-server
  215. 185 kubectl get svc kubernetes -o yaml
  216. 186 kubectl get all
  217. 187 kubectl expose deployment nginx-taint --port=80
  218. 188 kubectl get svc nginx-taint -o yaml
  219. 189 kubectl get svc kubernetes -o yaml
  220. 190 kubectl edit -n kube-system svc metrics-server
  221. 191 kubectl describe svc -n kube-system metrics-server
  222. 192 kubectl top pods
  223. 193 history
  224. 194 kubectl get svc -n kube-system -o yaml
  225. 195 vim nwpolicy-complete-example.yaml
  226. 196 kubectl apply -f nwpolicy-complete-example.yaml
  227. 197 kubectl delete -f nwpolicy-complete-example.yaml
  228. 198 kubectl get pods
  229. 199 kubectl apply -f nwpolicy-complete-example.yaml
  230. 200 kubectl expose pod nginx --port=80
  231. 201 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  232. 202 kubectl get pods busybox --show-labels
  233. 203 kubectl label pod busybox access=true
  234. 204 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  235. 205 ls
  236. 206 kubectl create ns nwp-namespace
  237. 207 vim nwp-lab11-1.yaml
  238. 208 kubectl create -f nwp-lab11-1.yaml
  239. 209 kubectl expose pod nwp-nginx --port=80
  240. 210 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  241. 211 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  242. 212 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  243. 213 vim nwp-lab11-2.yaml
  244. 214 kubectl create -f nwp-lab11-2.yaml
  245. 215 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  246. 216 kubectl create deploy busybox --image=busybox -- sleep 3600
  247. 217 kubectl exec -it busybox-669745485f-dqwft -- wget --spider --timeout=1 nwp-nginx
  248. 218 ./counter.sh 18
  249. 219 kubectl apply -f nwpolicy-complete-example.yaml
  250. 220 kubectl describe networkpolicy access-nginx
  251. 221 vim nwp-lab11-1.yaml
  252. 222 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  253. 223 kubectl get networkpolicy
  254. 224 kubectl delete nwp access-nginx
  255. 225 kubectl delete networkpolicy access-nginx
  256. 226 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  257. 227 vim nwp-lab11-2.yaml
  258. 228 kubectl create -f nwp-lab11-2.yaml
  259. 229 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  260. 230 vim nwp-lab11-2.yaml
  261. 231 kubectl get pods -o wide --sort-by=.spec.nodeName
  262. 232 kubectl create -h
  263. 233 kubectl create -h | less
  264. 234 kubectl create quota -h | less
  265. 235 kubectl create ns limited
  266. 236 kubectl create quota qtest --hard pods=3,cpu=100m,memory=500Mi -n limited
  267. 237 kubectl describe ns limited
  268. 238 kubectl describe quota -n limited
  269. 239 kubectl get quota -A
  270. 240 kubectl create deploy qginx --image=nginx --replicas=3 -n limited
  271. 241 kubectl get all -n limited
  272. 242 kubectl describe rs -n limited qginx-844f68fd9c
  273. 243 kubectl set -h | less
  274. 244 kubectl set resources -h | less
  275. 245 kubectl set resources -n limited deploy qginx --requests cpu=100m,memory=5Mi --limits cpu=200m,memory=20Mi
  276. 246 kubectl get all -n limited
  277. 247 kubectl describe -n limited rs qginx-5457b94959
  278. 248 kubectl edit -n limited quota qtest
  279. 249 kubectl get all -n limited
  280. 250 history
  281. 251 ./counter.sh 12
  282. 252 ./counter.sh 7
  283. 253 TCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> snapshot save <backup-file-location>
  284. 254 etcdctl
  285. 255 sudo apt install etcd-client
  286. 256 sudo -i
  287. 257 history
  288.  
  289.  
  290.  
Advertisement
Add Comment
Please, Sign In to add comment