Skip to content

Commit 501696d

Browse files
Notes to switch a worker to a master (#243)
Signed-off-by: Dean Roehrich <dean.roehrich@hpe.com> Co-authored-by: Blake Devcich <89158881+bdevcich@users.noreply.github.com>
1 parent 17ad68a commit 501696d

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

docs/guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
* [Disable or Drain a Node](node-management/drain.md)
2929
* [Debugging NVMe Namespaces](node-management/nvme-namespaces.md)
30+
* [Switch a Node From Worker to Master](node-management/worker-to-master.md)
3031

3132
## Monitoring the Cluster
3233

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Switch a Node From Worker to Master
2+
3+
In this example, we have htx[40-42] as worker nodes. We will remove htx[40-41] as worker nodes and re-join them as master nodes.
4+
5+
## Remove a k8s worker node
6+
7+
Begin by moving their existing pods to htx42.
8+
9+
Taint the nodes we're going to remove, to prevent new pods from being SCHEDULED on them (this is different from the taint we'll use in a later step):
10+
11+
```console
12+
NODE=htx40
13+
kubectl taint node $NODE cray.nnf.node.drain=true:NoSchedule
14+
```
15+
16+
Set deploy/dws-webhook to 1 replica. **This must be done via the gitops repo.** Edit `environments/$ENV/dws/kustomization.yaml`, and add this, then wait for argocd to put it into effect. Or, force argocd to sync it with `argocd app sync 1-dws`.
17+
18+
```bash
19+
patches:
20+
- target:
21+
kind: Deployment
22+
name: dws-webhook
23+
patch: |-
24+
apiVersion: apps/v1
25+
kind: Deployment
26+
metadata:
27+
name: dws-webhook
28+
spec:
29+
replicas: 1
30+
```
31+
32+
Taint the nodes we're going to remove, to BUMP EXISTING PODS off them (this is different from the taint we used earlier). This will bump any DWS, NNF, ArgoCD, cert-manager, mpi-operator, luster-fs-operator pods. This leaves any lustre-csi-driver pods in place to assist with any Lustre unmounts that k8s may
33+
request.
34+
35+
```console
36+
kubectl taint node $NODE cray.nnf.node.drain=true:NoExecute
37+
```
38+
39+
Decommission [calico node](https://docs.tigera.io/calico/latest/operations/decommissioning-a-node).
40+
41+
> If you are running the node controller or using the Kubernetes API datastore in policy-only mode, you do not need to manually decommission nodes.
42+
43+
Tell k8s to drain the nodes.
44+
45+
Use the cray.nnf.node taints above before running 'kubectl drain'. Those taints allow Workflows to be terminated cleanly, even when they have Lustre filesystems mounted in the pods on that node. It's important that the lustre-csi-driver pod on that node lives long enough to assist with those unmounts to allow K8s to finish pod cleanup.
46+
47+
```console
48+
kubectl drain --ignore-daemonsets $NODE
49+
```
50+
51+
Delete the worker nodes:
52+
53+
```console
54+
kubectl delete node $NODE
55+
```
56+
57+
Verify that the node is deleted from calico and k8s:
58+
59+
```console
60+
kubectl calico get nodes (requires the calico plugin for kubectl)
61+
kubectl get nodes
62+
```
63+
64+
Remove etcd, if it was a master:
65+
66+
```console
67+
(on $NODE) kubeadm reset remove-etcd-member
68+
```
69+
70+
It takes a while for all the containers on the deleted node to stop, so be patient.
71+
72+
```console
73+
(on $NODE) crictl ps
74+
```
75+
76+
Reset everything that "kubeadm join" did to that node:
77+
78+
```console
79+
(on $NODE) kubeadm reset cleanup-node
80+
```
81+
82+
## Join a node as a master
83+
84+
Check for expired "kubeadm init" or "kubeadm-certs" tokens, or expired certs:
85+
86+
The certificate-key from 'kubeadm init' is deleted after two hours. Use "kubeadm init phase upload-certs --upload-certs" to reload the certs later. This is explained in the output of the 'kubeadm init' command.
87+
88+
```console
89+
kubeadm token list
90+
```
91+
92+
The one labeled for "kubeadm init" is used as the token in "kubeadm join" commands. The one labeled for "managing TTL" controls the lifetime of the "kubeadm-certs" secret and the "bootstrap-token-XXX" secret. These secrets and this token, are deleted after the "managing TTL" token expires. A worker can still join after that expires; a master cannot.
93+
94+
```console
95+
kubeadm certs check-expiration
96+
```
97+
98+
Re-join that node as a master. When you ran "kubeadm init" to create the initial master node, you should have saved the output. It contains the "join" command that you need to create new masters. You want the commandline that includes the "--control-plane" option:
99+
100+
```console
101+
(on $NODE) kubeadm join ... --control-plane ...
102+
```
103+
104+
If that fails, it may tell you to generate new certs. Run the 'kubeadm init phase' command it specifies, and note the certificate key in the output. Replace the certificate key from your original join command with this new key and run the new join command.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ nav:
2424
- 'Auditing': 'guides/monitoring-cluster/auditing.md'
2525
- 'API Priority and Fairness': 'guides/monitoring-cluster/api-priority-and-fairness.md'
2626
- 'Debugging NVMe Namespaces': 'guides/node-management/nvme-namespaces.md'
27+
- 'Switch a Node From Worker to Master': 'guides/node-management/worker-to-master.md'
2728
- 'Directive Breakdown': 'guides/directive-breakdown/readme.md'
2829
- 'System Storage': 'guides/system-storage/readme.md'
2930
- 'RFCs':

0 commit comments

Comments
 (0)