Project

General

Profile

The ungleich kubernetes infrastructure » History » Version 101

Nico Schottelius, 05/21/2022 06:44 PM

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 95 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
| [[p6.k8s.ooo]]  | production        |            | server67 server69 server71 | "argo":https://argocd-server.argocd.svc.p6.k8s.ooo  | 147.78.194.13 |    2021-10-05 |
22
| [[p10.k8s.ooo]] | production        |            | server63 server65 server83 | "argo":https://argocd-server.argocd.svc.p10.k8s.ooo | 147.78.194.12 |    2021-10-05 |
23
| fnnf            | development       | Nico       | server75                   |                                                     |               |               |
24 78 Nico Schottelius
25 21 Nico Schottelius
26 1 Nico Schottelius
h2. General architecture and components overview
27
28
* All k8s clusters are IPv6 only
29
* We use BGP peering to propagate podcidr and serviceCidr networks to our infrastructure
30
* The main public testing repository is "ungleich-k8s":https://code.ungleich.ch/ungleich-public/ungleich-k8s
31 18 Nico Schottelius
** Private configurations are found in the **k8s-config** repository
32 1 Nico Schottelius
33
h3. Cluster types
34
35 28 Nico Schottelius
| **Type/Feature**            | **Development**                | **Production**         |
36
| Min No. nodes               | 3 (1 master, 3 worker)         | 5 (3 master, 3 worker) |
37
| Recommended minimum         | 4 (dedicated master, 3 worker) | 8 (3 master, 5 worker) |
38
| Separation of control plane | optional                       | recommended            |
39
| Persistent storage          | required                       | required               |
40
| Number of storage monitors  | 3                              | 5                      |
41 1 Nico Schottelius
42 43 Nico Schottelius
h2. General k8s operations
43 1 Nico Schottelius
44 46 Nico Schottelius
h3. Cheat sheet / external great references
45
46
* "kubectl cheatsheet":https://kubernetes.io/docs/reference/kubectl/cheatsheet/
47
48 69 Nico Schottelius
h3. Allowing to schedule work on the control plane
49
50
* Mostly for single node / test / development clusters
51
* Just remove the master taint as follows
52
53
<pre>
54
kubectl taint nodes --all node-role.kubernetes.io/master-
55
</pre>
56
57
58 44 Nico Schottelius
h3. Get the cluster admin.conf
59
60
* On the masters of each cluster you can find the file @/etc/kubernetes/admin.conf@
61
* To be able to administrate the cluster you can copy the admin.conf to your local machine
62
* Multi cluster debugging can very easy if you name the config ~/cX-admin.conf (see example below)
63
64
<pre>
65
% scp root@server47.place7.ungleich.ch:/etc/kubernetes/admin.conf ~/c2-admin.conf
66
% export KUBECONFIG=~/c2-admin.conf    
67
% kubectl get nodes
68
NAME       STATUS                     ROLES                  AGE   VERSION
69
server47   Ready                      control-plane,master   82d   v1.22.0
70
server48   Ready                      control-plane,master   82d   v1.22.0
71
server49   Ready                      <none>                 82d   v1.22.0
72
server50   Ready                      <none>                 82d   v1.22.0
73
server59   Ready                      control-plane,master   82d   v1.22.0
74
server60   Ready,SchedulingDisabled   <none>                 82d   v1.22.0
75
server61   Ready                      <none>                 82d   v1.22.0
76
server62   Ready                      <none>                 82d   v1.22.0               
77
</pre>
78
79 18 Nico Schottelius
h3. Installing a new k8s cluster
80 8 Nico Schottelius
81 9 Nico Schottelius
* Decide on the cluster name (usually *cX.k8s.ooo*), X counting upwards
82 28 Nico Schottelius
** Using pXX.k8s.ooo for production clusters of placeXX
83 9 Nico Schottelius
* Use cdist to configure the nodes with requirements like crio
84
* Decide between single or multi node control plane setups (see below)
85 28 Nico Schottelius
** Single control plane suitable for development clusters
86 9 Nico Schottelius
87 28 Nico Schottelius
Typical init procedure:
88 9 Nico Schottelius
89 28 Nico Schottelius
* Single control plane: @kubeadm init --config bootstrap/XXX/kubeadm.yaml@
90
* Multi control plane (HA): @kubeadm init --config bootstrap/XXX/kubeadm.yaml --upload-certs@
91 10 Nico Schottelius
92 29 Nico Schottelius
h3. Deleting a pod that is hanging in terminating state
93
94
<pre>
95
kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>
96
</pre>
97
98
(from https://stackoverflow.com/questions/35453792/pods-stuck-in-terminating-status)
99
100 42 Nico Schottelius
h3. Listing nodes of a cluster
101
102
<pre>
103
[15:05] bridge:~% kubectl get nodes
104
NAME       STATUS   ROLES                  AGE   VERSION
105
server22   Ready    <none>                 52d   v1.22.0
106
server23   Ready    <none>                 52d   v1.22.2
107
server24   Ready    <none>                 52d   v1.22.0
108
server25   Ready    <none>                 52d   v1.22.0
109
server26   Ready    <none>                 52d   v1.22.0
110
server27   Ready    <none>                 52d   v1.22.0
111
server63   Ready    control-plane,master   52d   v1.22.0
112
server64   Ready    <none>                 52d   v1.22.0
113
server65   Ready    control-plane,master   52d   v1.22.0
114
server66   Ready    <none>                 52d   v1.22.0
115
server83   Ready    control-plane,master   52d   v1.22.0
116
server84   Ready    <none>                 52d   v1.22.0
117
server85   Ready    <none>                 52d   v1.22.0
118
server86   Ready    <none>                 52d   v1.22.0
119
</pre>
120
121
122 41 Nico Schottelius
h3. Removing / draining a node
123
124
Usually @kubectl drain server@ should do the job, but sometimes we need to be more aggressive:
125
126
<pre>
127
kubectl drain --delete-emptydir-data --ignore-daemonsets server23
128 42 Nico Schottelius
</pre>
129
130
h3. Readding a node after draining
131
132
<pre>
133
kubectl uncordon serverXX
134 1 Nico Schottelius
</pre>
135 43 Nico Schottelius
136 50 Nico Schottelius
h3. (Re-)joining worker nodes after creating the cluster
137 49 Nico Schottelius
138
* We need to have an up-to-date token
139
* We use different join commands for the workers and control plane nodes
140
141
Generating the join command on an existing control plane node:
142
143
<pre>
144
kubeadm token create --print-join-command
145
</pre>
146
147 50 Nico Schottelius
h3. (Re-)joining control plane nodes after creating the cluster
148 1 Nico Schottelius
149 50 Nico Schottelius
* We generate the token again
150
* We upload the certificates
151
* We need to combine/create the join command for the control plane node
152
153
Example session:
154
155
<pre>
156
% kubeadm token create --print-join-command
157
kubeadm join p10-api.k8s.ooo:6443 --token xmff4i.ABC --discovery-token-ca-cert-hash sha256:longhash 
158
159
% kubeadm init phase upload-certs --upload-certs
160
[upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
161
[upload-certs] Using certificate key:
162
CERTKEY
163
164
# Then we use these two outputs on the joining node:
165
166
kubeadm join p10-api.k8s.ooo:6443 --token xmff4i.ABC --discovery-token-ca-cert-hash sha256:longhash --control-plane --certificate-key CERTKEY
167
</pre>
168
169
Commands to be used on a control plane node:
170
171
<pre>
172
kubeadm token create --print-join-command
173
kubeadm init phase upload-certs --upload-certs
174
</pre>
175
176
Commands to be used on the joining node:
177
178
<pre>
179
JOINCOMMAND --control-plane --certificate-key CERTKEY
180
</pre>
181 49 Nico Schottelius
182 51 Nico Schottelius
SEE ALSO
183
184
* https://stackoverflow.com/questions/63936268/how-to-generate-kubeadm-token-for-secondary-control-plane-nodes
185
* https://blog.scottlowe.org/2019/08/15/reconstructing-the-join-command-for-kubeadm/
186
187 53 Nico Schottelius
h3. How to fix etcd does not start when rejoining a kubernetes cluster as a control plane
188 52 Nico Schottelius
189
If during the above step etcd does not come up, @kubeadm join@ can hang as follows:
190
191
<pre>
192
[control-plane] Creating static Pod manifest for "kube-apiserver"                                                              
193
[control-plane] Creating static Pod manifest for "kube-controller-manager"                                                     
194
[control-plane] Creating static Pod manifest for "kube-scheduler"                                                              
195
[check-etcd] Checking that the etcd cluster is healthy                                                                         
196
error execution phase check-etcd: etcd cluster is not healthy: failed to dial endpoint https://[2a0a:e5c0:10:1:225:b3ff:fe20:37
197
8a]:2379 with maintenance client: context deadline exceeded                                                                    
198
To see the stack trace of this error execute with --v=5 or higher         
199
</pre>
200
201
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.
202
203
To fix this we do:
204
205
* Find a working etcd pod
206
* Find the etcd members / member list
207
* Remove the etcd member that we want to re-join the cluster
208
209
210
<pre>
211
# Find the etcd pods
212
kubectl -n kube-system get pods -l component=etcd,tier=control-plane
213
214
# Get the list of etcd servers with the member id 
215
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
216
217
# Remove the member
218
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
219
</pre>
220
221
Sample session:
222
223
<pre>
224
[10:48] line:~% kubectl -n kube-system get pods -l component=etcd,tier=control-plane
225
NAME            READY   STATUS    RESTARTS     AGE
226
etcd-server63   1/1     Running   0            3m11s
227
etcd-server65   1/1     Running   3            7d2h
228
etcd-server83   1/1     Running   8 (6d ago)   7d2h
229
[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
230
356891cd676df6e4, started, server65, https://[2a0a:e5c0:10:1:225:b3ff:fe20:375c]:2380, https://[2a0a:e5c0:10:1:225:b3ff:fe20:375c]:2379, false
231
371b8a07185dee7e, started, server63, https://[2a0a:e5c0:10:1:225:b3ff:fe20:378a]:2380, https://[2a0a:e5c0:10:1:225:b3ff:fe20:378a]:2379, false
232
5942bc58307f8af9, started, server83, https://[2a0a:e5c0:10:1:3e4a:92ff:fe79:bb98]:2380, https://[2a0a:e5c0:10:1:3e4a:92ff:fe79:bb98]:2379, false
233
234
[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
235
Member 371b8a07185dee7e removed from cluster e3c0805f592a8f77
236 1 Nico Schottelius
237
</pre>
238
239
SEE ALSO
240
241
* We found the solution using https://stackoverflow.com/questions/67921552/re-installed-node-cannot-join-kubernetes-cluster
242 56 Nico Schottelius
243 101 Nico Schottelius
h3. Hardware Maintenance using ungleich-hardware
244
245
Use the following manifest and replace the HOST with the actual host:
246
247
<pre>
248
apiVersion: v1
249
kind: Pod
250
metadata:
251
  name: ungleich-hardware-HOST
252
spec:
253
  containers:
254
  - name: ungleich-hardware
255
    image: ungleich/ungleich-hardware:0.0.5
256
    args:
257
    - sleep
258
    - "1000000"
259
    volumeMounts:
260
      - mountPath: /dev
261
        name: dev
262
    securityContext:
263
      privileged: true
264
  nodeSelector:
265
    kubernetes.io/hostname: "HOST"
266
267
  volumes:
268
    - name: dev
269
      hostPath:
270
        path: /dev
271
</pre>
272
273 62 Nico Schottelius
h2. Calico CNI
274
275
h3. Calico Installation
276
277
* We install "calico using helm":https://docs.projectcalico.org/getting-started/kubernetes/helm
278
* This has the following advantages:
279
** Easy to upgrade
280
** Does not require os to configure IPv6/dual stack settings as the tigera operator figures out things on its own
281
282
Usually plain calico can be installed directly using:
283
284
<pre>
285
helm repo add projectcalico https://docs.projectcalico.org/charts
286 94 Nico Schottelius
helm install calico projectcalico/tigera-operator --version v3.20.4
287 1 Nico Schottelius
</pre>
288 92 Nico Schottelius
289
* Check the tags on https://github.com/projectcalico/calico/tags for the latest release
290 62 Nico Schottelius
291
h3. Installing calicoctl
292
293
To be able to manage and configure calico, we need to 
294
"install calicoctl (we choose the version as a pod)":https://docs.projectcalico.org/getting-started/clis/calicoctl/install#install-calicoctl-as-a-kubernetes-pod
295
296
<pre>
297
kubectl apply -f https://docs.projectcalico.org/manifests/calicoctl.yaml
298
</pre>
299
300 93 Nico Schottelius
Or version specific:
301
302
<pre>
303
kubectl apply -f https://github.com/projectcalico/calico/blob/v3.20.4/manifests/calicoctl.yaml
304 97 Nico Schottelius
305
# For 3.22
306
kubectl apply -f https://projectcalico.docs.tigera.io/archive/v3.22/manifests/calicoctl.yaml
307 93 Nico Schottelius
</pre>
308
309 70 Nico Schottelius
And making it easier accessible by alias:
310
311
<pre>
312
alias calicoctl="kubectl exec -i -n kube-system calicoctl -- /calicoctl"
313
</pre>
314
315 62 Nico Schottelius
h3. Calico configuration
316
317 63 Nico Schottelius
By default our k8s clusters "BGP peer":https://docs.projectcalico.org/networking/bgp
318
with an upstream router to propagate podcidr and servicecidr.
319 62 Nico Schottelius
320
Default settings in our infrastructure:
321
322
* We use a full-mesh using the @nodeToNodeMeshEnabled: true@ option
323
* We keep the original next hop so that *only* the server with the pod is announcing it (instead of ecmp)
324 1 Nico Schottelius
* We use private ASNs for k8s clusters
325 63 Nico Schottelius
* We do *not* use any overlay
326 62 Nico Schottelius
327
After installing calico and calicoctl the last step of the installation is usually:
328
329 1 Nico Schottelius
<pre>
330 79 Nico Schottelius
calicoctl create -f - < calico-bgp.yaml
331 62 Nico Schottelius
</pre>
332
333
334
A sample BGP configuration:
335
336
<pre>
337
---
338
apiVersion: projectcalico.org/v3
339
kind: BGPConfiguration
340
metadata:
341
  name: default
342
spec:
343
  logSeverityScreen: Info
344
  nodeToNodeMeshEnabled: true
345
  asNumber: 65534
346
  serviceClusterIPs:
347
  - cidr: 2a0a:e5c0:10:3::/108
348
  serviceExternalIPs:
349
  - cidr: 2a0a:e5c0:10:3::/108
350
---
351
apiVersion: projectcalico.org/v3
352
kind: BGPPeer
353
metadata:
354
  name: router1-place10
355
spec:
356
  peerIP: 2a0a:e5c0:10:1::50
357
  asNumber: 213081
358
  keepOriginalNextHop: true
359
</pre>
360
361 64 Nico Schottelius
h2. ArgoCD / ArgoWorkFlow
362 56 Nico Schottelius
363 60 Nico Schottelius
h3. Argocd Installation
364 1 Nico Schottelius
365 60 Nico Schottelius
As there is no configuration management present yet, argocd is installed using
366
367 1 Nico Schottelius
<pre>
368 60 Nico Schottelius
kubectl create namespace argocd
369 86 Nico Schottelius
370 96 Nico Schottelius
# Specific Version
371
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.3.2/manifests/install.yaml
372 86 Nico Schottelius
373
# OR: latest stable
374 60 Nico Schottelius
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
375 1 Nico Schottelius
</pre>
376 56 Nico Schottelius
377 60 Nico Schottelius
* See https://argo-cd.readthedocs.io/en/stable/
378 1 Nico Schottelius
379 60 Nico Schottelius
h3. Get the argocd credentials
380
381
<pre>
382
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo ""
383
</pre>
384 52 Nico Schottelius
385 87 Nico Schottelius
h3. Accessing argocd
386
387
In regular IPv6 clusters:
388
389
* Navigate to https://argocd-server.argocd.CLUSTERDOMAIN
390
391
In legacy IPv4 clusters
392
393
<pre>
394
kubectl --namespace argocd port-forward svc/argocd-server 8080:80
395
</pre>
396
397 88 Nico Schottelius
* Navigate to https://localhost:8080
398
399 68 Nico Schottelius
h3. Using the argocd webhook to trigger changes
400 67 Nico Schottelius
401
* To trigger changes post json https://argocd.example.com/api/webhook
402
403 72 Nico Schottelius
h3. Deploying an application
404
405
* Applications are deployed via git towards gitea (code.ungleich.ch) and then pulled by argo
406 73 Nico Schottelius
* Always include the *redmine-url* pointing to the (customer) ticket
407
** Also add the support-url if it exists
408 72 Nico Schottelius
409
Application sample
410
411
<pre>
412
apiVersion: argoproj.io/v1alpha1
413
kind: Application
414
metadata:
415
  name: gitea-CUSTOMER
416
  namespace: argocd
417
spec:
418
  destination:
419
    namespace: default
420
    server: 'https://kubernetes.default.svc'
421
  source:
422
    path: apps/prod/gitea
423
    repoURL: 'https://code.ungleich.ch/ungleich-intern/k8s-config.git'
424
    targetRevision: HEAD
425
    helm:
426
      parameters:
427
        - name: storage.data.storageClass
428
          value: rook-ceph-block-hdd
429
        - name: storage.data.size
430
          value: 200Gi
431
        - name: storage.db.storageClass
432
          value: rook-ceph-block-ssd
433
        - name: storage.db.size
434
          value: 10Gi
435
        - name: storage.letsencrypt.storageClass
436
          value: rook-ceph-block-hdd
437
        - name: storage.letsencrypt.size
438
          value: 50Mi
439
        - name: letsencryptStaging
440
          value: 'no'
441
        - name: fqdn
442
          value: 'code.verua.online'
443
  project: default
444
  syncPolicy:
445
    automated:
446
      prune: true
447
      selfHeal: true
448
  info:
449
    - name: 'redmine-url'
450
      value: 'https://redmine.ungleich.ch/issues/ISSUEID'
451
    - name: 'support-url'
452
      value: 'https://support.ungleich.ch/Ticket/Display.html?id=TICKETID'
453
</pre>
454
455 80 Nico Schottelius
h2. Helm related operations and conventions
456 55 Nico Schottelius
457 61 Nico Schottelius
We use helm charts extensively.
458
459
* In production, they are managed via argocd
460
* In development, helm chart can de developed and deployed manually using the helm utility.
461
462 55 Nico Schottelius
h3. Installing a helm chart
463
464
One can use the usual pattern of
465
466
<pre>
467
helm install <releasename> <chartdirectory>
468
</pre>
469
470
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:
471
472
<pre>
473
helm upgrade --install <releasename> <chartdirectory>
474 1 Nico Schottelius
</pre>
475 80 Nico Schottelius
476
h3. Naming services and deployments in helm charts [Application labels]
477
478
* We always have {{ .Release.Name }} to identify the current "instance"
479
* Deployments:
480
** use @app: <what it is>@, f.i. @app: nginx@, @app: postgres@, ...
481 81 Nico Schottelius
* See more about standard labels on
482
** https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
483
** https://helm.sh/docs/chart_best_practices/labels/
484 55 Nico Schottelius
485 43 Nico Schottelius
h2. Rook / Ceph Related Operations
486
487 71 Nico Schottelius
h3. Executing ceph commands
488
489
Using the ceph-tools pod as follows:
490
491
<pre>
492
kubectl exec -n rook-ceph -ti $(kubectl -n rook-ceph get pods -l app=rook-ceph-tools -o jsonpath='{.items[*].metadata.name}') -- ceph -s
493
</pre>
494
495 43 Nico Schottelius
h3. Inspecting the logs of a specific server
496
497
<pre>
498
# Get the related pods
499
kubectl -n rook-ceph get pods -l app=rook-ceph-osd-prepare 
500
...
501
502
# Inspect the logs of a specific pod
503
kubectl -n rook-ceph logs -f rook-ceph-osd-prepare-server23--1-444qx
504
505 71 Nico Schottelius
</pre>
506
507
h3. Inspecting the logs of the rook-ceph-operator
508
509
<pre>
510
kubectl -n rook-ceph logs -f -l app=rook-ceph-operator
511 43 Nico Schottelius
</pre>
512
513
h3. Triggering server prepare / adding new osds
514
515
The rook-ceph-operator triggers/watches/creates pods to maintain hosts. To trigger a full "re scan", simply delete that pod:
516
517
<pre>
518
kubectl -n rook-ceph delete pods -l app=rook-ceph-operator
519
</pre>
520
521
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.
522
523
h3. Removing an OSD
524
525
* See "Ceph OSD Management":https://rook.io/docs/rook/v1.7/ceph-osd-mgmt.html
526 77 Nico Schottelius
* More specifically: https://github.com/rook/rook/blob/release-1.7/cluster/examples/kubernetes/ceph/osd-purge.yaml
527 99 Nico Schottelius
* Then delete the related deployment
528 41 Nico Schottelius
529 98 Nico Schottelius
Set osd id in the osd-purge.yaml and apply it. OSD should be down before.
530
531
<pre>
532
apiVersion: batch/v1
533
kind: Job
534
metadata:
535
  name: rook-ceph-purge-osd
536
  namespace: rook-ceph # namespace:cluster
537
  labels:
538
    app: rook-ceph-purge-osd
539
spec:
540
  template:
541
    metadata:
542
      labels:
543
        app: rook-ceph-purge-osd
544
    spec:
545
      serviceAccountName: rook-ceph-purge-osd
546
      containers:
547
        - name: osd-removal
548
          image: rook/ceph:master
549
          # TODO: Insert the OSD ID in the last parameter that is to be removed
550
          # The OSD IDs are a comma-separated list. For example: "0" or "0,2".
551
          # If you want to preserve the OSD PVCs, set `--preserve-pvc true`.
552
          #
553
          # A --force-osd-removal option is available if the OSD should be destroyed even though the
554
          # removal could lead to data loss.
555
          args:
556
            - "ceph"
557
            - "osd"
558
            - "remove"
559
            - "--preserve-pvc"
560
            - "false"
561
            - "--force-osd-removal"
562
            - "false"
563
            - "--osd-ids"
564
            - "SETTHEOSDIDHERE"
565
          env:
566
            - name: POD_NAMESPACE
567
              valueFrom:
568
                fieldRef:
569
                  fieldPath: metadata.namespace
570
            - name: ROOK_MON_ENDPOINTS
571
              valueFrom:
572
                configMapKeyRef:
573
                  key: data
574
                  name: rook-ceph-mon-endpoints
575
            - name: ROOK_CEPH_USERNAME
576
              valueFrom:
577
                secretKeyRef:
578
                  key: ceph-username
579
                  name: rook-ceph-mon
580
            - name: ROOK_CEPH_SECRET
581
              valueFrom:
582
                secretKeyRef:
583
                  key: ceph-secret
584
                  name: rook-ceph-mon
585
            - name: ROOK_CONFIG_DIR
586
              value: /var/lib/rook
587
            - name: ROOK_CEPH_CONFIG_OVERRIDE
588
              value: /etc/rook/config/override.conf
589
            - name: ROOK_FSID
590
              valueFrom:
591
                secretKeyRef:
592
                  key: fsid
593
                  name: rook-ceph-mon
594
            - name: ROOK_LOG_LEVEL
595
              value: DEBUG
596
          volumeMounts:
597
            - mountPath: /etc/ceph
598
              name: ceph-conf-emptydir
599
            - mountPath: /var/lib/rook
600
              name: rook-config
601
      volumes:
602
        - emptyDir: {}
603
          name: ceph-conf-emptydir
604
        - emptyDir: {}
605
          name: rook-config
606
      restartPolicy: Never
607
608
609 99 Nico Schottelius
</pre>
610
611
Deleting the deployment:
612
613
<pre>
614
[18:05] bridge:~% kubectl -n rook-ceph delete deployment rook-ceph-osd-6
615
deployment.apps "rook-ceph-osd-6" deleted
616 98 Nico Schottelius
</pre>
617
618 76 Nico Schottelius
h2. Harbor
619
620
* We user "Harbor":https://goharbor.io/ for caching and as an image registry. Internal app reference: apps/prod/harbor.
621
* The admin password is in the password store, auto generated per cluster
622
* At the moment harbor only authenticates against the internal ldap tree
623
624
h3. LDAP configuration
625
626
* The url needs to be ldaps://...
627
* uid = uid
628
* rest standard
629 75 Nico Schottelius
630 89 Nico Schottelius
h2. Monitoring / Prometheus
631
632 90 Nico Schottelius
* Via "kube-prometheus":https://github.com/prometheus-operator/kube-prometheus/
633 89 Nico Schottelius
634 91 Nico Schottelius
Access via ...
635
636
* http://prometheus-k8s.monitoring.svc:9090
637
* http://grafana.monitoring.svc:3000
638
* http://alertmanager.monitoring.svc:9093
639
640
641 100 Nico Schottelius
h3. Prometheus Options
642
643
* "helm/kube-prometheus-stack":https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
644
** Includes dashboards and co.
645
* "manifest based kube-prometheus":https://github.com/prometheus-operator/kube-prometheus
646
** Includes dashboards and co.
647
* "Prometheus Operator (mainly CRD manifest":https://github.com/prometheus-operator/prometheus-operator
648
649 91 Nico Schottelius
650 82 Nico Schottelius
h2. Nextcloud
651
652 85 Nico Schottelius
h3. How to get the nextcloud credentials 
653 84 Nico Schottelius
654
* The initial username is set to "nextcloud"
655
* The password is autogenerated and saved in a kubernetes secret
656
657
<pre>
658 85 Nico Schottelius
kubectl get secret RELEASENAME-nextcloud -o jsonpath="{.data.PASSWORD}" | base64 -d; echo "" 
659 84 Nico Schottelius
</pre>
660
661 83 Nico Schottelius
h3. How to fix "Access through untrusted domain"
662
663 82 Nico Schottelius
* Nextcloud stores the initial domain configuration
664 1 Nico Schottelius
* If the FQDN is changed, it will show the error message "Access through untrusted domain"
665 82 Nico Schottelius
* To fix, edit /var/www/html/config/config.php and correct the domain
666 83 Nico Schottelius
* Then delete the pods
667 82 Nico Schottelius
668 1 Nico Schottelius
h2. Infrastructure versions
669 35 Nico Schottelius
670 57 Nico Schottelius
h3. ungleich kubernetes infrastructure v5 (2021-10)
671 1 Nico Schottelius
672 57 Nico Schottelius
Clusters are configured / setup in this order:
673
674
* Bootstrap via kubeadm
675 59 Nico Schottelius
* "Networking via calico + BGP (non ECMP) using helm":https://docs.projectcalico.org/getting-started/kubernetes/helm
676
* "ArgoCD for CD":https://argo-cd.readthedocs.io/en/stable/
677
** "rook for storage via argocd":https://rook.io/
678 58 Nico Schottelius
** haproxy for in IPv6-cluster-IPv4-to-IPv6 proxy via argocd
679
** "kubernetes-secret-generator for in cluster secrets":https://github.com/mittwald/kubernetes-secret-generator
680
** "ungleich-certbot managing certs and nginx":https://hub.docker.com/repository/docker/ungleich/ungleich-certbot
681
682 57 Nico Schottelius
683
h3. ungleich kubernetes infrastructure v4 (2021-09)
684
685 54 Nico Schottelius
* rook is configured via manifests instead of using the rook-ceph-cluster helm chart
686 1 Nico Schottelius
* The rook operator is still being installed via helm
687 35 Nico Schottelius
688 57 Nico Schottelius
h3. ungleich kubernetes infrastructure v3 (2021-07)
689 1 Nico Schottelius
690 10 Nico Schottelius
* rook is now installed via helm via argocd instead of directly via manifests
691 28 Nico Schottelius
692 57 Nico Schottelius
h3. ungleich kubernetes infrastructure v2 (2021-05)
693 28 Nico Schottelius
694
* Replaced fluxv2 from ungleich k8s v1 with argocd
695 1 Nico Schottelius
** argocd can apply helm templates directly without needing to go through Chart releases
696 28 Nico Schottelius
* We are also using argoflow for build flows
697
* Planned to add "kaniko":https://github.com/GoogleContainerTools/kaniko for image building
698
699 57 Nico Schottelius
h3. ungleich kubernetes infrastructure v1 (2021-01)
700 28 Nico Schottelius
701
We are using the following components:
702
703
* "Calico as a CNI":https://www.projectcalico.org/ with BGP, IPv6 only, no encapsulation
704
** Needed for basic networking
705
* "kubernetes-secret-generator":https://github.com/mittwald/kubernetes-secret-generator for creating secrets
706
** Needed so that secrets are not stored in the git repository, but only in the cluster
707
* "ungleich-certbot":https://hub.docker.com/repository/docker/ungleich/ungleich-certbot
708
** Needed to get letsencrypt certificates for services
709
* "rook with ceph rbd + cephfs":https://rook.io/ for storage
710
** rbd for almost everything, *ReadWriteOnce*
711
** cephfs for smaller things, multi access *ReadWriteMany*
712
** Needed for providing persistent storage
713
* "flux v2":https://fluxcd.io/
714
** Needed to manage resources automatically