1、拓扑图
2、LB配置
- 绑定VIP:
ip address add 20.1.2.15/24 dev ens18
- 配置Cilium:
cilium-agent
--enable-ipv4=true
--enable-ipv6=false
--datapath-mode=lb-only
--bpf-lb-algorithm=maglev
--bpf-lb-dsr-dispatch=ipip
--bpf-lb-acceleration=native
--bpf-lb-mode=dsr
--devices="ens18"
--direct-routing-device=ens18
--bpf-lb-map-max=512000
3、Nginx配置
- 修改默认的arp响应和宣布行为
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
- 在lo网卡绑定VIP
ip address add 20.1.2.15/32 dev lo
- 通过tc加载ebpf代码来对IP-IP进行解包
tc qdisc add dev ens18 clsact && tc filter add dev ens18 ingress bpf direct-action object-file ./test_tc_tunnel.o section decap
参考文章:
如何编译用于IP-IP解包的程序:https://github.com/cilium/cilium/blob/main/test/l4lb/test.sh#L29
https://cilium.io/blog/2021/05/20/cilium-110/#standalonelb
https://cilium.io/blog/2022/04/12/cilium-standalone-L4LB-XDP/