Open
Description
I first modified the canal-config on a running cluster:
kubectl edit configmap canal-config -n kube-system
And then put the contents of the wireguard extension inside of the net-conf.json block:
net-conf.json:
----
{
"Network": "10.42.0.0/16",
"Backend": {
"Type": "extension",
"PreStartupCommand": "wg genkey | tee privatekey | wg pubkey",
"PostStartupCommand": "export SUBNET_IP=`echo $SUBNET | cut -d'/' -f 1`; ip link del flannel-wg 2>/dev/null; ip link add flannel-wg type wireguard && wg set flannel-wg listen-port 51820 private-key privatekey && ip addr add $SUBNET_IP/32 dev flannel-wg && ip link set flannel-wg up && ip route add $NETWORK dev flannel-wg",
"ShutdownCommand": "ip link del flannel-wg",
"SubnetAddCommand": "read PUBLICKEY; wg set flannel-wg peer $PUBLICKEY endpoint $PUBLIC_IP:51820 allowed-ips $SUBNET",
"SubnetRemoveCommand": "read PUBLICKEY; wg set flannel-wg peer $PUBLICKEY remove"
}
}
This is exactly what k3s is doing, (See: https://github.com/rancher/k3s/blob/master/pkg/agent/flannel/setup.go#L62).
gz#12903