harness: containerlab lab, vm:e2e on a 3-server cluster, k3s-reset node/cluster modes (#31 step 3) #32
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/machine-configs!32
Loading…
Reference in a new issue
No description provided.
Delete branch "clab-harness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #31, #14, #11.
task vm:e2enow runs the full test suite on a containerlab copy of the home network, against a three-server k3s cluster. The old raw-QEMU harness is gone.Lab
lab/lab.clab.ymldefines two RouterOS CHR routers in place of the RB5009s, a Linux bridge in place of the CRS309, a CHR acting as the PPPoE ISP, three NixOS VMs (test-01 to test-03) and a client.scripts/harness-ceremony.shcreates a throwaway root CA, and a test OpenBao issues certificates from it.task lab:router-checktests HTTPS, VRRP, PPPoE, WAN, DHCP, firewall zones and IPv6.docs/vm-testing.mdexplains how to run it.Bugs the lab found
pki/clusters/<cluster>.domains.task gatenow checks this.Unauthorizedon its next reboot.vm:rotate-checknow runs step 3, anddocs/k3s-ca-rotation.mdwarns about it.k3s-reset.sh
The script now takes a mode, and old command lines fail with a usage message.
--node HOSTrebuilds one node and keeps the cluster's data. Another server removes the node, then the script wipes it, reboots it and lets it rejoin.--cluster HOST...wipes every server and starts the cluster again with no data. It refuses unless you list every server.--no-rebootis gone.vm:reset-checktests both modes.Tested
task vm:e2epasses in full ate25c820.On merge
The secrets are re-keyed for test-02 and test-03, so c1 redeploys once with no change.
Questions on lines the lab can't fully test.
@ -1 +1 @@{"creation_rules":[{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq","path_regex":"(^|/)secrets/game\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq","path_regex":"(^|/)secrets/mini\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age126uz65ujpwsjnyzs5yqdrellnylrv3cr470ucqxuyatf4rjngqpq3fk9jr,age12euz3gyut2n0fden44n09yr888euav4p45lw4uz900lslkzejdjq4lc69s,age18jclu24g46l0ltxnjc9q6pfknr6eez9ts54qf2zglfyncmx5js5qnxv25w,age1cft0r0n46zts3cn3n4vswkaauf33xgaemhhs886xnr2yycgcjpcq0r06c9,age1ehr8hm6yrzev8h8u8wx6ufspjftp55kt3wv274g7vvnusyr9kcqsyrya0j,age1qp0cuyzkp6qgvy2hns2hc09yx6gtqlwj56rczd4uv5s3jsr9nqjs856cnh,age1s744yl9q5nkleuxeaxq4a2mc4u3mgk76yt0zvujev8xh4dun7u2s0p230u","path_regex":"(^|/)secrets/c1\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age1r00t88s0u3z0t2gphjl2z8zwx66apfwtj63ucywghkz4xp75x4xqzlalnu","path_regex":"(^|/)secrets/test\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age12euz3gyut2n0fden44n09yr888euav4p45lw4uz900lslkzejdjq4lc69s,age1cft0r0n46zts3cn3n4vswkaauf33xgaemhhs886xnr2yycgcjpcq0r06c9,age1r00t88s0u3z0t2gphjl2z8zwx66apfwtj63ucywghkz4xp75x4xqzlalnu,age1s744yl9q5nkleuxeaxq4a2mc4u3mgk76yt0zvujev8xh4dun7u2s0p230u","path_regex":"(^|/)secrets/flux\\.sops\\.yaml$"}]}{"creation_rules":[{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq","path_regex":"(^|/)secrets/game\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq","path_regex":"(^|/)secrets/mini\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age126uz65ujpwsjnyzs5yqdrellnylrv3cr470ucqxuyatf4rjngqpq3fk9jr,age12euz3gyut2n0fden44n09yr888euav4p45lw4uz900lslkzejdjq4lc69s,age18jclu24g46l0ltxnjc9q6pfknr6eez9ts54qf2zglfyncmx5js5qnxv25w,age1cft0r0n46zts3cn3n4vswkaauf33xgaemhhs886xnr2yycgcjpcq0r06c9,age1ehr8hm6yrzev8h8u8wx6ufspjftp55kt3wv274g7vvnusyr9kcqsyrya0j,age1qp0cuyzkp6qgvy2hns2hc09yx6gtqlwj56rczd4uv5s3jsr9nqjs856cnh,age1s744yl9q5nkleuxeaxq4a2mc4u3mgk76yt0zvujev8xh4dun7u2s0p230u","path_regex":"(^|/)secrets/c1\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age1pdqwjsnw9ny7e52nsu5m5psp45sanngmnrjpgnteh3pxhjtdremskvfjhd,age1r00t88s0u3z0t2gphjl2z8zwx66apfwtj63ucywghkz4xp75x4xqzlalnu,age1w2n7n7tfch3tkdx20f83fcspfzezjsek42tyn8j22gmdk9d7tv9shpkkex","path_regex":"(^|/)secrets/test\\.sops\\.yaml$"},{"age":"age16fc0q3a4ht2w2mslcyc8hckm7un3yuv70q49mcf7ftj6wvs9gf5qd4g3uq,age12euz3gyut2n0fden44n09yr888euav4p45lw4uz900lslkzejdjq4lc69s,age1cft0r0n46zts3cn3n4vswkaauf33xgaemhhs886xnr2yycgcjpcq0r06c9,age1pdqwjsnw9ny7e52nsu5m5psp45sanngmnrjpgnteh3pxhjtdremskvfjhd,age1r00t88s0u3z0t2gphjl2z8zwx66apfwtj63ucywghkz4xp75x4xqzlalnu,age1s744yl9q5nkleuxeaxq4a2mc4u3mgk76yt0zvujev8xh4dun7u2s0p230u,age1w2n7n7tfch3tkdx20f83fcspfzezjsek42tyn8j22gmdk9d7tv9shpkkex","path_regex":"(^|/)secrets/flux\\.sops\\.yaml$"}]}The new keys are for test-02 and test-03. Merging re-encrypts
secrets/flux.sops.yamlwith the same contents, so c1 redeploys with no change.@ -44,0 +36,4 @@# machine-configs checkout (found via git's common dir), so this also works# from a worktree under ~/.worktrees. Override with FLUX_REPO=...FLUX_REPO:sh: echo "${FLUX_REPO:-$(cd "$(git rev-parse --path-format=absolute --git-common-dir)/../.." && pwd)/flux-clusters}"vm:pushforce-pushes the commit checked out in~/Projects/Personal/lab/flux-clustersto itsdevbranch. test-01 runs whatever that commit contains.@ -449,6 +336,26 @@ tasks:{{.SSH}} "curl -sf -o /dev/null -k -H 'Authorization: Bearer $sat' https://127.0.0.1:6443/api" \|| { echo "a service-account token from before the rotation no longer authenticates"; exit 1; }echo "[vm] CAs rotated ($old -> $new), pre-rotation service-account token still accepted"# Runbook step 3: restart k3s on every OTHER server, one at a time.The test restarts the other servers only, because the test cluster has no agents. On c1 you also restart the Pis, and the lab never runs that step.
This comment makes no sense, rewrite it with more detail
@ -121,0 +131,4 @@# cluster. Point it at the VIP for this one join; the driver removes the# drop-in once the node is back.if [ -n "${REJOIN_URL:-}" ]; thenrun install -D -m 0644 /dev/null /etc/rancher/k3s/config.yaml.d/50-rejoin.yamlThis file lets a wiped bootstrap leader join the running cluster instead of starting a new one. Line 244 removes it. If the script stops in between, the file stays, and the next full cluster start fails on this host. I can add a trap that removes it on error.
This comment makes no sense and is some of the worst claudeslop I've ever seen, rewrite it with more context
@ -148,0 +170,4 @@wipe() {local h=$1echo "== $h (${IP[$h]}) ${ROLE[$h]} data=${DATA[$h]:-none} openbao=${BAO[$h]} mode=$mode apply=$apply"remote | RESET_SSH_TIMEOUT=3600 to "$h" "sudo env MODE=$mode APPLY=$apply REBOOT=$2 HOST=$h MARKER=${MARKER[$h]} DATA_DISK=${DATA[$h]} POOL=${POOL[$h]} REJOIN_URL=${3:-} bash -s"The wipe gets a one hour timeout. Is that long enough for your largest data disk?
@ -160,0 +230,4 @@node=$(on "$peer" "$K get nodes -o name | sed 's|^node/||' | grep -E '^$h(\\.|\$)'" || true)if [ -n "$node" ]; thenecho "[$h] $peer deletes node $node (k3s removes its etcd member)"on "$peer" "$K delete node $node --wait=true" >/dev/nullThis deletes the node without draining it first. On c1 that node runs Ceph OSDs and LINSTOR volumes, and the test cluster has neither. Should it drain first?
Does it matter if it drains first, this is for destroying a node?
I supposed if a node had to be reset to rejoin the cluster.
@ -160,0 +248,4 @@# --clusterfor s in "${all_servers[@]}"; doprintf '%s\n' "${hosts[@]}" | grep -qx "$s" || { echo "--cluster needs every server of $c; $s is missing" >&2; exit 1; }--clusterwipes the data disk on every server, so all Ceph and LINSTOR data is lost. The only check is that you listed every server. Should it also make you type the cluster name?No, every node name is probably good enough
@ -160,0 +266,4 @@for h in "$leader" "${servers[@]}"; doon "$h" "systemd-run --on-active=5 --unit=k3s-reset-reboot systemctl reboot" >/dev/nullwait_reboot "$h" "${B0[$h]}"wait_bao "$h"The script waits for OpenBao to unseal before it reboots the next server. The test VMs don't run OpenBao, so the lab never runs this wait.
Why shouldn't the test vms run openbao?
Replies.
@ -449,6 +336,26 @@ tasks:{{.SSH}} "curl -sf -o /dev/null -k -H 'Authorization: Bearer $sat' https://127.0.0.1:6443/api" \More detail. Step 3 of
docs/k3s-ca-rotation.mdsays to restart k3s on every other server, then on every agent, one node at a time. Agents are nodes that run workloads but not the control plane. On c1 those are the Pis.The test cluster has three servers and no agents. So this test restarts test-02 and test-03, then checks that all three servers hold the same CAs. The agent half of step 3 never runs in the lab, so we haven't seen a Pi pick up rotated CAs after a restart. Adding one agent VM to the lab would cover it.
@ -121,0 +131,4 @@# cluster. Point it at the VIP for this one join; the driver removes the# drop-in once the node is back.if [ -n "${REJOIN_URL:-}" ]; thenrun install -D -m 0644 /dev/null /etc/rancher/k3s/config.yaml.d/50-rejoin.yamlMore context. The first server in each cluster, the bootstrap leader (test-01 here, think-01 on c1), has no
server:line in its k3s config. On a cold start it has to create the cluster, so it can't point at anyone. Every other server joins through the VIP.When
--nodewipes the leader and reboots it, k3s would read that config and create a new, empty cluster beside the real one. To stop that, the script writes/etc/rancher/k3s/config.yaml.d/50-rejoin.yamlwithserver: https://<VIP>:6443before the reboot, so the leader joins the existing cluster. Once the node is Ready, line 244 deletes the file.The risk is a run that dies between the reboot and line 244, for example your laptop losing its connection. The file then stays on the leader. Nothing breaks right away. It matters the next time the whole cluster is down at once, because the leader would try to join a VIP that nobody holds and k3s would never start.
A trap in the script won't help if the laptop is what died. Two options. node-health could flag the file if it's still there an hour after boot. Or we accept it and you remove it by hand if a reset run gets interrupted. Which do you prefer?
@ -160,0 +230,4 @@node=$(on "$peer" "$K get nodes -o name | sed 's|^node/||' | grep -E '^$h(\\.|\$)'" || true)if [ -n "$node" ]; thenecho "[$h] $peer deletes node $node (k3s removes its etcd member)"on "$peer" "$K delete node $node --wait=true" >/dev/nullAgreed, no drain.
--nodeis only used on a node you're wiping anyway. Deleting the node object makes Kubernetes reschedule its pods on other nodes, and the reset wipes the OSD and volume data on that node regardless. Leaving it as is.@ -160,0 +248,4 @@# --clusterfor s in "${all_servers[@]}"; doprintf '%s\n' "${hosts[@]}" | grep -qx "$s" || { echo "--cluster needs every server of $c; $s is missing" >&2; exit 1; }OK, keeping the every-server check as the only guard.
@ -160,0 +266,4 @@for h in "$leader" "${servers[@]}"; doon "$h" "systemd-run --on-active=5 --unit=k3s-reset-reboot systemctl reboot" >/dev/nullwait_reboot "$h" "${B0[$h]}"wait_bao "$h"No good reason. The harness runs a single OpenBao on the host machine, which was simpler to set up. On c1, OpenBao runs on the three thinks next to k3s. Running it on test-01 to test-03 as a three-node Raft cluster would match that, and it would exercise this wait and the same quorum guard in
--cluster.It's a sizeable harness change, covering unseal, Raft join and host enrollment against the in-cluster OpenBao. Do you want it in this PR or a follow-up?