网络拓扑
BigIP 配置 vxlan tunnel
1. 将 data interface 配置上 vlan 和 self IP 地址,确保数据口 self IP 可以正常联通:
2. 创建 vxlan profile:
3. 创建 tunnel 将 vxlan profile 绑定到 data selfip(local Address) 上,用来做 overlay。tunnel 的 key 即是 vxlan 的 id,这里得对映之前 k8s 中 flannel 的 vxlan ID。
4. 创建 bigip underlay 网络接口:
BigIP 上添加一个 self IP 作为 vxlan 的 underlay 网络流量的出入口。
selfip 作为一个流量出入口,它的 netmask 必须保证 k8s 中其他 node 的 underlay 网络访流量都可以问到,所以和 flannel 部署时指定的管理网段一样为 /16
。
selfip 的 IP Address 最好选择和其他 node 不会冲突的任意 IP (IP 地址需要在 Flannel 管理范围内)。
比如这里配置的 IP Address: 10.200.3.1
, Netmask:255.255.0.0
。
注意:k8s 集群中,flannel interface (每台 node 上 flannel.1
名称的 interface) 使用的是 32 位 netmask,但是配置 self IP 不支持,所以不能模仿 k8s flannel 方式配置成 32 位。
Specifies the full netmask. Network prefix lengths (CIDR) are not supported
配置完 IP 和 NETMASK 后,需要绑定上一步创建的 vxlan tunnel profile。
配置完成后 bigip 机器上会有两个 selfip IP,一个是 overlay,一个是 underlay:
k8s 集群上添加 BigIP 设备 (k8s master node)
完成 BigIP 设备配置后,需要将 BigIP 设备作为一个 node 加入 k8s 集群。Node resource 的 yaml 文件如下:
# [root@vxlan-k8s ~]# cat flannel-node.yaml
apiVersion: v1
kind: Node
metadata:
name: bigip1
annotations:
# Replace IP with Self-IP for your deployment
flannel.alpha.coreos.com/public-ip: "10.110.10.10"
# uncomment the following line if using v6 tunnel and modify bigip v6 address
# flannel.alpha.coreos.com/public-ipv6: "2021:15::125"
# Replace MAC with your BIGIP Flannel VXLAN Tunnel MAC
flannel.alpha.coreos.com/backend-data: '{"VtepMAC":"fa:16:3e:0f:6d:4f"}'
# uncomment the following line if using v6 tunnel and modify mac accordingly
# flannel.alpha.coreos.com/backend-v6-data: '{"VtepMAC":"fa:16:3e:d5:28:07"}'
flannel.alpha.coreos.com/backend-type: "vxlan"
flannel.alpha.coreos.com/kube-subnet-manager: "true"
spec:
# Replace Subnet with your BIGIP Flannel Subnet
podCIDR: "10.200.3.0/24"
# uncomment the following 3 lines if using v6 tunnel and modify CIDRs using real data
#podCIDRs:
#- "10.42.20.0/24"
#- "2021:118:2:2::/64"
-
flannel.alpha.coreos.com/public-ip:
数据口的 overlay selfip -
flannel.alpha.coreos.com/backend-data:
创建完 vxlan tunnel,绑定 underlay IP 后,BigIP 会虚拟出来一个和 vxlan tunnel 同名的 interface,将那个 interface 的 MAC 地址配置在此处。
-
podCIDR:
BigIP underlay 的 selfip 地址。注意这里是遵循 flannel 的管理,netmask 需要配置成/24
。但是在 BigIP 上位了所有流量出入 selfip 的 netmask 配置成/16
。
定义完 node yaml 后,在 master 节点运行 kubectl apply -f flannel-node.yaml
。最终可以看到 bigip node 虽然是 NotReady 状态,但是已经加入 k8s 集群。
[root@vxlan-k8s ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
bigip1 NotReady <none> 21d
vxlan-k8s.pdsea.f5net.com Ready control-plane 21d v1.26.1
vxlan-test-1.pdsea.f5net.com Ready <none> 21d v1.26.1
vxlan-test-2.pdsea.f5net.com Ready <none> 21d v1.26.1
测试使用
…