glb-director 部署

源码下载:https://github.com/github/glb-director.git

2018年8月8日,GitHub 发布了开源负载均衡组件 GitHub Load Balancer Director (GLB) Director,GLB 是 GitHub 针对裸机数据中心的可扩展负载均衡解决方案,它支持大多数 GitHub 的对外服务,并且还为诸如高可用 MySQL 集群这样最为关键的内部系统提供负载均衡服务。

GLB-director的亮点:

1)L4 LB集群+BGP ECMP,实现director节点线性扩展;

2)director群集节点独立生成静态转发表,director节点增减时保证连接一致性;

3)利用proxy节点iptable提供二次调度,服务器节点增减时保证连接一致性;

4)转发面DPDK加速,利用Flow Bifurcation实现Linux用户态和内核态流量分配。

 

从通用性的角度来看,GLB-director有一些不足:

1)仅支持TCP业务;

2)GUE隧道封装解封装,增加CPU负担;

3)涉及服务器侧修改,耦合大、侵入式;

4)无状态实现有利有弊,弊端是无法做到连接数均衡、连接数限流等。

 

Github glb-director最大的技术特点是利用GUE隧道,实现无状态连接一致性。

 

配置文件如下:

[root@junqiang glb-director]# cat /etc/glb/director.conf 
{
  "outbound_gateway_mac": "00:50:56:e3:57:e4", // 封装的目的MAC
  "outbound_src_ip": "192.168.220.105",        // 封装的源IP地址
  "forward_icmp_ping_responses": true,
  "num_worker_queues": 1,
  "flow_paths": [
    { "rx_port": 0, "rx_queue": 0, "tx_port": 0, "tx_queue": 0 }
  ]
}


[root@junqiang glb-director]# cat /etc/glb/forwarding_table.json 
{
    "tables": [
    {
        "name": "example1",
        "hash_key": "12345678901234561234567890123456",
        "seed": "34567890123456783456789012345678",
        "binds": [
            { "ip": "100.100.100.100", "proto": "tcp", "port": 80 } // VIP 地址和端口
        ],
        "backends": [
            { "ip": "192.168.220.102", "state": "active", "healthchecks": {"http": 80, "gue": 19523} }, // 后端地址
            { "ip": "192.168.220.103", "state": "active", "healthchecks": {"http": 80, "gue": 19523} }
        ]
    }
    ]
}

其中forwarding_table.json需要用glb-director-cli工具进行转换成forwarding_table.bin

glb-director-cli build-config /etc/glb/forwarding_table.json /etc/glb/forwarding_table.bin

需要启动两个进程:

# 指定那个接口跑xdp
./xdp-root-shim/xdp-root-shim bpf/tailcall.o /sys/fs/bpf/xdp_root_array@ens33 ens33

# 主要进程
./glb-director-xdp --xdp-root-path=/sys/fs/bpf/xdp_root_array@ens33 --pid-file=/run/glb-director-xdp.pid --config-file=/etc/glb/director.conf --forwarding-table=/etc/glb/forwarding_table.bin --bpf-program=bpf/glb_encap_trace.o

后端配置:

modprobe fou
ip fou add port 19523 gue
ip addr add 192.168.220.103/32 dev tunl0
# tunl0 接口将会进行解封装

 

抓包:

 

 

 

 

posted @ 2022-09-18 10:14  salami_china  阅读(87)  评论(0编辑  收藏  举报