Watch
0
0
Fork
You've already forked hyperhive
0

run flannel's wireguard-native backend on every k8s node

This commit is contained in:
atlas 2026-11-27 22:48:56 +01:00 • committed by maia
commit 44ae81470e

View file

@ -18,6 +18,19 @@ cluster of its own beyond that one main node, and it replicates no service.
metrics-server are off, and the cluster encrypts its Secrets at rest
(`--secrets-encryption`). CoreDNS and the local-path provisioner stay on, so
pods have cluster DNS and PersistentVolumeClaims.
- **Pod network:** flannel's `wireguard-native` mode
(`--flannel-backend=wireguard-native`), so the traffic between nodes is
encrypted and authenticated. Each node holds a WireGuard key of its own,
k3s publishes the public keys through the API server, and a node drops a
frame from a host that holds no listed key, whatever address it comes from.
A joined node takes the mode from the server and needs no flag. The
tunnel is the device `flannel-wg`, on UDP 51820, and the cluster is IPv4
only, so there is no IPv6 device or port. Every node runs the same mode:
a node that runs another one doesn't reach the others' pods. A WireGuard
interface of the host's own that listens on UDP 51820, like the `wg0` of the
[semi-spread example](../../2-handbook/swarm/semi-spread-deploy.md#the-vpn-raw-wireguard),
can't share the port, and the evaluation fails when `networking.wireguard`
or `networking.wg-quick` declares one.
- **Images:** the node holds k3s's own images and the image of each service
that [renders manifests](manifests.md) on this host, in containerd before k3s
starts. No registry service exists. A pod names its image with
@ -33,7 +46,7 @@ cluster of its own beyond that one main node, and it replicates no service.
evaluation fails when one does: the bridge and the cluster would route the
same addresses. k3s's own default pod range, `10.42.0.0/16`, contains the
bridge's default subnet.
- **Firewall:** the pod network's interfaces, `cni0` and `flannel.1`, are
- **Firewall:** the pod network's interfaces, `cni0` and `flannel-wg`, are
trusted, so the node reaches its pods. The node-to-node ports are open to
the addresses in `deploy.k8s.nodeAddresses` only, which is empty by default
([Joining nodes](#joining-nodes)).
@ -118,8 +131,10 @@ On the main node, set the addresses:
the option existed.
- `deploy.k8s.nodeAddresses`: the addresses of the nodes that may join. The
firewall admits these ports from them and from no other source: TCP 6443
(the API, and the image mirror), TCP 10250 (the kubelet), UDP 8472 (flannel's
VXLAN tunnel) and TCP 5001 (the mirror's peers). It writes iptables rules
(the API, and the image mirror), TCP 10250 (the kubelet), UDP 51820 (flannel's
WireGuard tunnel) and TCP 5001 (the mirror's peers). The tunnel checks the
peer's key as well as its address, so the source filter is a second
check. It writes iptables rules
and refuses a host with `networking.nftables.enable`. With the list empty,
no port is open.
@ -240,7 +255,7 @@ token against the node's own signing keys.
certificate and asks for no client certificate. A pod dials it by the name it
dials the store by, `bao.<swarm domain>`, which CoreDNS answers with the
bridge's address.
- **Firewall:** that port is open on `cni0` and `flannel.1` and on no other
- **Firewall:** that port is open on `cni0` and `flannel-wg` and on no other
interface. The bridge's firewall refuses it, so an agent on the bridge can't
connect. Binding an address doesn't isolate a port, because the kernel
accepts a packet for any local address on any interface, so the firewall