查看日志发现是因为启用了 enable-endpoint-routes
$ kubectl logs --since 5m ds/cilium -n kube-system | grep legacy
level=info msg=" --enable-host-legacy-routing='false'" subsys=daemon
level=info msg="BPF host routing is currently not supported with enable-endpoint-routes. Falling back to legacy host routing (enable-host-legacy-routing=true)." subsys=daemon
修改 configmap,改为 enable-endpoint-routes: "false"
kubectl edit cm cilium-config -n kube-system
日志变为
level=info msg="BPF host routing requires kernel 5.10 or newer. Falling back to legacy host routing (enable-host-legacy-routing=true)." subsys=daemon
原来是 linux 内核版本不够,服务器操作系统用的是 Ubuntu 20.04.4,内核版本是 5.4
通过下面的命令将 kernel 升级至 5.14 后就解决了
add-apt-repository ppa:cappelikan/ppa -y && \
apt update && \
apt install mainline -y && \
apt install linux-oem-20.04b -y && \
reboot
@dudu: 如果出现下面的日志,需要给 helm 部署命令添加 -set bpf.masquerade=true
参数
BPF host routing requires enable-bpf-masquerade. Falling back to legacy host routing (enable-host-legacy-routing=true)