Advertisement
sandervanvugt

cka day2 march 21

Mar 19th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.76 KB | None | 0 0
  1. [student@control1 cka]$ history
  2. 1 mkdir .kube
  3. 2 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  4. 3 sudo chown $(id -u):$(id -g) $HOME/.kube/config
  5. 4 kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
  6. 5 kubectl delete -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
  7. 6 kubectl apply -f https://docs.projectcalicao.org/v3.14/manifests/calico.yaml
  8. 7 kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
  9. 8 kubectl get ns -a
  10. 9 kubectl get ns -A
  11. 10 kubectl get pods kube-system
  12. 11 kubectl get pods -n kube-system
  13. 12 exit
  14. 13 kubectl get nodes
  15. 14 exit
  16. 15 kubectl get nodes
  17. 16 exit
  18. 17 kubectl get all
  19. 18 git clone https://github.com/sandervanvugt/ckad
  20. 19 cd ckad/
  21. 20 cd ..
  22. 21 git clone https://github.com/sandervanvugt/cka
  23. 22 cd cka
  24. 23 vim pv-pvc-pod.yaml
  25. 24 kubectl create -f pv-pvc-pod.yaml
  26. 25 kubectl create ns myvol
  27. 26 kubectl create -f pv-pvc-pod.yaml
  28. 27 kubectl get pv
  29. 28 kubectl get pvc
  30. 29 kubectl get pvc -n myvol
  31. 30 kubectl describe pod -n myvol
  32. 31 vim pv-pvc-pod.yaml
  33. 32 kubectl explain pv.spec | less
  34. 33 ./counter.sh 6
  35. 34 kubectl completion -h
  36. 35 source <(kubectl completion bash)
  37. 36 kubectl get all
  38. 37 kubectl create deployment mydeploy --image=nginx:1.14
  39. 38 kubectl set image deployment/mydeploy nginx=nginx:1.16.1 --record
  40. 39 kubectl get all
  41. 40 kubectl rollout history
  42. 41 kubectl rollout history deployment mydeploy
  43. 42 kubectl get deployments.apps mydeploy -o yaml
  44. 43 kubectl rollout undo deployment mydeploy
  45. 44 kubectl rollout history deployment
  46. 45 kubectl cordon -h
  47. 46 kubectl drain -h
  48. 47 kubectl drain worker2.example.com --ignore-daemonsets
  49. 48 kubectl get nodes
  50. 49 kubectl uncordon -h
  51. 50 kubectl uncordon worker2.example.com
  52. 51 kubectl get nodes
  53. 52 ./counter.sh 16
  54. 53 sudo etcdctl
  55. 54 sudo yum provides */etcdctl
  56. 55 sudo yum install etcd
  57. 56 sudo etcdctl --help
  58. 57 sudo ETCDCTL_API=3 etcdctl
  59. 58 sudo ETCDCTL_API=3 etcdctl snapshot save -h
  60. 59 sudo ETCDCTL_API=3 etcdctl snapshot save myetcd
  61. 60 sudo ETCDCTL_API=3 etcdctl snapshot --endpoints=localhost:2379
  62. 61 sudo ls /etc/kubernetes/pki/etcd/
  63. 62 sudo ETCDCTL_API=3 etcdctl snapshot --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
  64. 63 sudo ETCDCTL_API=3 etcdctl snapshot --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 / --keys-only
  65. 64 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
  66. 65 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 snapshot.db
  67. 66 ps aux | grep api-server
  68. 67 ps aux | grep api
  69. 68 ps aux | grep api | grep etcd
  70. 69 ps aux | grep etcd
  71. 70 sudo -i
  72. 71 vim ~/.kube/config
  73. 72 sudo -i
  74. 73 kubectl config set-credentials anna --client-certificate=/home/anna/.certs/anna.crt --client-key=/home/anna/.certs/anna.key
  75. 74 kubectl config view
  76. 75 mkdir /home/anna/.kube
  77. 76 cp ~/.kube/config /home/anna/.kube/
  78. 77 exit
  79. 78 kubectl get all
  80. 79 cd cka
  81. 80 vim podacessrole.yaml
  82. 81 kubectl create -f podacessrole.yaml
  83. 82 vim rolebinding.yaml
  84. 83 kubectl create -f rolebinding.yaml
  85. 84 kubectl get pods
  86. 85 kubectl run rolepod --image=nginx
  87. 86 kubectl get pods
  88. 87 su - anna
  89. 88 exit
  90. 89 kubectl get pods --as anna
  91. 90 kubectl auth can-i get pods --as anna
  92. 91 cd cka
  93. 92 ./counter.sh 18
  94. 93 ./counter.sh 3
  95. 94 kubectl create deploy mydep --image=busybox --dry-run=client -o yaml --replicas=3 -- sleep 1000 >dep.yaml
  96. 95 vim dep.yaml
  97. 96 kubectl create -f dep.yaml
  98. 97 kubectl delete -f dep.yaml
  99. 98 kubectl get nodes
  100. 99 ./counter.sh 6
  101. 100 kubectl create ns restricted
  102. 101 kubectl create quota -h
  103. 102 kubectl create quota qa --hard=memory=1G,pods=3 --namespace restricted
  104. 103 kubectl get quota
  105. 104 kubectl get quota -n restricted
  106. 105 kubectl kubectl completion -h
  107. 106 kubectl completion -h
  108. 107 source <(kubectl completion bash)
  109. 108 kubectl describe ns restricted
  110. 109 kubectl create deploy nginx --image=nginx --replicas=3 -n restricted
  111. 110 kubect get all -n restricted
  112. 111 kubectl get all -n restricted
  113. 112 kubectl describe -n restricted rs nginx-6799fc88d8
  114. 113 kubectl set -h
  115. 114 kubectl set resources -h
  116. 115 #kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi
  117. 116 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi
  118. 117 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi -n restricted
  119. 118 kubectl get all -n restricted
  120. 119 history
  121. 120 kubectl get nodes
  122. 121 kubectl get all -n restricted
  123. 122 kubectl get nodes
  124. 123 vim newexo.txt
  125. 124 kubectl explain pod.spec
  126. 125 vim ab3.yaml
  127. 126 kubectl create -f ab3.yaml
  128. 127 kubectl get pods
  129. 128 kubectl describe pod pod
  130. 129 kubectl get nodes
  131. 130 vim ab3.yaml
  132. 131 kubectl describe node worker1.example.com
  133. 132 kubectl get events
  134. 133 ssh root@worker1.example.com
  135. 134 kubectl get pods
  136. 135 history
  137. 136 kubectl get pods
  138. 137 kubectl create -f ab3.yaml
  139. 138 kubectl get pods
  140. 139 kubectl get pods -o wide
  141. 140 vim igfds.yaml
  142. 141 kubectl create -h
  143. 142 vim igfds.yaml
  144. 143 kubectl explain daemonset.spec
  145. 144 kubectl create -f igfds.yaml
  146. 145 kubectl get ds
  147. 146 kubectl get pods -o wide
  148. 147 vim igfds.yaml
  149. 148 ./counter.sh 12
  150. 149 kubectl get all -n restricted
  151. 150 kubectl describe replicaset.apps/nginx-6b5f657dd8 -n restricted
  152. 151 kubectl set resources -h | less
  153. 152 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
  154. 153 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi -n restricted
  155. 154 kubectl get all -n restricted
  156. 155 kubectl get pods nginx-6689944d78-lqzfj -n restricted
  157. 156 kubectl get pods nginx-6689944d78-lqzfj -n restricted -o yaml
  158. 157 kubectl explain pods.spec.containers.resources
  159. 158 vim nwpolicy-complete-example.yaml
  160. 159 kubectl get deploy
  161. 160 kubectl delete deploy mydeploy
  162. 161 kubectl get pods
  163. 162 kubectl delete ds nginx
  164. 163 kubectl delete ds nginx-ds
  165. 164 kubectl get all -A --selector app=nginx
  166. 165 kubectl create -f nwpolicy-complete-example.yaml
  167. 166 kubectl expose pod nginx --port=80
  168. 167 kubectl get svc
  169. 168 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  170. 169 kubectl get pods --show-labels
  171. 170 kubectl label pod busybox access=true
  172. 171 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  173. 172 kubectl create ns nwp-namespace
  174. 173 vim nwp-lab11-1.yaml
  175. 174 kubectl create -f nwp-lab11-1.yaml
  176. 175 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  177. 176 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  178. 177 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  179. 178 kubectl expose pod nwp-nginx --port=80
  180. 179 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  181. 180 kubectl get pods -A -o wide
  182. 181 kubectl get pods -n default
  183. 182 kubectl get pods -n nwp-namespace
  184. 183 kubectl get nwp
  185. 184 kubectl get networkpolicy
  186. 185 kubectl get pods -n default --show-labels
  187. 186 kubectl label pod nwp-nginx app-
  188. 187 kubectl get pods -n default --show-labels
  189. 188 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  190. 189 kubectl get svc --show-labels
  191. 190 kubectl label svc nwp-nginx app-
  192. 191 kubectl get svc --show-labels
  193. 192 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  194. 193 kubectl get networkpolicy
  195. 194 kubectl delete networkpolicy access-nginx
  196. 195 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  197. 196 vim nwp-lab11-2.yaml
  198. 197 kubectl create -f nwp-lab11-2.yaml
  199. 198 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  200. 199 history
  201. [student@control1 cka]$
  202. [student@control1 cka]$ su -
  203. Password:
  204. Last login: Fri Mar 19 09:30:49 EDT 2021 from gateway on pts/0
  205. [root@control1 ~]# history
  206. 1 ssh 192.168.29.64
  207. 2 vim /etc/hosts
  208. 3 vi /etc/hosts
  209. 4 yum install -y vim git bash-completion
  210. 5 git clone https://github.com/sandervanvugt/cka
  211. 6 cd cka
  212. 7 ./setup-docker.sh
  213. 8 ./setup-kubetools.sh
  214. 9 history
  215. 10 cat /etc/hosts
  216. 11 for i in 62 63 64 65; do scp /etc/hosts 192.168.29.$i:/etc/; done
  217. 12 scp /etc/hosts 192.168.29.200:/etc/
  218. 13 vim setup-lb.sh
  219. 14 ip a
  220. 15 vim keepalived.conf
  221. 16 vim setup-lb.sh
  222. 17 vim check_apiserver.sh
  223. 18 vim setup-lb.sh
  224. 19 chmod +x setup-lb.sh
  225. 20 vim /etc/hosts
  226. 21 vim setup-lb.sh
  227. 22 ./setup-lb.sh
  228. 23 ip a
  229. 24 vim setup-lb.sh
  230. 25 vim keepalived.conf
  231. 26 ls *server*
  232. 27 vim check_apiserver.sh
  233. 28 kubeadm init --control-plane-endpoint "192.168.29.100:8443" --upload-certs
  234. 29 vim /tmp/hasetup.txt
  235. 30 su - student
  236. 31 cat /tmp/hasetup.txt
  237. 32 ssh control2
  238. 33 ssh control3
  239. 34 su - student
  240. 35 ssh control2
  241. 36 cat /tmp/hasetup.txt
  242. 37 ssh worker1
  243. 38 ssh worker2
  244. 39 su - student
  245. 40 history
  246. 41 ip a
  247. 42 history
  248. 43 ./counter.sh 5
  249. 44 vim /tmp/hasetup.txt
  250. 45 history
  251. 46 vim /tmp/hasetup.txt
  252. 47 exit
  253. 48 cd /etc/kubernetes/manifests/
  254. 49 ls
  255. 50 vim etcd.yaml
  256. 51 exit
  257. 52 useradd anna
  258. 53 cd /home/anna
  259. 54 openssl genrsa -out anna.key 2048
  260. 55 ls
  261. 56 openssl req -new -key anna.key -out anna.csr -subj "/CN=anna"
  262. 57 openssl x509 -req -in anna.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out anna.crt -days 600
  263. 58 mkdir .certs
  264. 59 ls
  265. 60 mv ann* .certs/
  266. 61 cd ..
  267. 62 chmod -R 777 anna
  268. 63 ls -l anna
  269. 64 ls -l
  270. 65 exit
  271. 66 history
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement