Skip to content

Cluster-wide outage from Tailscale node flapping

Date: 2026-09-04 Duration: ~3 hours (acute outage) + follow-on cleanup Severity: High — cluster-wide impact (production, staging, registry, messaging) Status: Resolved and verified

Summary

castis-desktop (a control-plane/etcd node) began flapping between Ready and NotReady, with nuc-a also affected. This triggered a cascade through Longhorn storage into apisix's own etcd (its routing config store), which took down apisix entirely — including the registry.nexus.castis.io route — causing cluster-wide ImagePullBackOff on every node, not just the flapping ones. A secondary, related issue (Traefik reappearing on rejoined nodes) was found and fixed during follow-up cleanup.

Root Causes

Two independent, compounding causes were identified on the affected nodes (castis-desktop, nuc-a):

  1. Tailscale route conflict. Tailscale was installed on every node in the cluster with --accept-routes enabled on all of them (via Headscale, this cluster's self-hosted Tailscale control server). At least one node had also advertised the cluster's own LAN subnet (<OFFICE_LAN_CIDR>) as a Tailscale subnet route, and Headscale had approved it. Because every node was set to accept advertised routes, that LAN route got pulled into the routing table of nodes that were already directly on that same LAN themselves — nodes don't need Tailscale to reach each other over their own local network. In short: the network no longer knew which path to take — traffic between nodes could get pulled into the Tailscale/WireGuard tunnel instead of the direct LAN, inconsistently and unpredictably. This produced intermittent, asymmetric connectivity (packet loss, timeouts, and TLS handshake noise during etcd peer reconnects — WireGuard's smaller MTU can fragment/corrupt a TLS handshake in transit) rather than a clean up/down failure, and made core cluster networking depend on tailscaled staying healthy for traffic that should never have left the LAN. Removing Tailscale from nuc-a resolved that node's instability, confirming it as a real contributing cause. The tailscaled service has since been stopped on the affected nodes (not uninstalled) — see Follow-ups for the safe re-test performed on mac-mini with --accept-routes off.

  2. k3s version skew across control-plane nodes. castis-desktop and nuc-a were running v1.33.3+k3s1 while nuc-b had already been manually upgraded to v1.34.5+k3s1 (no automated upgrade controller was in use). Running mismatched etcd/raft protocol versions across HA control-plane members for an extended period is unsupported and produced intermittent consensus failures, elevated etcd latency, and "bad certificate"-style TLS handshake noise during peer reconnects.

These two factors compounded each other — network disruption from Tailscale made the already-fragile mixed-version etcd raft communication even less reliable, producing the flapping.

Cascade

castis-desktop / nuc-a flapping NotReady
        │
        ▼
Longhorn loses replicas hosted on the flapping nodes
        │  (instance-manager pods restart repeatedly,
        │   replicas marked failed, auto-salvage storms)
        ▼
~30 Longhorn volumes go degraded/faulted/unknown cluster-wide
        │
        ▼
apisix's own etcd (separate 3-pod StatefulSet, just its
routing-config store — NOT k3s's cluster etcd) loses quorum
because its volumes can't attach reliably
        │
        ▼
apisix itself goes down ("no healthy etcd endpoint available")
        │
        ▼
registry.nexus.castis.io route breaks (504 → connection refused)
        │
        ▼
Cluster-wide ImagePullBackOff on every node (not just the
flapping ones) — production, staging, and messaging workloads
all affected

Key Diagnostic Findings Along the Way

  • k3s's own cluster etcd (embedded in the k3s process, 3 members) never actually lost quorum — 2 of 3 members (nuc-a, nuc-b) stayed available throughout. The instability was real but not a full k3s control-plane outage.
  • apisix's etcd StatefulSet is a separate etcd cluster from k3s's own, used only as apisix's config cache. Its data is fully disposable — the actual source of truth is the ApisixRoute/ApisixUpstream CRDs, which apisix-ingress-controller continuously re-syncs into it.
  • Ruled out during investigation: OOM kills (none found in dmesg), etcd CA/cert mismatch (fingerprints matched exactly across nodes), clock drift (NTP synced on all nodes checked).
  • castis-desktop's etcd membership became corrupted after repeated forced interruptions during the incident, requiring a full member remove-and-rejoin rather than a simple restart.
  • apisix's etcd-0/1/2 pods went through a secondary "synchronization race" after their PVCs were reset: each pod requires seeing the other two resolvable via the headless service DNS simultaneously to complete initial bootstrap. With each pod crash-looping on an independent ~60s timer, they kept narrowly missing each other. Fixed by force-deleting all three pods close together so their restarts overlapped.

Resolution Steps Taken

  1. Removed Tailscale from nuc-a (later removed cluster-wide).
  2. Upgraded nuc-a and castis-desktop to v1.34.5+k3s1 to match nuc-b:
    curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.34.5+k3s1 sh -s - server
    
  3. castis-desktop's etcd membership was corrupted beyond a simple restart fixing it, so it was removed and rejoined as a fresh member:
    # on a healthy node
    etcdctl member remove <castis-desktop-member-id>
    
    # on castis-desktop
    sudo systemctl stop k3s
    sudo rm -rf /var/lib/rancher/k3s/server/db
    curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.34.5+k3s1 \
      K3S_TOKEN=<token> sh -s - server --server https://<healthy-node-ip>:6443
    
  4. Reset apisix's etcd (safe — disposable config cache, re-synced automatically from k8s CRDs):
    kubectl scale statefulset -n apisix etcd --replicas=0
    kubectl delete pvc -n apisix data-etcd-0 data-etcd-1 data-etcd-2
    kubectl scale statefulset -n apisix etcd --replicas=3
    
  5. Force-cleared several pods stuck Terminating/Init due to lingering Longhorn volume-attach state, and later force-deleted etcd-0/etcd-1 together to resolve the bootstrap synchronization race described above:
    kubectl delete pod <pod> --grace-period=0 --force
    
  6. Once the etcd cluster achieved a stable 3-way quorum, Longhorn volumes self-healed and apisix/registry came back automatically.
  7. Force-deleted remaining ImagePullBackOff pods to trigger an immediate retry (rather than waiting on k8s's exponential backoff) once the registry was confirmed reachable again.
  8. Follow-up fix — Traefik reappeared on rejoined nodes. nuc-b already had /etc/rancher/k3s/config.yaml with disable: traefik set (this cluster uses apisix as its ingress, not the k3s-bundled Traefik), but castis-desktop and nuc-a lost this node-local file when they were freshly reinstalled/rejoined during the incident (step 2–3 above). Their k3s addon manager then re-created the traefik/traefik-crd HelmChart resources, which got stuck in CrashLoopBackOff (the traefik chart install failed because its required CRDs, installed by the separate traefik-crd chart, were missing). Fixed by restoring the same config.yaml to both nodes, restarting k3s, and deleting the stale HelmChart/Job resources:
    sudo tee /etc/rancher/k3s/config.yaml <<'EOF'
    kubelet-arg:
      - "resolv-conf=/run/systemd/resolve/resolv.conf"
    disable: traefik
    EOF
    sudo systemctl restart k3s
    
    kubectl delete helmchart -n kube-system traefik traefik-crd
    kubectl delete job -n kube-system helm-install-traefik helm-install-traefik-crd
    

Verified Final State

Confirmed via kubectl after all fixes:

  • Nodes: all 4 (castis-desktop, nuc-a, nuc-b, mac-mini) Ready, control-plane nodes aligned on v1.34.5+k3s1.
  • Pods: zero pods cluster-wide in any state other than Running/Succeeded.
  • Longhorn: every currently-attached volume is healthy. Remaining unknown/detached volumes are not attached to anything and not blocking any workload.
  • apisix: all etcd-0/1/2 pods 1/1 Running; all gateway, dashboard, and ingress-controller pods Running.
  • Registry: registry.nexus.castis.io returns 401 on manifest requests — the correct behavior for an unauthenticated Docker registry v2 API call, confirming the full path (DNS → apisix → etcd config → route → nexus) works end-to-end.
  • Traefik: no leftover HelmChart/Job/pod resources on any node.

Follow-ups / Recommendations

  • Stop tailscaled on the affected nodes and validate a safe re-introduction path — done, see full "Tailscale Safe Re-Setup" section below for the complete procedure, findings, and current rollout status.
  • Restore disable: traefik on rejoined nodes and clean up stale Traefik resources — done.
  • Establish a process for keeping k3s versions in sync across all control-plane nodes — this version skew was the root structural cause. Consider the Rancher system-upgrade-controller for automated, coordinated upgrades instead of manual per-node upgrades.
  • Track node-local k3s config (/etc/rancher/k3s/config.yaml) in this repo (e.g. as a reference file per node, or provisioned via cloud-init/Ansible) rather than only on-disk. The Traefik regression above happened specifically because this file existed only locally on nuc-b and had no record anywhere else — a node reinstall silently lost it. The same risk applies to anything else configured ad hoc on individual nodes and not captured in this IaC repo.
  • Clean up the orphaned faulted Longhorn volume left over from the apisix-etcd reset (safe, no longer referenced by any PVC):
    kubectl delete volumes.longhorn.io -n longhorn-system pvc-4350048b-9492-4800-96e7-f772cbeb2f4a
    
  • Consider monitoring/alerting on k3s node version drift and on Longhorn volume robustness, so this class of incident is caught before it cascades into a full outage next time.
  • Confirm whether nuc-b (the original route-advertising node — see Tailscale Safe Re-Setup section) still has an active route advertisement, and decide whether to remove it entirely.
  • Rotate/expire the Tailscale preauth key committed in plaintext in headscale/TailscaleClientInstall.md's git history.

Tailscale Safe Re-Setup (Follow-up, 2026-09-07)

Three days after the incident, Tailscale was reintroduced on a per-node basis for remote-access purposes, using the safe configuration validated below: joined to the same Headscale tailnet, but without accepting or advertising any routes, so it can never again interfere with cluster-internal networking.

Prerequisites

  • Headscale (self-hosted Tailscale control server) runs on a separate cluster from this k3s cluster — not in playtelly-iac. Generate preauth keys there, not here.
  • A preauth key, generated per-node (reusable keys are fine for a short rollout window, but prefer short expirations):
    kubectl exec -n headscale headscale-0 -- headscale users list
    kubectl exec -n headscale headscale-0 -- \
      headscale preauthkeys create --user <ID> --reusable --expiration 24h
    

Per-node procedure

1. Check inotify limits first (k3s nodes only). A busy k3s node can exhaust the default Linux fs.inotify.max_user_instances (128), which causes unrelated failures like systemd/tailscaled failing with "Failed to allocate directory watch: Too many open files" — this hit nuc-a mid-rollout, unrelated to Tailscale itself. Fix once, on every node:

echo 'fs.inotify.max_user_instances = 1024' | sudo tee -a /etc/sysctl.d/99-k3s-inotify.conf
echo 'fs.inotify.max_user_watches = 524288' | sudo tee -a /etc/sysctl.d/99-k3s-inotify.conf
sudo sysctl --system

2. Install (or reuse existing install):

curl -fsSL https://tailscale.com/install.sh | sh

3. If Tailscale was previously configured on this node, wipe its state first. Old --advertise-routes/--accept-routes config persists in tailscaled's state file, not just in the last tailscale up command's flags — just stopping the service is not enough, since the old config comes right back the next time it's started unless the state is cleared:

sudo systemctl stop tailscaled
sudo rm -f /var/lib/tailscale/tailscaled.state
sudo systemctl start tailscaled
sudo systemctl enable tailscaled

4. Join — no route acceptance, no advertisement:

sudo tailscale up \
  --login-server https://headscale.castis.io \
  --authkey <preauth-key>
Deliberately do not pass --accept-routes or --advertise-routes — both default to off, and that's exactly what we want. If DNS health warnings show up (MagicDNS trying to override this cluster's custom resolv-conf kubelet arg), disable it explicitly:
sudo tailscale set --accept-dns=false

5. Verify it didn't touch cluster networking:

tailscale status
ip route show
Expect to see, in tailscale status, a health-check note like "Some peers are advertising routes but --accept-routes is false" — that confirms routes ARE still being advertised somewhere in the tailnet, and this node is correctly ignoring them. In ip route show, the LAN route (<OFFICE_LAN_CIDR> dev <lan-iface>) and flannel/cni routes must be completely unaffected — no tailscale0 involvement. If it's a k3s node, also confirm from another node that it didn't drop out of the cluster during setup:
kubectl get nodes

Understanding tailscale status output

Columns reflect live traffic, not just reachability:

Status shown Meaning
- (blank) Peer is connected to Headscale, but no recent traffic exchanged with it from this node — idle, not broken.
offline, last seen X ago That peer isn't connected to Headscale's control plane at all right now.
active; direct ... Live traffic, true peer-to-peer WireGuard connection.
active; relay "sin", tx/rx ... Live traffic, routed through a DERP relay server (here, Singapore) because a direct path couldn't be negotiated — works, just slower.

Node hygiene: stale Headscale entries

Every time a node's local state is wiped and rejoined (step 3 above), it gets a new machine identity, and Headscale registers it as a brand-new node rather than recognizing the same physical machine — duplicates like nuc-a, nuc-a-xllvpuhg, nuc-a-xse9bv3m pile up. Clean up the stale/offline ones after a reset:

kubectl exec -n headscale headscale-0 -- headscale nodes list
kubectl exec -n headscale headscale-0 -- headscale nodes delete -i <stale-id> --force
Keep the one currently showing online/actively connected; delete the rest.

Rollout status (as of 2026-09-07)

Node Reinstalled with safe config? Notes
mac-mini Yes First validated test — confirmed clean.
nuc-a Yes Hit the inotify limit issue during setup (see step 1).
castis-desktop Yes An unrelated, pre-existing broken host-level nginx/RTMP config surfaced during apt install (see "Known non-issues" below); did not block Tailscale's own install.
nuc-b Not yet reset nuc-b was the original node configured to advertise <OFFICE_LAN_CIDR> per the old headscale/TailscaleClientInstall.md procedure. It has not been through this safe re-setup — its advertised route may still be active/approved in Headscale. Action needed: run headscale nodes list-routes to check, and if still advertising, decide whether to disable the advertisement entirely (recommended, since no node needs to reach this LAN through Tailscale) or, if remote access to the LAN is genuinely needed, leave exactly one node advertising it and ensure no k3s node ever runs with --accept-routes again.

Known non-issues (encountered during rollout, unrelated to Tailscale)

  • fs.inotify.max_user_instances exhaustion on nuc-a — fixed via step 1 above; a general k3s node tuning gap, not Tailscale-specific.
  • Broken host-level nginx/RTMP config on castis-desktop — pre-existing, unrelated OS package issue (nginx: [emerg] unknown directive "rtmp" in /etc/nginx/nginx.conf:8) that happened to surface during apt install tailscale because it triggered processing of a backlog of pending package configurations. Does not affect Tailscale or k3s; left as-is pending a decision on whether that RTMP setup is still needed.