move flannel's wireguard port to 51830, advertise the node address as the tunnel endpoint, drop the 51820 assertion
This commit is contained in:
parent
44ae81470e
commit
8cfd52cd4c
1 changed files with 194 additions and 77 deletions
|
|
@ -24,13 +24,19 @@ cluster of its own beyond that one main node, and it replicates no service.
|
|||
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.
|
||||
tunnel is the device `flannel-wg`, 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.
|
||||
- **Tunnel port:** UDP 51830, set by `--flannel-conf`, which names a net-conf
|
||||
file the module writes with the pod range (`deploy.k8s.podCidr`) and the
|
||||
tunnel's `ListenPort`. k3s has no flag for the port, and flannel's own
|
||||
default, 51820, is the port of the `wg0` that a host in the
|
||||
[semi-spread example](../../2-handbook/swarm/semi-spread-deploy.md#the-vpn-raw-wireguard)
|
||||
runs, and a host in that mesh is a cluster node as well. Every node reads
|
||||
its own file, so a joined host passes the flag too and sets the same
|
||||
`deploy.k8s.podCidr` as the main node. The option
|
||||
`deploy.k8s.flannelWgPort` holds the port, and the firewall rule and the
|
||||
tests read it.
|
||||
- **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
|
||||
|
|
@ -126,12 +132,15 @@ there pulls its image from a peer.
|
|||
On the main node, set the addresses:
|
||||
|
||||
- `deploy.k8s.address`: the address the other nodes reach this one on. Set,
|
||||
it's the node's IP (`--node-ip`) and the API certificate lists it
|
||||
(`--tls-san`). Unset, k3s picks the default route's address, as it did before
|
||||
the option existed.
|
||||
it's the node's IP (`--node-ip`) and its external IP (`--node-external-ip`),
|
||||
the server runs `--flannel-external-ip`, and the API certificate lists it
|
||||
(`--tls-san`). flannel then points the tunnel at that address. Unset,
|
||||
k3s picks the default route's address for the node, and flannel binds the
|
||||
tunnel to the default route's interface and advertises that interface's
|
||||
address, which has to be one of the peers' `nodeAddresses`.
|
||||
- `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 51820 (flannel's
|
||||
(the API, and the image mirror), TCP 10250 (the kubelet), UDP 51830 (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
|
||||
|
|
@ -187,10 +196,28 @@ this by hand:
|
|||
registry.hyperhive.invalid:
|
||||
```
|
||||
|
||||
4. Start k3s as an agent:
|
||||
4. Write the flannel net-conf, which names the tunnel's port, to
|
||||
`/etc/rancher/k3s/flannel-net-conf.json`. `<pod range>` is the main node's
|
||||
`deploy.k8s.podCidr`:
|
||||
|
||||
```json
|
||||
{
|
||||
"Network": "<pod range>",
|
||||
"EnableIPv4": true,
|
||||
"EnableIPv6": false,
|
||||
"IPv6Network": "::/0",
|
||||
"Backend": {
|
||||
"Type": "wireguard",
|
||||
"PersistentKeepaliveInterval": 25,
|
||||
"ListenPort": 51830
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
5. Start k3s as an agent:
|
||||
|
||||
```bash
|
||||
k3s agent --server https://<main node>:6443 --token-file <token file> --node-ip <the machine's address>
|
||||
k3s agent --server https://<main node>:6443 --token-file <token file> --node-ip <the machine's address> --node-external-ip <the machine's address> --flannel-conf /etc/rancher/k3s/flannel-net-conf.json
|
||||
```
|
||||
|
||||
The machine's firewall has to admit the same four ports from the main node and
|
||||
|
|
|
|||
Loading…
Reference in a new issue