The ungleich kubernetes infrastructure » History » Version 190
Nico Schottelius, 06/25/2023 11:49 AM
1 | 22 | Nico Schottelius | h1. The ungleich kubernetes infrastructure and ungleich kubernetes manual |
---|---|---|---|
2 | 1 | Nico Schottelius | |
3 | 3 | Nico Schottelius | {{toc}} |
4 | |||
5 | 1 | Nico Schottelius | h2. Status |
6 | |||
7 | 28 | Nico Schottelius | This document is **pre-production**. |
8 | This document is to become the ungleich kubernetes infrastructure overview as well as the ungleich kubernetes manual. |
||
9 | 1 | Nico Schottelius | |
10 | 10 | Nico Schottelius | h2. k8s clusters |
11 | |||
12 | 123 | Nico Schottelius | | Cluster | Purpose/Setup | Maintainer | Master(s) | argo | v4 http proxy | last verified | |
13 | | c0.k8s.ooo | Dev | - | UNUSED | | | 2021-10-05 | |
||
14 | | c1.k8s.ooo | retired | | - | | | 2022-03-15 | |
||
15 | | c2.k8s.ooo | Dev p7 HW | Nico | server47 server53 server54 | "argo":https://argocd-server.argocd.svc.c2.k8s.ooo | | 2021-10-05 | |
||
16 | | c3.k8s.ooo | retired | - | - | | | 2021-10-05 | |
||
17 | | c4.k8s.ooo | Dev2 p7 HW | Jin-Guk | server52 server53 server54 | | | - | |
||
18 | | c5.k8s.ooo | retired | | - | | | 2022-03-15 | |
||
19 | | c6.k8s.ooo | Dev p6 VM Jin-Guk | Jin-Guk | | | | | |
||
20 | | [[p5.k8s.ooo]] | production | | server34 server36 server38 | "argo":https://argocd-server.argocd.svc.p5.k8s.ooo | - | | |
||
21 | | [[p5-cow.k8s.ooo]] | production | Nico | server47 server51 server55 | "argo":https://argocd-server.argocd.svc.p5-cow.k8s.ooo | | 2022-08-27 | |
||
22 | | [[p6.k8s.ooo]] | production | | server67 server69 server71 | "argo":https://argocd-server.argocd.svc.p6.k8s.ooo | 147.78.194.13 | 2021-10-05 | |
||
23 | 184 | Nico Schottelius | | [[p6-cow.k8s.ooo]] | production | | server134 server135 server136 | "argo":https://argocd-server.argocd.svc.p6in10.k8s.ooo | ? | 2023-05-17 | |
24 | 177 | Nico Schottelius | | [[p10.k8s.ooo]] | production | | server131 server132 server133 | "argo":https://argocd-server.argocd.svc.p10.k8s.ooo | 147.78.194.12 | 2021-10-05 | |
25 | 123 | Nico Schottelius | | [[k8s.ge.nau.so]] | development | | server107 server108 server109 | "argo":https://argocd-server.argocd.svc.k8s.ge.nau.so | | | |
26 | | [[dev.k8s.ooo]] | development | | server110 server111 server112 | "argo":https://argocd-server.argocd.svc.dev.k8s.ooo | - | 2022-07-08 | |
||
27 | 164 | Nico Schottelius | | [[r1r2p15k8sooo|r1.p15.k8s.ooo]] | production | Nico | server120 | | | 2022-10-30 | |
28 | | [[r1r2p15k8sooo|r2.p15.k8s.ooo]] | production | Nico | server121 | | | 2022-09-06 | |
||
29 | 162 | Nico Schottelius | | [[r1r2p10k8sooo|r1.p10.k8s.ooo]] | production | Nico | server122 | | | 2022-10-30 | |
30 | | [[r1r2p10k8sooo|r2.p10.k8s.ooo]] | production | Nico | server123 | | | 2022-10-15 | |
||
31 | | [[r1r2p5k8sooo|r1.p5.k8s.ooo]] | production | Nico | server137 | | | 2022-10-30 | |
||
32 | | [[r1r2p5k8sooo|r2.p5.k8s.ooo]] | production | Nico | server138 | | | 2022-10-30 | |
||
33 | | [[r1r2p6k8sooo|r1.p6.k8s.ooo]] | production | Nico | server139 | | | 2022-10-30 | |
||
34 | | [[r1r2p6k8sooo|r2.p6.k8s.ooo]] | production | Nico | server140 | | | 2022-10-30 | |
||
35 | 21 | Nico Schottelius | |
36 | 1 | Nico Schottelius | h2. General architecture and components overview |
37 | |||
38 | * All k8s clusters are IPv6 only |
||
39 | * We use BGP peering to propagate podcidr and serviceCidr networks to our infrastructure |
||
40 | * The main public testing repository is "ungleich-k8s":https://code.ungleich.ch/ungleich-public/ungleich-k8s |
||
41 | 18 | Nico Schottelius | ** Private configurations are found in the **k8s-config** repository |
42 | 1 | Nico Schottelius | |
43 | h3. Cluster types |
||
44 | |||
45 | 28 | Nico Schottelius | | **Type/Feature** | **Development** | **Production** | |
46 | | Min No. nodes | 3 (1 master, 3 worker) | 5 (3 master, 3 worker) | |
||
47 | | Recommended minimum | 4 (dedicated master, 3 worker) | 8 (3 master, 5 worker) | |
||
48 | | Separation of control plane | optional | recommended | |
||
49 | | Persistent storage | required | required | |
||
50 | | Number of storage monitors | 3 | 5 | |
||
51 | 1 | Nico Schottelius | |
52 | 43 | Nico Schottelius | h2. General k8s operations |
53 | 1 | Nico Schottelius | |
54 | 46 | Nico Schottelius | h3. Cheat sheet / external great references |
55 | |||
56 | * "kubectl cheatsheet":https://kubernetes.io/docs/reference/kubectl/cheatsheet/ |
||
57 | |||
58 | 117 | Nico Schottelius | h3. Allowing to schedule work on the control plane / removing node taints |
59 | 69 | Nico Schottelius | |
60 | * Mostly for single node / test / development clusters |
||
61 | * Just remove the master taint as follows |
||
62 | |||
63 | <pre> |
||
64 | kubectl taint nodes --all node-role.kubernetes.io/master- |
||
65 | 118 | Nico Schottelius | kubectl taint nodes --all node-role.kubernetes.io/control-plane- |
66 | 69 | Nico Schottelius | </pre> |
67 | 1 | Nico Schottelius | |
68 | 117 | Nico Schottelius | You can check the node taints using @kubectl describe node ...@ |
69 | 69 | Nico Schottelius | |
70 | 44 | Nico Schottelius | h3. Get the cluster admin.conf |
71 | |||
72 | * On the masters of each cluster you can find the file @/etc/kubernetes/admin.conf@ |
||
73 | * To be able to administrate the cluster you can copy the admin.conf to your local machine |
||
74 | * Multi cluster debugging can very easy if you name the config ~/cX-admin.conf (see example below) |
||
75 | |||
76 | <pre> |
||
77 | % scp root@server47.place7.ungleich.ch:/etc/kubernetes/admin.conf ~/c2-admin.conf |
||
78 | % export KUBECONFIG=~/c2-admin.conf |
||
79 | % kubectl get nodes |
||
80 | NAME STATUS ROLES AGE VERSION |
||
81 | server47 Ready control-plane,master 82d v1.22.0 |
||
82 | server48 Ready control-plane,master 82d v1.22.0 |
||
83 | server49 Ready <none> 82d v1.22.0 |
||
84 | server50 Ready <none> 82d v1.22.0 |
||
85 | server59 Ready control-plane,master 82d v1.22.0 |
||
86 | server60 Ready,SchedulingDisabled <none> 82d v1.22.0 |
||
87 | server61 Ready <none> 82d v1.22.0 |
||
88 | server62 Ready <none> 82d v1.22.0 |
||
89 | </pre> |
||
90 | |||
91 | 18 | Nico Schottelius | h3. Installing a new k8s cluster |
92 | 8 | Nico Schottelius | |
93 | 9 | Nico Schottelius | * Decide on the cluster name (usually *cX.k8s.ooo*), X counting upwards |
94 | 28 | Nico Schottelius | ** Using pXX.k8s.ooo for production clusters of placeXX |
95 | 9 | Nico Schottelius | * Use cdist to configure the nodes with requirements like crio |
96 | * Decide between single or multi node control plane setups (see below) |
||
97 | 28 | Nico Schottelius | ** Single control plane suitable for development clusters |
98 | 9 | Nico Schottelius | |
99 | 28 | Nico Schottelius | Typical init procedure: |
100 | 9 | Nico Schottelius | |
101 | 28 | Nico Schottelius | * Single control plane: @kubeadm init --config bootstrap/XXX/kubeadm.yaml@ |
102 | * Multi control plane (HA): @kubeadm init --config bootstrap/XXX/kubeadm.yaml --upload-certs@ |
||
103 | 10 | Nico Schottelius | |
104 | 29 | Nico Schottelius | h3. Deleting a pod that is hanging in terminating state |
105 | |||
106 | <pre> |
||
107 | kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE> |
||
108 | </pre> |
||
109 | |||
110 | (from https://stackoverflow.com/questions/35453792/pods-stuck-in-terminating-status) |
||
111 | |||
112 | 42 | Nico Schottelius | h3. Listing nodes of a cluster |
113 | |||
114 | <pre> |
||
115 | [15:05] bridge:~% kubectl get nodes |
||
116 | NAME STATUS ROLES AGE VERSION |
||
117 | server22 Ready <none> 52d v1.22.0 |
||
118 | server23 Ready <none> 52d v1.22.2 |
||
119 | server24 Ready <none> 52d v1.22.0 |
||
120 | server25 Ready <none> 52d v1.22.0 |
||
121 | server26 Ready <none> 52d v1.22.0 |
||
122 | server27 Ready <none> 52d v1.22.0 |
||
123 | server63 Ready control-plane,master 52d v1.22.0 |
||
124 | server64 Ready <none> 52d v1.22.0 |
||
125 | server65 Ready control-plane,master 52d v1.22.0 |
||
126 | server66 Ready <none> 52d v1.22.0 |
||
127 | server83 Ready control-plane,master 52d v1.22.0 |
||
128 | server84 Ready <none> 52d v1.22.0 |
||
129 | server85 Ready <none> 52d v1.22.0 |
||
130 | server86 Ready <none> 52d v1.22.0 |
||
131 | </pre> |
||
132 | |||
133 | 41 | Nico Schottelius | h3. Removing / draining a node |
134 | |||
135 | Usually @kubectl drain server@ should do the job, but sometimes we need to be more aggressive: |
||
136 | |||
137 | 1 | Nico Schottelius | <pre> |
138 | 103 | Nico Schottelius | kubectl drain --delete-emptydir-data --ignore-daemonsets serverXX |
139 | 42 | Nico Schottelius | </pre> |
140 | |||
141 | h3. Readding a node after draining |
||
142 | |||
143 | <pre> |
||
144 | kubectl uncordon serverXX |
||
145 | 1 | Nico Schottelius | </pre> |
146 | 43 | Nico Schottelius | |
147 | 50 | Nico Schottelius | h3. (Re-)joining worker nodes after creating the cluster |
148 | 49 | Nico Schottelius | |
149 | * We need to have an up-to-date token |
||
150 | * We use different join commands for the workers and control plane nodes |
||
151 | |||
152 | Generating the join command on an existing control plane node: |
||
153 | |||
154 | <pre> |
||
155 | kubeadm token create --print-join-command |
||
156 | </pre> |
||
157 | |||
158 | 50 | Nico Schottelius | h3. (Re-)joining control plane nodes after creating the cluster |
159 | 1 | Nico Schottelius | |
160 | 50 | Nico Schottelius | * We generate the token again |
161 | * We upload the certificates |
||
162 | * We need to combine/create the join command for the control plane node |
||
163 | |||
164 | Example session: |
||
165 | |||
166 | <pre> |
||
167 | % kubeadm token create --print-join-command |
||
168 | kubeadm join p10-api.k8s.ooo:6443 --token xmff4i.ABC --discovery-token-ca-cert-hash sha256:longhash |
||
169 | |||
170 | % kubeadm init phase upload-certs --upload-certs |
||
171 | [upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace |
||
172 | [upload-certs] Using certificate key: |
||
173 | CERTKEY |
||
174 | |||
175 | # Then we use these two outputs on the joining node: |
||
176 | |||
177 | kubeadm join p10-api.k8s.ooo:6443 --token xmff4i.ABC --discovery-token-ca-cert-hash sha256:longhash --control-plane --certificate-key CERTKEY |
||
178 | </pre> |
||
179 | |||
180 | Commands to be used on a control plane node: |
||
181 | |||
182 | <pre> |
||
183 | kubeadm token create --print-join-command |
||
184 | kubeadm init phase upload-certs --upload-certs |
||
185 | </pre> |
||
186 | |||
187 | Commands to be used on the joining node: |
||
188 | |||
189 | <pre> |
||
190 | JOINCOMMAND --control-plane --certificate-key CERTKEY |
||
191 | </pre> |
||
192 | 49 | Nico Schottelius | |
193 | 51 | Nico Schottelius | SEE ALSO |
194 | |||
195 | * https://stackoverflow.com/questions/63936268/how-to-generate-kubeadm-token-for-secondary-control-plane-nodes |
||
196 | * https://blog.scottlowe.org/2019/08/15/reconstructing-the-join-command-for-kubeadm/ |
||
197 | |||
198 | 53 | Nico Schottelius | h3. How to fix etcd does not start when rejoining a kubernetes cluster as a control plane |
199 | 52 | Nico Schottelius | |
200 | If during the above step etcd does not come up, @kubeadm join@ can hang as follows: |
||
201 | |||
202 | <pre> |
||
203 | [control-plane] Creating static Pod manifest for "kube-apiserver" |
||
204 | [control-plane] Creating static Pod manifest for "kube-controller-manager" |
||
205 | [control-plane] Creating static Pod manifest for "kube-scheduler" |
||
206 | [check-etcd] Checking that the etcd cluster is healthy |
||
207 | error execution phase check-etcd: etcd cluster is not healthy: failed to dial endpoint https://[2a0a:e5c0:10:1:225:b3ff:fe20:37 |
||
208 | 8a]:2379 with maintenance client: context deadline exceeded |
||
209 | To see the stack trace of this error execute with --v=5 or higher |
||
210 | </pre> |
||
211 | |||
212 | Then the problem is likely that the etcd server is still a member of the cluster. We first need to remove it from the etcd cluster and then the join works. |
||
213 | |||
214 | To fix this we do: |
||
215 | |||
216 | * Find a working etcd pod |
||
217 | * Find the etcd members / member list |
||
218 | * Remove the etcd member that we want to re-join the cluster |
||
219 | |||
220 | |||
221 | <pre> |
||
222 | # Find the etcd pods |
||
223 | kubectl -n kube-system get pods -l component=etcd,tier=control-plane |
||
224 | |||
225 | # Get the list of etcd servers with the member id |
||
226 | kubectl exec -n kube-system -ti ETCDPODNAME -- etcdctl --endpoints '[::1]:2379' --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key member list |
||
227 | |||
228 | # Remove the member |
||
229 | kubectl exec -n kube-system -ti ETCDPODNAME -- etcdctl --endpoints '[::1]:2379' --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key member remove MEMBERID |
||
230 | </pre> |
||
231 | |||
232 | Sample session: |
||
233 | |||
234 | <pre> |
||
235 | [10:48] line:~% kubectl -n kube-system get pods -l component=etcd,tier=control-plane |
||
236 | NAME READY STATUS RESTARTS AGE |
||
237 | etcd-server63 1/1 Running 0 3m11s |
||
238 | etcd-server65 1/1 Running 3 7d2h |
||
239 | etcd-server83 1/1 Running 8 (6d ago) 7d2h |
||
240 | [10:48] line:~% kubectl exec -n kube-system -ti etcd-server65 -- etcdctl --endpoints '[::1]:2379' --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key member list |
||
241 | 356891cd676df6e4, started, server65, https://[2a0a:e5c0:10:1:225:b3ff:fe20:375c]:2380, https://[2a0a:e5c0:10:1:225:b3ff:fe20:375c]:2379, false |
||
242 | 371b8a07185dee7e, started, server63, https://[2a0a:e5c0:10:1:225:b3ff:fe20:378a]:2380, https://[2a0a:e5c0:10:1:225:b3ff:fe20:378a]:2379, false |
||
243 | 5942bc58307f8af9, started, server83, https://[2a0a:e5c0:10:1:3e4a:92ff:fe79:bb98]:2380, https://[2a0a:e5c0:10:1:3e4a:92ff:fe79:bb98]:2379, false |
||
244 | |||
245 | [10:48] line:~% kubectl exec -n kube-system -ti etcd-server65 -- etcdctl --endpoints '[::1]:2379' --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key member remove 371b8a07185dee7e |
||
246 | Member 371b8a07185dee7e removed from cluster e3c0805f592a8f77 |
||
247 | 1 | Nico Schottelius | |
248 | </pre> |
||
249 | |||
250 | SEE ALSO |
||
251 | |||
252 | * We found the solution using https://stackoverflow.com/questions/67921552/re-installed-node-cannot-join-kubernetes-cluster |
||
253 | 56 | Nico Schottelius | |
254 | 147 | Nico Schottelius | h3. Node labels (adding, showing, removing) |
255 | |||
256 | Listing the labels: |
||
257 | |||
258 | <pre> |
||
259 | kubectl get nodes --show-labels |
||
260 | </pre> |
||
261 | |||
262 | Adding labels: |
||
263 | |||
264 | <pre> |
||
265 | kubectl label nodes LIST-OF-NODES label1=value1 |
||
266 | |||
267 | </pre> |
||
268 | |||
269 | For instance: |
||
270 | |||
271 | <pre> |
||
272 | kubectl label nodes router2 router3 hosttype=router |
||
273 | </pre> |
||
274 | |||
275 | Selecting nodes in pods: |
||
276 | |||
277 | <pre> |
||
278 | apiVersion: v1 |
||
279 | kind: Pod |
||
280 | ... |
||
281 | spec: |
||
282 | nodeSelector: |
||
283 | hosttype: router |
||
284 | </pre> |
||
285 | |||
286 | 148 | Nico Schottelius | Removing labels by adding a minus at the end of the label name: |
287 | |||
288 | <pre> |
||
289 | kubectl label node <nodename> <labelname>- |
||
290 | </pre> |
||
291 | |||
292 | For instance: |
||
293 | |||
294 | <pre> |
||
295 | kubectl label nodes router2 router3 hosttype- |
||
296 | </pre> |
||
297 | |||
298 | 147 | Nico Schottelius | SEE ALSO |
299 | 1 | Nico Schottelius | |
300 | 148 | Nico Schottelius | * https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/ |
301 | * https://stackoverflow.com/questions/34067979/how-to-delete-a-node-label-by-command-and-api |
||
302 | 147 | Nico Schottelius | |
303 | 101 | Nico Schottelius | h3. Hardware Maintenance using ungleich-hardware |
304 | |||
305 | Use the following manifest and replace the HOST with the actual host: |
||
306 | |||
307 | <pre> |
||
308 | apiVersion: v1 |
||
309 | kind: Pod |
||
310 | metadata: |
||
311 | name: ungleich-hardware-HOST |
||
312 | spec: |
||
313 | containers: |
||
314 | - name: ungleich-hardware |
||
315 | image: ungleich/ungleich-hardware:0.0.5 |
||
316 | args: |
||
317 | - sleep |
||
318 | - "1000000" |
||
319 | volumeMounts: |
||
320 | - mountPath: /dev |
||
321 | name: dev |
||
322 | securityContext: |
||
323 | privileged: true |
||
324 | nodeSelector: |
||
325 | kubernetes.io/hostname: "HOST" |
||
326 | |||
327 | volumes: |
||
328 | - name: dev |
||
329 | hostPath: |
||
330 | path: /dev |
||
331 | </pre> |
||
332 | |||
333 | 102 | Nico Schottelius | Also see: [[The_ungleich_hardware_maintenance_guide]] |
334 | |||
335 | 105 | Nico Schottelius | h3. Triggering a cronjob / creating a job from a cronjob |
336 | 104 | Nico Schottelius | |
337 | To test a cronjob, we can create a job from a cronjob: |
||
338 | |||
339 | <pre> |
||
340 | kubectl create job --from=cronjob/volume2-daily-backup volume2-manual |
||
341 | </pre> |
||
342 | |||
343 | This creates a job volume2-manual based on the cronjob volume2-daily |
||
344 | |||
345 | 112 | Nico Schottelius | h3. su-ing into a user that has nologin shell set |
346 | |||
347 | Many times users are having nologin as their shell inside the container. To be able to execute maintenance commands within the |
||
348 | container, we can use @su -s /bin/sh@ like this: |
||
349 | |||
350 | <pre> |
||
351 | su -s /bin/sh -c '/path/to/your/script' testuser |
||
352 | </pre> |
||
353 | |||
354 | Found on https://serverfault.com/questions/351046/how-to-run-command-as-user-who-has-usr-sbin-nologin-as-shell |
||
355 | |||
356 | 113 | Nico Schottelius | h3. How to print a secret value |
357 | |||
358 | Assuming you want the "password" item from a secret, use: |
||
359 | |||
360 | <pre> |
||
361 | kubectl get secret SECRETNAME -o jsonpath="{.data.password}" | base64 -d; echo "" |
||
362 | </pre> |
||
363 | |||
364 | 173 | Nico Schottelius | h3. How to upgrade a kubernetes cluster |
365 | 172 | Nico Schottelius | |
366 | h4. General |
||
367 | |||
368 | * Should be done every X months to stay up-to-date |
||
369 | ** X probably something like 3-6 |
||
370 | * kubeadm based clusters |
||
371 | * Needs specific kubeadm versions for upgrade |
||
372 | * Follow instructions on https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/ |
||
373 | 190 | Nico Schottelius | * Finding releases: https://github.com/kubernetes/kubernetes/tree/master/CHANGELOG |
374 | 172 | Nico Schottelius | |
375 | h4. Getting a specific kubeadm or kubelet version |
||
376 | |||
377 | <pre> |
||
378 | 190 | Nico Schottelius | RELEASE=v1.22.17 |
379 | RELEASE=v1.23.17 |
||
380 | 181 | Nico Schottelius | RELEASE=v1.24.9 |
381 | 1 | Nico Schottelius | RELEASE=v1.25.9 |
382 | RELEASE=v1.26.6 |
||
383 | 190 | Nico Schottelius | RELEASE=v1.27.2 |
384 | |||
385 | 187 | Nico Schottelius | ARCH=amd64 |
386 | 172 | Nico Schottelius | |
387 | curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet} |
||
388 | 182 | Nico Schottelius | chmod u+x kubeadm kubelet |
389 | 172 | Nico Schottelius | </pre> |
390 | |||
391 | h4. Steps |
||
392 | |||
393 | * kubeadm upgrade plan |
||
394 | ** On one control plane node |
||
395 | * kubeadm upgrade apply vXX.YY.ZZ |
||
396 | ** On one control plane node |
||
397 | 189 | Nico Schottelius | * kubeadm upgrade node |
398 | ** On all other control plane nodes |
||
399 | ** On all worker nodes afterwards |
||
400 | |||
401 | 172 | Nico Schottelius | |
402 | 173 | Nico Schottelius | Repeat for all control planes nodes. The upgrade kubelet on all other nodes via package manager. |
403 | 172 | Nico Schottelius | |
404 | 188 | Nico Schottelius | h4. Upgrading to 1.26.6 |
405 | |||
406 | * https://v1-26.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/ |
||
407 | |||
408 | |||
409 | 186 | Nico Schottelius | h4. Upgrade to kubernetes 1.27 |
410 | |||
411 | * kubelet will not start anymore |
||
412 | * reason: @"command failed" err="failed to parse kubelet flag: unknown flag: --container-runtime"@ |
||
413 | * /var/lib/kubelet/kubeadm-flags.env contains that parameter |
||
414 | * remove it, start kubelet |
||
415 | |||
416 | h4. Upgrade to crio 1.27: missing crun |
||
417 | |||
418 | Error message |
||
419 | |||
420 | <pre> |
||
421 | level=fatal msg="validating runtime config: runtime validation: \"crun\" not found in $PATH: exec: \"crun\": executable file not found in $PATH" |
||
422 | </pre> |
||
423 | |||
424 | Fix: |
||
425 | |||
426 | <pre> |
||
427 | apk add crun |
||
428 | </pre> |
||
429 | |||
430 | 157 | Nico Schottelius | h2. Reference CNI |
431 | |||
432 | * Mainly "stupid", but effective plugins |
||
433 | * Main documentation on https://www.cni.dev/plugins/current/ |
||
434 | 158 | Nico Schottelius | * Plugins |
435 | ** bridge |
||
436 | *** Can create the bridge on the host |
||
437 | *** But seems not to be able to add host interfaces to it as well |
||
438 | *** Has support for vlan tags |
||
439 | ** vlan |
||
440 | *** creates vlan tagged sub interface on the host |
||
441 | 160 | Nico Schottelius | *** "It's a 1:1 mapping (i.e. no bridge in between)":https://github.com/k8snetworkplumbingwg/multus-cni/issues/569 |
442 | 158 | Nico Schottelius | ** host-device |
443 | *** moves the interface from the host into the container |
||
444 | *** very easy for physical connections to containers |
||
445 | 159 | Nico Schottelius | ** ipvlan |
446 | *** "virtualisation" of a host device |
||
447 | *** routing based on IP |
||
448 | *** Same MAC for everyone |
||
449 | *** Cannot reach the master interface |
||
450 | ** maclvan |
||
451 | *** With mac addresses |
||
452 | *** Supports various modes (to be checked) |
||
453 | ** ptp ("point to point") |
||
454 | *** Creates a host device and connects it to the container |
||
455 | ** win* |
||
456 | 158 | Nico Schottelius | *** Windows implementations |
457 | 157 | Nico Schottelius | |
458 | 62 | Nico Schottelius | h2. Calico CNI |
459 | |||
460 | h3. Calico Installation |
||
461 | |||
462 | * We install "calico using helm":https://docs.projectcalico.org/getting-started/kubernetes/helm |
||
463 | * This has the following advantages: |
||
464 | ** Easy to upgrade |
||
465 | ** Does not require os to configure IPv6/dual stack settings as the tigera operator figures out things on its own |
||
466 | |||
467 | Usually plain calico can be installed directly using: |
||
468 | |||
469 | <pre> |
||
470 | 174 | Nico Schottelius | VERSION=v3.25.0 |
471 | 149 | Nico Schottelius | |
472 | 1 | Nico Schottelius | helm repo add projectcalico https://docs.projectcalico.org/charts |
473 | 167 | Nico Schottelius | helm repo update |
474 | 124 | Nico Schottelius | helm upgrade --install --namespace tigera calico projectcalico/tigera-operator --version $VERSION --create-namespace |
475 | 1 | Nico Schottelius | </pre> |
476 | 92 | Nico Schottelius | |
477 | * Check the tags on https://github.com/projectcalico/calico/tags for the latest release |
||
478 | 62 | Nico Schottelius | |
479 | h3. Installing calicoctl |
||
480 | |||
481 | 115 | Nico Schottelius | * General installation instructions, including binary download: https://projectcalico.docs.tigera.io/maintenance/clis/calicoctl/install |
482 | |||
483 | 62 | Nico Schottelius | To be able to manage and configure calico, we need to |
484 | "install calicoctl (we choose the version as a pod)":https://docs.projectcalico.org/getting-started/clis/calicoctl/install#install-calicoctl-as-a-kubernetes-pod |
||
485 | |||
486 | <pre> |
||
487 | kubectl apply -f https://docs.projectcalico.org/manifests/calicoctl.yaml |
||
488 | </pre> |
||
489 | |||
490 | 93 | Nico Schottelius | Or version specific: |
491 | |||
492 | <pre> |
||
493 | kubectl apply -f https://github.com/projectcalico/calico/blob/v3.20.4/manifests/calicoctl.yaml |
||
494 | 97 | Nico Schottelius | |
495 | # For 3.22 |
||
496 | kubectl apply -f https://projectcalico.docs.tigera.io/archive/v3.22/manifests/calicoctl.yaml |
||
497 | 93 | Nico Schottelius | </pre> |
498 | |||
499 | 70 | Nico Schottelius | And making it easier accessible by alias: |
500 | |||
501 | <pre> |
||
502 | alias calicoctl="kubectl exec -i -n kube-system calicoctl -- /calicoctl" |
||
503 | </pre> |
||
504 | |||
505 | 62 | Nico Schottelius | h3. Calico configuration |
506 | |||
507 | 63 | Nico Schottelius | By default our k8s clusters "BGP peer":https://docs.projectcalico.org/networking/bgp |
508 | with an upstream router to propagate podcidr and servicecidr. |
||
509 | 62 | Nico Schottelius | |
510 | Default settings in our infrastructure: |
||
511 | |||
512 | * We use a full-mesh using the @nodeToNodeMeshEnabled: true@ option |
||
513 | * We keep the original next hop so that *only* the server with the pod is announcing it (instead of ecmp) |
||
514 | 1 | Nico Schottelius | * We use private ASNs for k8s clusters |
515 | 63 | Nico Schottelius | * We do *not* use any overlay |
516 | 62 | Nico Schottelius | |
517 | After installing calico and calicoctl the last step of the installation is usually: |
||
518 | |||
519 | 1 | Nico Schottelius | <pre> |
520 | 79 | Nico Schottelius | calicoctl create -f - < calico-bgp.yaml |
521 | 62 | Nico Schottelius | </pre> |
522 | |||
523 | |||
524 | A sample BGP configuration: |
||
525 | |||
526 | <pre> |
||
527 | --- |
||
528 | apiVersion: projectcalico.org/v3 |
||
529 | kind: BGPConfiguration |
||
530 | metadata: |
||
531 | name: default |
||
532 | spec: |
||
533 | logSeverityScreen: Info |
||
534 | nodeToNodeMeshEnabled: true |
||
535 | asNumber: 65534 |
||
536 | serviceClusterIPs: |
||
537 | - cidr: 2a0a:e5c0:10:3::/108 |
||
538 | serviceExternalIPs: |
||
539 | - cidr: 2a0a:e5c0:10:3::/108 |
||
540 | --- |
||
541 | apiVersion: projectcalico.org/v3 |
||
542 | kind: BGPPeer |
||
543 | metadata: |
||
544 | name: router1-place10 |
||
545 | spec: |
||
546 | peerIP: 2a0a:e5c0:10:1::50 |
||
547 | asNumber: 213081 |
||
548 | keepOriginalNextHop: true |
||
549 | </pre> |
||
550 | |||
551 | 126 | Nico Schottelius | h2. Cilium CNI (experimental) |
552 | |||
553 | 137 | Nico Schottelius | h3. Status |
554 | |||
555 | 138 | Nico Schottelius | *NO WORKING CILIUM CONFIGURATION FOR IPV6 only modes* |
556 | 137 | Nico Schottelius | |
557 | 146 | Nico Schottelius | h3. Latest error |
558 | |||
559 | It seems cilium does not run on IPv6 only hosts: |
||
560 | |||
561 | <pre> |
||
562 | level=info msg="Validating configured node address ranges" subsys=daemon |
||
563 | level=fatal msg="postinit failed" error="external IPv4 node address could not be derived, please configure via --ipv4-node" subsys=daemon |
||
564 | level=info msg="Starting IP identity watcher" subsys=ipcache |
||
565 | </pre> |
||
566 | |||
567 | It crashes after that log entry |
||
568 | |||
569 | 128 | Nico Schottelius | h3. BGP configuration |
570 | |||
571 | * The cilium-operator will not start without a correct configmap being present beforehand (see error message below) |
||
572 | * Creating the bgp config beforehand as a configmap is thus required. |
||
573 | |||
574 | The error one gets without the configmap present: |
||
575 | |||
576 | Pods are hanging with: |
||
577 | |||
578 | <pre> |
||
579 | cilium-bpqm6 0/1 Init:0/4 0 9s |
||
580 | cilium-operator-5947d94f7f-5bmh2 0/1 ContainerCreating 0 9s |
||
581 | </pre> |
||
582 | |||
583 | The error message in the cilium-*perator is: |
||
584 | |||
585 | <pre> |
||
586 | Events: |
||
587 | Type Reason Age From Message |
||
588 | ---- ------ ---- ---- ------- |
||
589 | Normal Scheduled 80s default-scheduler Successfully assigned kube-system/cilium-operator-5947d94f7f-lqcsp to server56 |
||
590 | Warning FailedMount 16s (x8 over 80s) kubelet MountVolume.SetUp failed for volume "bgp-config-path" : configmap "bgp-config" not found |
||
591 | </pre> |
||
592 | |||
593 | A correct bgp config looks like this: |
||
594 | |||
595 | <pre> |
||
596 | apiVersion: v1 |
||
597 | kind: ConfigMap |
||
598 | metadata: |
||
599 | name: bgp-config |
||
600 | namespace: kube-system |
||
601 | data: |
||
602 | config.yaml: | |
||
603 | peers: |
||
604 | - peer-address: 2a0a:e5c0::46 |
||
605 | peer-asn: 209898 |
||
606 | my-asn: 65533 |
||
607 | - peer-address: 2a0a:e5c0::47 |
||
608 | peer-asn: 209898 |
||
609 | my-asn: 65533 |
||
610 | address-pools: |
||
611 | - name: default |
||
612 | protocol: bgp |
||
613 | addresses: |
||
614 | - 2a0a:e5c0:0:14::/64 |
||
615 | </pre> |
||
616 | 127 | Nico Schottelius | |
617 | h3. Installation |
||
618 | 130 | Nico Schottelius | |
619 | 127 | Nico Schottelius | Adding the repo |
620 | 1 | Nico Schottelius | <pre> |
621 | 127 | Nico Schottelius | |
622 | 129 | Nico Schottelius | helm repo add cilium https://helm.cilium.io/ |
623 | 130 | Nico Schottelius | helm repo update |
624 | </pre> |
||
625 | 129 | Nico Schottelius | |
626 | 135 | Nico Schottelius | Installing + configuring cilium |
627 | 129 | Nico Schottelius | <pre> |
628 | 130 | Nico Schottelius | ipv6pool=2a0a:e5c0:0:14::/112 |
629 | 1 | Nico Schottelius | |
630 | 146 | Nico Schottelius | version=1.12.2 |
631 | 129 | Nico Schottelius | |
632 | helm upgrade --install cilium cilium/cilium --version $version \ |
||
633 | 1 | Nico Schottelius | --namespace kube-system \ |
634 | --set ipv4.enabled=false \ |
||
635 | --set ipv6.enabled=true \ |
||
636 | 146 | Nico Schottelius | --set enableIPv6Masquerade=false \ |
637 | --set bgpControlPlane.enabled=true |
||
638 | 1 | Nico Schottelius | |
639 | 146 | Nico Schottelius | # --set ipam.operator.clusterPoolIPv6PodCIDRList=$ipv6pool |
640 | |||
641 | # Old style bgp? |
||
642 | 136 | Nico Schottelius | # --set bgp.enabled=true --set bgp.announce.podCIDR=true \ |
643 | 127 | Nico Schottelius | |
644 | # Show possible configuration options |
||
645 | helm show values cilium/cilium |
||
646 | |||
647 | 1 | Nico Schottelius | </pre> |
648 | 132 | Nico Schottelius | |
649 | Using a /64 for ipam.operator.clusterPoolIPv6PodCIDRList fails with: |
||
650 | |||
651 | <pre> |
||
652 | level=fatal msg="Unable to init cluster-pool allocator" error="unable to initialize IPv6 allocator New CIDR set failed; the node CIDR size is too big" subsys=cilium-operator-generic |
||
653 | </pre> |
||
654 | |||
655 | 126 | Nico Schottelius | |
656 | 1 | Nico Schottelius | See also https://github.com/cilium/cilium/issues/20756 |
657 | 135 | Nico Schottelius | |
658 | Seems a /112 is actually working. |
||
659 | |||
660 | h3. Kernel modules |
||
661 | |||
662 | Cilium requires the following modules to be loaded on the host (not loaded by default): |
||
663 | |||
664 | <pre> |
||
665 | 1 | Nico Schottelius | modprobe ip6table_raw |
666 | modprobe ip6table_filter |
||
667 | </pre> |
||
668 | 146 | Nico Schottelius | |
669 | h3. Interesting helm flags |
||
670 | |||
671 | * autoDirectNodeRoutes |
||
672 | * bgpControlPlane.enabled = true |
||
673 | |||
674 | h3. SEE ALSO |
||
675 | |||
676 | * https://docs.cilium.io/en/v1.12/helm-reference/ |
||
677 | 133 | Nico Schottelius | |
678 | 179 | Nico Schottelius | h2. Multus |
679 | 168 | Nico Schottelius | |
680 | * https://github.com/k8snetworkplumbingwg/multus-cni |
||
681 | * Installing a deployment w/ CRDs |
||
682 | 150 | Nico Schottelius | |
683 | 169 | Nico Schottelius | <pre> |
684 | 176 | Nico Schottelius | VERSION=v4.0.1 |
685 | 169 | Nico Schottelius | |
686 | 170 | Nico Schottelius | kubectl apply -f https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/${VERSION}/deployments/multus-daemonset-crio.yml |
687 | </pre> |
||
688 | 169 | Nico Schottelius | |
689 | 122 | Nico Schottelius | h2. ArgoCD |
690 | 56 | Nico Schottelius | |
691 | 60 | Nico Schottelius | h3. Argocd Installation |
692 | 1 | Nico Schottelius | |
693 | 116 | Nico Schottelius | * See https://argo-cd.readthedocs.io/en/stable/ |
694 | |||
695 | 60 | Nico Schottelius | As there is no configuration management present yet, argocd is installed using |
696 | |||
697 | 1 | Nico Schottelius | <pre> |
698 | 60 | Nico Schottelius | kubectl create namespace argocd |
699 | 86 | Nico Schottelius | |
700 | 96 | Nico Schottelius | # Specific Version |
701 | kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.3.2/manifests/install.yaml |
||
702 | 86 | Nico Schottelius | |
703 | # OR: latest stable |
||
704 | 60 | Nico Schottelius | kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml |
705 | 56 | Nico Schottelius | </pre> |
706 | 1 | Nico Schottelius | |
707 | 116 | Nico Schottelius | |
708 | 1 | Nico Schottelius | |
709 | 60 | Nico Schottelius | h3. Get the argocd credentials |
710 | |||
711 | <pre> |
||
712 | kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo "" |
||
713 | </pre> |
||
714 | 52 | Nico Schottelius | |
715 | 87 | Nico Schottelius | h3. Accessing argocd |
716 | |||
717 | In regular IPv6 clusters: |
||
718 | |||
719 | * Navigate to https://argocd-server.argocd.CLUSTERDOMAIN |
||
720 | |||
721 | In legacy IPv4 clusters |
||
722 | |||
723 | <pre> |
||
724 | kubectl --namespace argocd port-forward svc/argocd-server 8080:80 |
||
725 | </pre> |
||
726 | |||
727 | 88 | Nico Schottelius | * Navigate to https://localhost:8080 |
728 | |||
729 | 68 | Nico Schottelius | h3. Using the argocd webhook to trigger changes |
730 | 67 | Nico Schottelius | |
731 | * To trigger changes post json https://argocd.example.com/api/webhook |
||
732 | |||
733 | 72 | Nico Schottelius | h3. Deploying an application |
734 | |||
735 | * Applications are deployed via git towards gitea (code.ungleich.ch) and then pulled by argo |
||
736 | 73 | Nico Schottelius | * Always include the *redmine-url* pointing to the (customer) ticket |
737 | ** Also add the support-url if it exists |
||
738 | 72 | Nico Schottelius | |
739 | Application sample |
||
740 | |||
741 | <pre> |
||
742 | apiVersion: argoproj.io/v1alpha1 |
||
743 | kind: Application |
||
744 | metadata: |
||
745 | name: gitea-CUSTOMER |
||
746 | namespace: argocd |
||
747 | spec: |
||
748 | destination: |
||
749 | namespace: default |
||
750 | server: 'https://kubernetes.default.svc' |
||
751 | source: |
||
752 | path: apps/prod/gitea |
||
753 | repoURL: 'https://code.ungleich.ch/ungleich-intern/k8s-config.git' |
||
754 | targetRevision: HEAD |
||
755 | helm: |
||
756 | parameters: |
||
757 | - name: storage.data.storageClass |
||
758 | value: rook-ceph-block-hdd |
||
759 | - name: storage.data.size |
||
760 | value: 200Gi |
||
761 | - name: storage.db.storageClass |
||
762 | value: rook-ceph-block-ssd |
||
763 | - name: storage.db.size |
||
764 | value: 10Gi |
||
765 | - name: storage.letsencrypt.storageClass |
||
766 | value: rook-ceph-block-hdd |
||
767 | - name: storage.letsencrypt.size |
||
768 | value: 50Mi |
||
769 | - name: letsencryptStaging |
||
770 | value: 'no' |
||
771 | - name: fqdn |
||
772 | value: 'code.verua.online' |
||
773 | project: default |
||
774 | syncPolicy: |
||
775 | automated: |
||
776 | prune: true |
||
777 | selfHeal: true |
||
778 | info: |
||
779 | - name: 'redmine-url' |
||
780 | value: 'https://redmine.ungleich.ch/issues/ISSUEID' |
||
781 | - name: 'support-url' |
||
782 | value: 'https://support.ungleich.ch/Ticket/Display.html?id=TICKETID' |
||
783 | </pre> |
||
784 | |||
785 | 80 | Nico Schottelius | h2. Helm related operations and conventions |
786 | 55 | Nico Schottelius | |
787 | 61 | Nico Schottelius | We use helm charts extensively. |
788 | |||
789 | * In production, they are managed via argocd |
||
790 | * In development, helm chart can de developed and deployed manually using the helm utility. |
||
791 | |||
792 | 55 | Nico Schottelius | h3. Installing a helm chart |
793 | |||
794 | One can use the usual pattern of |
||
795 | |||
796 | <pre> |
||
797 | helm install <releasename> <chartdirectory> |
||
798 | </pre> |
||
799 | |||
800 | However often you want to reinstall/update when testing helm charts. The following pattern is "better", because it allows you to reinstall, if it is already installed: |
||
801 | |||
802 | <pre> |
||
803 | helm upgrade --install <releasename> <chartdirectory> |
||
804 | 1 | Nico Schottelius | </pre> |
805 | 80 | Nico Schottelius | |
806 | h3. Naming services and deployments in helm charts [Application labels] |
||
807 | |||
808 | * We always have {{ .Release.Name }} to identify the current "instance" |
||
809 | * Deployments: |
||
810 | ** use @app: <what it is>@, f.i. @app: nginx@, @app: postgres@, ... |
||
811 | 81 | Nico Schottelius | * See more about standard labels on |
812 | ** https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ |
||
813 | ** https://helm.sh/docs/chart_best_practices/labels/ |
||
814 | 55 | Nico Schottelius | |
815 | 151 | Nico Schottelius | h3. Show all versions of a helm chart |
816 | |||
817 | <pre> |
||
818 | helm search repo -l repo/chart |
||
819 | </pre> |
||
820 | |||
821 | For example: |
||
822 | |||
823 | <pre> |
||
824 | % helm search repo -l projectcalico/tigera-operator |
||
825 | NAME CHART VERSION APP VERSION DESCRIPTION |
||
826 | projectcalico/tigera-operator v3.23.3 v3.23.3 Installs the Tigera operator for Calico |
||
827 | projectcalico/tigera-operator v3.23.2 v3.23.2 Installs the Tigera operator for Calico |
||
828 | .... |
||
829 | </pre> |
||
830 | |||
831 | 152 | Nico Schottelius | h3. Show possible values of a chart |
832 | |||
833 | <pre> |
||
834 | helm show values <repo/chart> |
||
835 | </pre> |
||
836 | |||
837 | Example: |
||
838 | |||
839 | <pre> |
||
840 | helm show values ingress-nginx/ingress-nginx |
||
841 | </pre> |
||
842 | |||
843 | 178 | Nico Schottelius | h3. Download a chart |
844 | |||
845 | For instance for checking it out locally. Use: |
||
846 | |||
847 | <pre> |
||
848 | helm pull <repo/chart> |
||
849 | </pre> |
||
850 | 152 | Nico Schottelius | |
851 | 139 | Nico Schottelius | h2. Rook + Ceph |
852 | |||
853 | h3. Installation |
||
854 | |||
855 | * Usually directly via argocd |
||
856 | |||
857 | 71 | Nico Schottelius | h3. Executing ceph commands |
858 | |||
859 | Using the ceph-tools pod as follows: |
||
860 | |||
861 | <pre> |
||
862 | kubectl exec -n rook-ceph -ti $(kubectl -n rook-ceph get pods -l app=rook-ceph-tools -o jsonpath='{.items[*].metadata.name}') -- ceph -s |
||
863 | </pre> |
||
864 | |||
865 | 43 | Nico Schottelius | h3. Inspecting the logs of a specific server |
866 | |||
867 | <pre> |
||
868 | # Get the related pods |
||
869 | kubectl -n rook-ceph get pods -l app=rook-ceph-osd-prepare |
||
870 | ... |
||
871 | |||
872 | # Inspect the logs of a specific pod |
||
873 | kubectl -n rook-ceph logs -f rook-ceph-osd-prepare-server23--1-444qx |
||
874 | |||
875 | 71 | Nico Schottelius | </pre> |
876 | |||
877 | h3. Inspecting the logs of the rook-ceph-operator |
||
878 | |||
879 | <pre> |
||
880 | kubectl -n rook-ceph logs -f -l app=rook-ceph-operator |
||
881 | 43 | Nico Schottelius | </pre> |
882 | |||
883 | 121 | Nico Schottelius | h3. Restarting the rook operator |
884 | |||
885 | <pre> |
||
886 | kubectl -n rook-ceph delete pods -l app=rook-ceph-operator |
||
887 | </pre> |
||
888 | |||
889 | 43 | Nico Schottelius | h3. Triggering server prepare / adding new osds |
890 | |||
891 | The rook-ceph-operator triggers/watches/creates pods to maintain hosts. To trigger a full "re scan", simply delete that pod: |
||
892 | |||
893 | <pre> |
||
894 | kubectl -n rook-ceph delete pods -l app=rook-ceph-operator |
||
895 | </pre> |
||
896 | |||
897 | This will cause all the @rook-ceph-osd-prepare-..@ jobs to be recreated and thus OSDs to be created, if new disks have been added. |
||
898 | |||
899 | h3. Removing an OSD |
||
900 | |||
901 | * See "Ceph OSD Management":https://rook.io/docs/rook/v1.7/ceph-osd-mgmt.html |
||
902 | 77 | Nico Schottelius | * More specifically: https://github.com/rook/rook/blob/release-1.7/cluster/examples/kubernetes/ceph/osd-purge.yaml |
903 | 99 | Nico Schottelius | * Then delete the related deployment |
904 | 41 | Nico Schottelius | |
905 | 98 | Nico Schottelius | Set osd id in the osd-purge.yaml and apply it. OSD should be down before. |
906 | |||
907 | <pre> |
||
908 | apiVersion: batch/v1 |
||
909 | kind: Job |
||
910 | metadata: |
||
911 | name: rook-ceph-purge-osd |
||
912 | namespace: rook-ceph # namespace:cluster |
||
913 | labels: |
||
914 | app: rook-ceph-purge-osd |
||
915 | spec: |
||
916 | template: |
||
917 | metadata: |
||
918 | labels: |
||
919 | app: rook-ceph-purge-osd |
||
920 | spec: |
||
921 | serviceAccountName: rook-ceph-purge-osd |
||
922 | containers: |
||
923 | - name: osd-removal |
||
924 | image: rook/ceph:master |
||
925 | # TODO: Insert the OSD ID in the last parameter that is to be removed |
||
926 | # The OSD IDs are a comma-separated list. For example: "0" or "0,2". |
||
927 | # If you want to preserve the OSD PVCs, set `--preserve-pvc true`. |
||
928 | # |
||
929 | # A --force-osd-removal option is available if the OSD should be destroyed even though the |
||
930 | # removal could lead to data loss. |
||
931 | args: |
||
932 | - "ceph" |
||
933 | - "osd" |
||
934 | - "remove" |
||
935 | - "--preserve-pvc" |
||
936 | - "false" |
||
937 | - "--force-osd-removal" |
||
938 | - "false" |
||
939 | - "--osd-ids" |
||
940 | - "SETTHEOSDIDHERE" |
||
941 | env: |
||
942 | - name: POD_NAMESPACE |
||
943 | valueFrom: |
||
944 | fieldRef: |
||
945 | fieldPath: metadata.namespace |
||
946 | - name: ROOK_MON_ENDPOINTS |
||
947 | valueFrom: |
||
948 | configMapKeyRef: |
||
949 | key: data |
||
950 | name: rook-ceph-mon-endpoints |
||
951 | - name: ROOK_CEPH_USERNAME |
||
952 | valueFrom: |
||
953 | secretKeyRef: |
||
954 | key: ceph-username |
||
955 | name: rook-ceph-mon |
||
956 | - name: ROOK_CEPH_SECRET |
||
957 | valueFrom: |
||
958 | secretKeyRef: |
||
959 | key: ceph-secret |
||
960 | name: rook-ceph-mon |
||
961 | - name: ROOK_CONFIG_DIR |
||
962 | value: /var/lib/rook |
||
963 | - name: ROOK_CEPH_CONFIG_OVERRIDE |
||
964 | value: /etc/rook/config/override.conf |
||
965 | - name: ROOK_FSID |
||
966 | valueFrom: |
||
967 | secretKeyRef: |
||
968 | key: fsid |
||
969 | name: rook-ceph-mon |
||
970 | - name: ROOK_LOG_LEVEL |
||
971 | value: DEBUG |
||
972 | volumeMounts: |
||
973 | - mountPath: /etc/ceph |
||
974 | name: ceph-conf-emptydir |
||
975 | - mountPath: /var/lib/rook |
||
976 | name: rook-config |
||
977 | volumes: |
||
978 | - emptyDir: {} |
||
979 | name: ceph-conf-emptydir |
||
980 | - emptyDir: {} |
||
981 | name: rook-config |
||
982 | restartPolicy: Never |
||
983 | |||
984 | |||
985 | 99 | Nico Schottelius | </pre> |
986 | |||
987 | 1 | Nico Schottelius | Deleting the deployment: |
988 | |||
989 | <pre> |
||
990 | [18:05] bridge:~% kubectl -n rook-ceph delete deployment rook-ceph-osd-6 |
||
991 | 99 | Nico Schottelius | deployment.apps "rook-ceph-osd-6" deleted |
992 | </pre> |
||
993 | 185 | Nico Schottelius | |
994 | h3. Placement of mons/osds/etc. |
||
995 | |||
996 | See https://rook.io/docs/rook/v1.11/CRDs/Cluster/ceph-cluster-crd/#placement-configuration-settings |
||
997 | 98 | Nico Schottelius | |
998 | 145 | Nico Schottelius | h2. Ingress + Cert Manager |
999 | |||
1000 | * We deploy "nginx-ingress":https://docs.nginx.com/nginx-ingress-controller/ to get an ingress |
||
1001 | * we deploy "cert-manager":https://cert-manager.io/ to handle certificates |
||
1002 | * We independently deploy @ClusterIssuer@ to allow the cert-manager app to deploy and the issuer to be created once the CRDs from cert manager are in place |
||
1003 | |||
1004 | h3. IPv4 reachability |
||
1005 | |||
1006 | The ingress is by default IPv6 only. To make it reachable from the IPv4 world, get its IPv6 address and configure a NAT64 mapping in Jool. |
||
1007 | |||
1008 | Steps: |
||
1009 | |||
1010 | h4. Get the ingress IPv6 address |
||
1011 | |||
1012 | Use @kubectl -n ingress-nginx get svc ingress-nginx-controller -o jsonpath='{.spec.clusterIP}'; echo ''@ |
||
1013 | |||
1014 | Example: |
||
1015 | |||
1016 | <pre> |
||
1017 | kubectl -n ingress-nginx get svc ingress-nginx-controller -o jsonpath='{.spec.clusterIP}'; echo '' |
||
1018 | 2a0a:e5c0:10:1b::ce11 |
||
1019 | </pre> |
||
1020 | |||
1021 | h4. Add NAT64 mapping |
||
1022 | |||
1023 | * Update the __dcl_jool_siit cdist type |
||
1024 | * Record the two IPs (IPv6 and IPv4) |
||
1025 | * Configure all routers |
||
1026 | |||
1027 | |||
1028 | h4. Add DNS record |
||
1029 | |||
1030 | To use the ingress capable as a CNAME destination, create an "ingress" DNS record, such as: |
||
1031 | |||
1032 | <pre> |
||
1033 | ; k8s ingress for dev |
||
1034 | dev-ingress AAAA 2a0a:e5c0:10:1b::ce11 |
||
1035 | dev-ingress A 147.78.194.23 |
||
1036 | |||
1037 | </pre> |
||
1038 | |||
1039 | h4. Add supporting wildcard DNS |
||
1040 | |||
1041 | If you plan to add various sites under a specific domain, we can add a wildcard DNS entry, such as *.k8s-dev.django-hosting.ch: |
||
1042 | |||
1043 | <pre> |
||
1044 | *.k8s-dev CNAME dev-ingress.ungleich.ch. |
||
1045 | </pre> |
||
1046 | |||
1047 | 76 | Nico Schottelius | h2. Harbor |
1048 | |||
1049 | 175 | Nico Schottelius | * We user "Harbor":https://goharbor.io/ as an image registry for our own images. Internal app reference: apps/prod/harbor. |
1050 | * The admin password is in the password store, it is Harbor12345 by default |
||
1051 | 76 | Nico Schottelius | * At the moment harbor only authenticates against the internal ldap tree |
1052 | |||
1053 | h3. LDAP configuration |
||
1054 | |||
1055 | * The url needs to be ldaps://... |
||
1056 | * uid = uid |
||
1057 | * rest standard |
||
1058 | 75 | Nico Schottelius | |
1059 | 89 | Nico Schottelius | h2. Monitoring / Prometheus |
1060 | |||
1061 | 90 | Nico Schottelius | * Via "kube-prometheus":https://github.com/prometheus-operator/kube-prometheus/ |
1062 | 89 | Nico Schottelius | |
1063 | 91 | Nico Schottelius | Access via ... |
1064 | |||
1065 | * http://prometheus-k8s.monitoring.svc:9090 |
||
1066 | * http://grafana.monitoring.svc:3000 |
||
1067 | * http://alertmanager.monitoring.svc:9093 |
||
1068 | |||
1069 | |||
1070 | 100 | Nico Schottelius | h3. Prometheus Options |
1071 | |||
1072 | * "helm/kube-prometheus-stack":https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack |
||
1073 | ** Includes dashboards and co. |
||
1074 | * "manifest based kube-prometheus":https://github.com/prometheus-operator/kube-prometheus |
||
1075 | ** Includes dashboards and co. |
||
1076 | * "Prometheus Operator (mainly CRD manifest":https://github.com/prometheus-operator/prometheus-operator |
||
1077 | |||
1078 | 171 | Nico Schottelius | h3. Grafana default password |
1079 | |||
1080 | * If not changed: @prom-operator@ |
||
1081 | |||
1082 | 82 | Nico Schottelius | h2. Nextcloud |
1083 | |||
1084 | 85 | Nico Schottelius | h3. How to get the nextcloud credentials |
1085 | 84 | Nico Schottelius | |
1086 | * The initial username is set to "nextcloud" |
||
1087 | * The password is autogenerated and saved in a kubernetes secret |
||
1088 | |||
1089 | <pre> |
||
1090 | 85 | Nico Schottelius | kubectl get secret RELEASENAME-nextcloud -o jsonpath="{.data.PASSWORD}" | base64 -d; echo "" |
1091 | 84 | Nico Schottelius | </pre> |
1092 | |||
1093 | 83 | Nico Schottelius | h3. How to fix "Access through untrusted domain" |
1094 | |||
1095 | 82 | Nico Schottelius | * Nextcloud stores the initial domain configuration |
1096 | 1 | Nico Schottelius | * If the FQDN is changed, it will show the error message "Access through untrusted domain" |
1097 | 82 | Nico Schottelius | * To fix, edit /var/www/html/config/config.php and correct the domain |
1098 | 1 | Nico Schottelius | * Then delete the pods |
1099 | 165 | Nico Schottelius | |
1100 | h3. Running occ commands inside the nextcloud container |
||
1101 | |||
1102 | * Find the pod in the right namespace |
||
1103 | |||
1104 | Exec: |
||
1105 | |||
1106 | <pre> |
||
1107 | su www-data -s /bin/sh -c ./occ |
||
1108 | </pre> |
||
1109 | |||
1110 | * -s /bin/sh is needed as the default shell is set to /bin/false |
||
1111 | |||
1112 | 166 | Nico Schottelius | h4. Rescanning files |
1113 | 165 | Nico Schottelius | |
1114 | 166 | Nico Schottelius | * If files have been added without nextcloud's knowledge |
1115 | |||
1116 | <pre> |
||
1117 | su www-data -s /bin/sh -c "./occ files:scan --all" |
||
1118 | </pre> |
||
1119 | 82 | Nico Schottelius | |
1120 | 1 | Nico Schottelius | h2. Infrastructure versions |
1121 | 35 | Nico Schottelius | |
1122 | 57 | Nico Schottelius | h3. ungleich kubernetes infrastructure v5 (2021-10) |
1123 | 1 | Nico Schottelius | |
1124 | 57 | Nico Schottelius | Clusters are configured / setup in this order: |
1125 | |||
1126 | * Bootstrap via kubeadm |
||
1127 | 59 | Nico Schottelius | * "Networking via calico + BGP (non ECMP) using helm":https://docs.projectcalico.org/getting-started/kubernetes/helm |
1128 | * "ArgoCD for CD":https://argo-cd.readthedocs.io/en/stable/ |
||
1129 | ** "rook for storage via argocd":https://rook.io/ |
||
1130 | 58 | Nico Schottelius | ** haproxy for in IPv6-cluster-IPv4-to-IPv6 proxy via argocd |
1131 | ** "kubernetes-secret-generator for in cluster secrets":https://github.com/mittwald/kubernetes-secret-generator |
||
1132 | ** "ungleich-certbot managing certs and nginx":https://hub.docker.com/repository/docker/ungleich/ungleich-certbot |
||
1133 | |||
1134 | 57 | Nico Schottelius | |
1135 | h3. ungleich kubernetes infrastructure v4 (2021-09) |
||
1136 | |||
1137 | 54 | Nico Schottelius | * rook is configured via manifests instead of using the rook-ceph-cluster helm chart |
1138 | 1 | Nico Schottelius | * The rook operator is still being installed via helm |
1139 | 35 | Nico Schottelius | |
1140 | 57 | Nico Schottelius | h3. ungleich kubernetes infrastructure v3 (2021-07) |
1141 | 1 | Nico Schottelius | |
1142 | 10 | Nico Schottelius | * rook is now installed via helm via argocd instead of directly via manifests |
1143 | 28 | Nico Schottelius | |
1144 | 57 | Nico Schottelius | h3. ungleich kubernetes infrastructure v2 (2021-05) |
1145 | 28 | Nico Schottelius | |
1146 | * Replaced fluxv2 from ungleich k8s v1 with argocd |
||
1147 | 1 | Nico Schottelius | ** argocd can apply helm templates directly without needing to go through Chart releases |
1148 | 28 | Nico Schottelius | * We are also using argoflow for build flows |
1149 | * Planned to add "kaniko":https://github.com/GoogleContainerTools/kaniko for image building |
||
1150 | |||
1151 | 57 | Nico Schottelius | h3. ungleich kubernetes infrastructure v1 (2021-01) |
1152 | 28 | Nico Schottelius | |
1153 | We are using the following components: |
||
1154 | |||
1155 | * "Calico as a CNI":https://www.projectcalico.org/ with BGP, IPv6 only, no encapsulation |
||
1156 | ** Needed for basic networking |
||
1157 | * "kubernetes-secret-generator":https://github.com/mittwald/kubernetes-secret-generator for creating secrets |
||
1158 | ** Needed so that secrets are not stored in the git repository, but only in the cluster |
||
1159 | * "ungleich-certbot":https://hub.docker.com/repository/docker/ungleich/ungleich-certbot |
||
1160 | ** Needed to get letsencrypt certificates for services |
||
1161 | * "rook with ceph rbd + cephfs":https://rook.io/ for storage |
||
1162 | ** rbd for almost everything, *ReadWriteOnce* |
||
1163 | ** cephfs for smaller things, multi access *ReadWriteMany* |
||
1164 | ** Needed for providing persistent storage |
||
1165 | * "flux v2":https://fluxcd.io/ |
||
1166 | ** Needed to manage resources automatically |