sandervanvugt

cka day2 march 21

Mar 19th, 2021
134
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. 134 kubectl get pods
  135. 135 history
  136. 136 kubectl get pods
  137. 137 kubectl create -f ab3.yaml
  138. 138 kubectl get pods
  139. 139 kubectl get pods -o wide
  140. 140 vim igfds.yaml
  141. 141 kubectl create -h
  142. 142 vim igfds.yaml
  143. 143 kubectl explain daemonset.spec
  144. 144 kubectl create -f igfds.yaml
  145. 145 kubectl get ds
  146. 146 kubectl get pods -o wide
  147. 147 vim igfds.yaml
  148. 148 ./counter.sh 12
  149. 149 kubectl get all -n restricted
  150. 150 kubectl describe replicaset.apps/nginx-6b5f657dd8 -n restricted
  151. 151 kubectl set resources -h | less
  152. 152 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
  153. 153 kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi -n restricted
  154. 154 kubectl get all -n restricted
  155. 155 kubectl get pods nginx-6689944d78-lqzfj -n restricted
  156. 156 kubectl get pods nginx-6689944d78-lqzfj -n restricted -o yaml
  157. 157 kubectl explain pods.spec.containers.resources
  158. 158 vim nwpolicy-complete-example.yaml
  159. 159 kubectl get deploy
  160. 160 kubectl delete deploy mydeploy
  161. 161 kubectl get pods
  162. 162 kubectl delete ds nginx
  163. 163 kubectl delete ds nginx-ds
  164. 164 kubectl get all -A --selector app=nginx
  165. 165 kubectl create -f nwpolicy-complete-example.yaml
  166. 166 kubectl expose pod nginx --port=80
  167. 167 kubectl get svc
  168. 168 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  169. 169 kubectl get pods --show-labels
  170. 170 kubectl label pod busybox access=true
  171. 171 kubectl exec -it busybox -- wget --spider --timeout=1 nginx
  172. 172 kubectl create ns nwp-namespace
  173. 173 vim nwp-lab11-1.yaml
  174. 174 kubectl create -f nwp-lab11-1.yaml
  175. 175 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx
  176. 176 kubectl exec -it nwp-busybox -n nwp-namespace -- nslookup nwp-nginx
  177. 177 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  178. 178 kubectl expose pod nwp-nginx --port=80
  179. 179 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  180. 180 kubectl get pods -A -o wide
  181. 181 kubectl get pods -n default
  182. 182 kubectl get pods -n nwp-namespace
  183. 183 kubectl get nwp
  184. 184 kubectl get networkpolicy
  185. 185 kubectl get pods -n default --show-labels
  186. 186 kubectl label pod nwp-nginx app-
  187. 187 kubectl get pods -n default --show-labels
  188. 188 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  189. 189 kubectl get svc --show-labels
  190. 190 kubectl label svc nwp-nginx app-
  191. 191 kubectl get svc --show-labels
  192. 192 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  193. 193 kubectl get networkpolicy
  194. 194 kubectl delete networkpolicy access-nginx
  195. 195 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  196. 196 vim nwp-lab11-2.yaml
  197. 197 kubectl create -f nwp-lab11-2.yaml
  198. 198 kubectl exec -it nwp-busybox -n nwp-namespace -- wget --spider --timeout=1 nwp-nginx.default.svc.cluster.local
  199. 199 history
  200. [student@control1 cka]$
  201. [student@control1 cka]$ su -
  202. Password:
  203. Last login: Fri Mar 19 09:30:49 EDT 2021 from gateway on pts/0
  204. [root@control1 ~]# history
  205. 1 ssh 192.168.29.64
  206. 2 vim /etc/hosts
  207. 3 vi /etc/hosts
  208. 4 yum install -y vim git bash-completion
  209. 5 git clone https://github.com/sandervanvugt/cka
  210. 6 cd cka
  211. 7 ./setup-docker.sh
  212. 8 ./setup-kubetools.sh
  213. 9 history
  214. 10 cat /etc/hosts
  215. 11 for i in 62 63 64 65; do scp /etc/hosts 192.168.29.$i:/etc/; done
  216. 12 scp /etc/hosts 192.168.29.200:/etc/
  217. 13 vim setup-lb.sh
  218. 14 ip a
  219. 15 vim keepalived.conf
  220. 16 vim setup-lb.sh
  221. 17 vim check_apiserver.sh
  222. 18 vim setup-lb.sh
  223. 19 chmod +x setup-lb.sh
  224. 20 vim /etc/hosts
  225. 21 vim setup-lb.sh
  226. 22 ./setup-lb.sh
  227. 23 ip a
  228. 24 vim setup-lb.sh
  229. 25 vim keepalived.conf
  230. 26 ls *server*
  231. 27 vim check_apiserver.sh
  232. 28 kubeadm init --control-plane-endpoint "192.168.29.100:8443" --upload-certs
  233. 29 vim /tmp/hasetup.txt
  234. 30 su - student
  235. 31 cat /tmp/hasetup.txt
  236. 32 ssh control2
  237. 33 ssh control3
  238. 34 su - student
  239. 35 ssh control2
  240. 36 cat /tmp/hasetup.txt
  241. 37 ssh worker1
  242. 38 ssh worker2
  243. 39 su - student
  244. 40 history
  245. 41 ip a
  246. 42 history
  247. 43 ./counter.sh 5
  248. 44 vim /tmp/hasetup.txt
  249. 45 history
  250. 46 vim /tmp/hasetup.txt
  251. 47 exit
  252. 48 cd /etc/kubernetes/manifests/
  253. 49 ls
  254. 50 vim etcd.yaml
  255. 51 exit
  256. 52 useradd anna
  257. 53 cd /home/anna
  258. 54 openssl genrsa -out anna.key 2048
  259. 55 ls
  260. 56 openssl req -new -key anna.key -out anna.csr -subj "/CN=anna"
  261. 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
  262. 58 mkdir .certs
  263. 59 ls
  264. 60 mv ann* .certs/
  265. 61 cd ..
  266. 62 chmod -R 777 anna
  267. 63 ls -l anna
  268. 64 ls -l
  269. 65 exit
  270. 66 history
Advertisement
Add Comment
Please, Sign In to add comment