Set up HA from DigitalOcean APISIX to the private k3s cluster
Companion document: ha-architecture.html — read that for the why behind each step below; this file is the what to actually do, in order. Section numbers here (Step N) are cross-referenced from the matching §N in the architecture doc, so if a step here is confusing, jump to the matching section there for the full reasoning and diagrams.
Final architecture in one line: DO Load Balancer → 3 DO droplets running APISIX → each APISIX upstream lists 3 of the private cluster nodes' own individual Tailscale IPs directly (mac-mini excluded from this specific upstream), with APISIX active health checks doing the failover. Separately, nuc-a and nuc-b also advertise the home LAN subnet as an HA Tailscale subnet route, for reaching the wider <HOME_LAN_CIDR> network beyond just the APISIX path. No MetalLB, no Headscale involved.
0. Current inventory (as of this session)¶
DigitalOcean (SGP1), Tailscale already installed on all three:
| Droplet | Public IP | Tag | Role |
|---|---|---|---|
| ubuntu-worker-node-A | worker-node-A | APISIX gateway node | |
| ubuntu-24-04-LTS-control-plane | control-plane | APISIX gateway node | |
| ubuntu-mashup-gitlab-haproxy | worker-node | APISIX gateway node + GitLab/CI (shared) |
These 3 droplets already form their own small k3s cluster running APISIX. That cluster currently has an internal MetalLB config used to hand Service type: LoadBalancer a VIP — this is being replaced by DO's actual Load Balancer product, so it's being removed (Step 1).
Private cluster (home, k3s): castis-desktop, nuc-a, nuc-b (control-plane), mac-mini (worker). One router, one switch (Ruijie) at home. Tailscale not yet installed here — this guide installs it.
Note on node counts: the 3 DO droplets running APISIX and the 3 private nodes listed in the upstream config (§Step 4 — mac-mini is on the tailnet and wired, but deliberately excluded from this particular upstream) are unrelated counts that happen to match — don't read anything into the coincidence.
Step 1 — Decommission the internal MetalLB config on the DO-side cluster¶
Since DO's own Load Balancer product will now front the 3 droplets directly (by targeting them via their DO-assigned IPs/tags), the internal MetalLB VIP inside that small cluster becomes redundant — two independent mechanisms trying to solve the same "give this Service a stable external IP" problem.
- Confirm the DO Load Balancer (Step 5) is live and passing traffic before removing anything — don't remove this until the replacement is proven working.
- Once confirmed, remove the
IPAddressPool/L2Advertisement(or whatever MetalLB CRs exist) from that cluster, and change the affectedServiceback toClusterIPorNodePortas appropriate for however APISIX is deployed there. - Uninstall the MetalLB controller/speaker from that cluster if nothing else in it depends on it.
Step 2 — Install Tailscale on all 4 private cluster nodes¶
On each of castis-desktop, nuc-a, nuc-b, mac-mini:
Each node gets its own ordinary Tailscale identity/IP — this part is unchanged.
Record each node's Tailscale IP (tailscale ip -4) — you'll need them for Step 4.
Step 2a — HA subnet route advertisement (for SSH maintenance access to the wider <HOME_LAN_CIDR> LAN)¶
Purpose, to be explicit: this route is for your own SSH/admin access to devices on the home LAN from wherever you're working — not for APISIX traffic, and not something the DO edge droplets need. APISIX's upstream (Step 4) already talks directly to specific nodes' own Tailscale IPs for the ingress path; that's unrelated to this. This route exists so that when you're off-site, you can SSH into anything on <HOME_LAN_CIDR> — including devices that aren't individually joined to the tailnet — through your own Tailscale client, without needing to be on the home Wi-Fi or open anything on the router.
Do this from both nuc-a and nuc-b so it's not a new single point of failure — Tailscale automatically fails over between multiple nodes advertising the same route:
# on nuc-a
sudo tailscale up --advertise-routes=<HOME_LAN_CIDR> --accept-routes
# on nuc-b
sudo tailscale up --advertise-routes=<HOME_LAN_CIDR> --accept-routes
Then approve both routes in the Tailscale admin console (Machines → each node → "Edit route settings" → enable) — an advertised route sits disabled until approved, and approving only one defeats the point of doing this from two nodes.
Scope this down in your Tailscale ACL — since this is for your own SSH maintenance, restrict access to <HOME_LAN_CIDR> to your personal admin device(s) (e.g. tag them tag:admin), not to tag:do-edge or any other device on the tailnet. The DO edge droplets have no reason to reach the wider LAN — they only need the specific node IPs already covered by Step 4 — so giving them this route too would be unnecessary exposure. Example ACL rule:
Advertising the whole /24 is broader than the tightly-scoped single-VIP CIDR discussed earlier, which is fine for this purpose — an admin device doing SSH maintenance legitimately needs to reach various hosts on the LAN, not just one VIP. The ACL restricting who can use the route is what keeps that broader scope from becoming a real exposure — particularly since it should exclude the DO droplets entirely, not just APISIX's specific targets.
Step 3 — Expose the ingress controller identically on every target node¶
This is the step most likely to silently break the whole design if skipped. APISIX sends traffic directly to each node's own Tailscale IP on port 80 — so whatever's supposed to answer there needs to actually be listening on every node in the list, not just wherever the ingress pod happens to be scheduled.
Settled, confirmed against the real cluster: apisix-gateway (the private cluster's ingress) is type: LoadBalancer:
apisix-gateway LoadBalancer <APISIX_GATEWAY_CLUSTER_IP> <K3S_NODE_A_LAN_IP>,<K3S_NODE_B_LAN_IP>,<K3S_NODE_C_LAN_IP>,<K3S_NODE_D_LAN_IP> 80:30081/TCP,9180:30181/TCP,9091:32674/TCP,9443:32043/TCP
svclb-apisix-gateway-* pods (one per home node) and an empty metallb-system namespace — is k3s's built-in ServiceLB ("klipper-lb"), not MetalLB (which was planned but never actually installed on this cluster). ServiceLB runs a small DaemonSet, one pod per node, each binding port 80 directly on its own node via hostPort. That's what makes port 80 answer on every node's every interface, LAN and Tailscale alike, and it's a designed per-node mechanism — not a coincidence of the current 4 nodes — so it'll keep working automatically as nodes are added or removed, with no config to maintain. MetalLB is not needed on the private cluster for this design.
Practical conclusion: use port 80 in Step 4's ApisixUpstream. Confirmed working, no further action needed for this specific Service.
Two things still worth a one-time check:
1. No host firewall (ufw, iptables) scopes port 80 to the LAN interface only, in a way a future OS update could tighten.
2. If a different Service is added later that isn't already type: LoadBalancer with ServiceLB behind it (e.g. still ClusterIP), it won't get this behavior automatically — pick one of:
- NodePort or LoadBalancer: either gets you a per-node listener the same way, though LoadBalancer via k3s's ServiceLB is what gives you the exact port (80) rather than a random NodePort.
- hostNetwork / DaemonSet: run it as a DaemonSet with hostNetwork: true (or hostPort), for a local listener on every node without going through a Service at all.
Verify before moving on:
All three should answer identically (mac-mini doesn't need to, since it's not in Step 4's upstream list).
Step 4 — Configure ApisixUpstream with multiple nodes + health checks¶
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
name: nexus-private
namespace: nexus
spec:
externalNodes:
- type: Domain
name: "<NUC_A_TAILSCALE_IP>" # nuc-a
port: 80 # confirmed working over Tailscale via k3s's built-in ServiceLB — see Step 3
weight: 1
- type: Domain
name: "<NUC_B_TAILSCALE_IP>" # nuc-b
port: 80
weight: 1
- type: Domain
name: "<CASTIS_DESKTOP_TAILSCALE_IP>" # castis-desktop
port: 80
weight: 1
# mac-mini removed from this upstream by decision — still on the tailnet
# (wired, Step 2), just not a backend for this particular Service/route.
scheme: http
loadbalancer:
type: roundrobin
healthCheck:
active:
type: http
httpPath: /healthz
timeout: 3
healthy:
interval: 2
successes: 2
unhealthy:
interval: 1
httpFailures: 2
passive:
healthy:
successes: 2
unhealthy:
httpFailures: 3
timeouts: 3
Apply it, then confirm APISIX shows all 3 nodes healthy in its dashboard/admin API before relying on it.
Step 5 — DO Load Balancer in front of the 3 DO droplets¶
- Create a DO Load Balancer, forwarding rules for whatever ports APISIX listens on (80/443).
- Target it at the tags covering all 3 droplets — you confirmed earlier that including
ubuntu-mashup-gitlab-haproxyis acceptable for your risk tolerance; just be aware it also carries CI load (see architecture doc §4 for the shared-resource risk note). - Health check should hit an APISIX/route health endpoint, not just "is the process up" — you want DO to stop sending traffic to a droplet whose APISIX can't actually reach the private cluster, not just one that's technically alive.
Step 6 — Headscale: no action needed¶
Confirmed decision: stay on Tailscale's own SaaS coordination plane. Do not stand up Headscale — it has no supported HA/clustering mode and would introduce a new single point of failure. (Full reasoning in architecture doc §2.)
Step 7 — Home network hardening (independent of the above, do in parallel)¶
You have 1 router + 1 switch — this is a hard SPOF that can't be fixed by Kubernetes/Tailscale config. Two tiers, pick based on budget.
Now, no new hardware (Topology A): - Configure 802.3ad LACP bonding on any node with 2 NICs — confirm the Ruijie switch model supports LACP first. - Buy and pre-configure one cold-spare router and one cold-spare switch, configs backed up, ready to swap in under ~15 minutes if the primary dies. - Optional: a 4G/5G backup WAN path as a secondary default route.
Later, real fix (Topology B) — and an important correction:
A common misconception (worth flagging explicitly, since it came up): tightening the trunk allowed-VLAN list and enabling spanning tree do not, by themselves, remove the switch as a SPOF for any device. Those two things solve different problems: - The trunk allow-list (already done — VLANs 1/2/26 only) is about reducing broadcast noise, nothing to do with redundancy. - STP's job is loop prevention on the redundant links between switches/routers once you have more than one path — it doesn't invent a second physical path to a device that only has one cable.
For a switch to genuinely stop being a SPOF for a given device, that device needs an actual second physical path to the network that doesn't go through the switch that just died. Concretely, that means:
- Each of the 4 nodes needs a second NIC, cabled once to Switch 1 and once to Switch 2. If a node only has one NIC, no amount of switch-side configuration saves it — check which of
castis-desktop,nuc-a,nuc-b,mac-miniactually have a spare NIC or a USB/Thunderbolt-Ethernet adapter available before committing to this topology. - Host-side NIC bonding, mode
active-backup(not802.3ad/LACP) on each node — LACP across two independent switches only works if both switches support MLAG/stacking so they present as one logical LACP partner; typical Ruijie access-layer switches usually don't. Active-backup avoids that requirement entirely: normal traffic goes out NIC 1 → Switch 1; if that link or Switch 1 dies, the kernel fails over to NIC 2 → Switch 2 with no special switch cooperation needed. - A link between Switch 1 and Switch 2 (and/or both switches uplinking to both routers) is what actually creates a loop in the topology — this is where STP (ideally RSTP for faster convergence, seconds instead of the classic ~30-50s) becomes necessary: it keeps one path blocked in normal operation and unblocks it automatically if the primary path fails. STP is the mechanism that makes the inter-switch/inter-router redundancy safe, not the mechanism that makes a single-homed end device survive.
- Second router in VRRP/keepalived pair, as before.
So the accurate one-line version: trunk-allow-list and STP are necessary-but-not-sufficient — they keep a meshed multi-switch/multi-router topology from melting down with a broadcast storm, but the thing that actually removes the switch SPOF for each of your 4 devices is dual NICs + dual cabling + host-side active-backup bonding. STP alone changes nothing for a node with only one cable.
Full diagrams for both topologies, updated for all 4 nodes, in architecture doc §5.
Step 7a — Reference configs for Topology B (switches, routers, hosts)¶
These assume your existing gear: Ruijie switches (Cisco-like CLI, as used in the earlier VLAN trunk work) and a MikroTik RouterOS router (as used in the cross-VLAN casting work). Adjust syntax to your actual firmware versions — treat this as a template, verify against your device's docs before applying.
What "just configure the trunk" actually covers, and what it doesn't: the inter-switch trunk port (0/23 below) is one piece — it's the physical link STP needs to manage. But on its own, a trunk port with default settings gets you classic STP (slow, ~30-50s convergence) and a root-bridge choice decided arbitrarily by whichever switch has the lower MAC address. Two more one-line global commands make it actually useful for HA: spanning-tree mode rstp (fast convergence) and spanning-tree priority (deterministic root bridge — put the lower number on whichever switch you want as root). Both are in the config below; neither is optional if you want predictable, fast failover rather than "technically works, eventually."
Switch 1 (intended root bridge — lower priority number):
configure terminal
spanning-tree mode rstp
spanning-tree priority 4096
interface GigabitEthernet 0/1
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/2
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/3
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/4
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
! ports 0/1-0/4 = primary link for castis-desktop, nuc-a, nuc-b, mac-mini respectively
! inter-switch link — this is the redundant path STP needs to manage
interface GigabitEthernet 0/23
switchport mode trunk
switchport trunk allowed vlan only 1,2,26
spanning-tree link-type point-to-point
exit
! uplink to Router 1
interface GigabitEthernet 0/24
switchport mode access
switchport access vlan 1
exit
exit
write
Switch 2 (backup root — higher priority number, or just leave the default 32768 so it never wins the tie-break):
configure terminal
spanning-tree mode rstp
spanning-tree priority 8192
interface GigabitEthernet 0/1
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/2
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/3
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
interface GigabitEthernet 0/4
switchport mode access
switchport access vlan 2
spanning-tree portfast
exit
! ports 0/1-0/4 = backup link for castis-desktop, nuc-a, nuc-b, mac-mini respectively
interface GigabitEthernet 0/23
switchport mode trunk
switchport trunk allowed vlan only 1,2,26
spanning-tree link-type point-to-point
exit
interface GigabitEthernet 0/24
switchport mode access
switchport access vlan 1
exit
exit
write
spanning-tree portfast on the host-facing access ports so they come up immediately (skip STP's listening/learning delay) — do not put portfast on the inter-switch trunk (0/23), that's the actual redundant path STP needs to negotiate. spanning-tree mode rstp (Rapid STP) converges in low single-digit seconds if the trunk link fails, versus classic STP's ~30-50s.
Routers — MikroTik RouterOS VRRP pair:
Router 1 (intended primary — higher priority):
/interface vrrp
add interface=ether1 name=vrrp-lan vrid=51 priority=200
/ip address
add address=<LAN_GATEWAY_VIP>/24 interface=vrrp-lan
/interface vrrp
add interface=ether1 name=vrrp-lan vrid=51 priority=100
/ip address
add address=<LAN_GATEWAY_VIP>/24 interface=vrrp-lan
<LAN_GATEWAY_VIP> — that address now floats to whichever router currently holds VRRP mastership.
Hosts — Linux nodes (castis-desktop, nuc-a, nuc-b) — active-backup bonding via netplan:
network:
version: 2
ethernets:
eth0: {dhcp4: no}
eth1: {dhcp4: no}
bonds:
bond0:
interfaces: [eth0, eth1]
addresses: [<NODE_LAN_IP>/24] # replace with the node's actual LAN IP
gateway4: <LAN_GATEWAY_VIP> # the VRRP virtual IP above
parameters:
mode: active-backup
primary: eth0
mii-monitor-interval: 100
sudo netplan apply. mode: active-backup (not 802.3ad) is the deliberate choice here — LACP across two independent, non-stacked switches isn't reliable; active-backup needs zero switch-side cooperation, it's purely the kernel deciding which NIC is currently live.
mac-mini — important gap, read before assuming this applies uniformly:
macOS's built-in NIC bonding ("Manage Virtual Interfaces" → "New Link Aggregate") only implements 802.3ad/LACP — there's no built-in active-backup mode. Since your two switches aren't stacked/MLAG-capable, LACP across them won't work reliably, which means true kernel-level dual-NIC failover isn't cleanly available on mac-mini the way it is on the three Linux boxes.
Practical options, in order of how much complexity they add:
1. Leave mac-mini single-homed to one switch, accept it as the one node without switch-level redundancy. Now that mac-mini is also excluded from the APISIX upstream (Step 4), this is a low-stakes call either way — nothing in the public-facing path depends on it, so a switch failure taking it offline doesn't affect APISIX at all.
2. A DIY scripted failover (a launchd daemon watching link/gateway reachability and switching networksetup service order on failure) — works, but it's bespoke and another thing to maintain and test.
3. Skip dual-homing mac-mini specifically and instead treat it as disposable in this topology.
Recommendation: option 1, more so now than before — since mac-mini carries no public-facing traffic, there's little reason to invest in scripted failover for it.
Step 8 — Home hardware inventory check for Topology B¶
Before buying anything for Topology B, confirm which of the 4 nodes actually have (or can cheaply gain via USB/Thunderbolt adapter) a second NIC — that determines whether Topology B's dual-homing is achievable as designed, or needs adjusting per-node.
Step 9 — End-to-end failover verification¶
Do this before calling the migration done:
1. Under load, kill each APISIX-upstream private node one at a time (nuc-a, nuc-b, castis-desktop) — confirm APISIX's health check pulls it out of rotation within the configured interval and traffic continues through the remaining nodes.
2. Kill each DO droplet one at a time — confirm the DO Load Balancer routes around it.
3. Confirm a full recovery (bring the killed node back) results in APISIX adding it back into rotation automatically.
4. Separately, test the Step 2a subnet route: from your admin device (tag:admin), SSH to a <HOME_LAN_HOST_IP> host to confirm the route works at all; then, with both nuc-a and nuc-b advertising the route, disable Tailscale (or power off) on whichever is currently carrying it, and confirm your admin device's SSH session/route fails over to the other within a few seconds — check via tailscale status. Separately confirm a DO droplet cannot reach <HOME_LAN_CIDR> at all, since it was deliberately left out of the ACL.
5. Time each of the above — write the actual observed failover latency into the architecture doc's §4 table so it's not just theoretical.