部署Bond-CNI插件
Bond-CNI需要与其他的多网卡和直通插件集成,在Pod内部完成虚拟网卡的Bonding。与之前SRIOV-CNI网络直通插件的配置不同的是,在SR-IOV设备的configMap当中,使用PF来区分网络设备,如下为bond4模式的配置。
- 对物理机上的两个网卡设备进行VF直通配置。
在sriov-crd-01.yaml中配置一个网卡设备VF直通。
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: sriov-net1 annotations: k8s.v1.cni.cncf.io/resourceName: huawei.com/huawei_1822_netdevice_01 spec: config: '{ "type": "sriov", "cniVersion": "0.3.1", "name": "sriov-network", "spoofchk":"off" }'
在sriov-crd-02.yaml中配置另一个网卡设备VF直通。
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: sriov-net2 annotations: k8s.v1.cni.cncf.io/resourceName: huawei.com/huawei_1822_netdevice_02 spec: config: '{ "type": "sriov", "cniVersion": "0.3.1", "name": "sriov-network", "spoofchk":"off" }'
新建完成后,在集群中进行部署。
kubectl apply -f sriov-crd-01.yaml kubectl apply -f sriov-crd-02.yaml
- 配置Bond网络接口,新建sriov-crd-bond.yaml进行配置。
配置中通过“mode”参数指定bonding模式,常见模式有:
- “balance-rr”(mode=0)
- “active-backup”(mode=1)
- “balance-xor”(mode=2)
- “broadcast”(mode=3)
- “802.3ad”(mode=4)
- “balance-tlb”(mode=5)
- “balance-alb”(mode=6)
当前仅建议使用mode=0,1,2三种模式,由于mode=4模式下的协议限制,单个集群节点上无法使用多个mode=4的容器。部署示例如下:
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: bond-net1 spec: config: '{ "type": "bond", "cniVersion": "0.3.1", "name": "bond-net1", "mode": "balance-xor", "faileOverMac": 1, "linksInContainer": true, "miimon": "100", "mtu": 1500, "links": [ {"name": "net1"}, {"name": "net2"} ], "ipam": { "type": "host-local", "subnet": "10.56.217.0/24", "routes": [{ "dst": "0.0.0.0/0" }], "gateway": "10.56.217.1" } }'
新建完成后,在集群中部署。
kubectl apply -f sriov-crd-bond.yaml
注意:
- “active-backup”模式的“failOverMac”属性是必需的,必须设为“1”。
- “linksInContainer=true”标志告知Bond-CNI在容器内找到所需的接口。默认情况下,在容器内使用设置为true。
- “links”部分定义将用于创建绑定的接口。默认情况下,Multus将附加的接口命名为"net",再加上一个连续的数字。
- 对于“balance-rr”或“balance-xor”模式,必须为SR-IOV VF将“trust”模式设置为“on”。方式一:在“sriov-crd-01.yaml”和“sriov-crd-02.yaml”配置文件中添加“"trust": on”
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: sriov-net2 annotations: k8s.v1.cni.cncf.io/resourceName: huawei.com/huawei_1822_netdevice_02 spec: config: '{ "type": "sriov", "cniVersion": "0.3.1", "name": "sriov-network", "spoofchk":"off", "trust": "on" }'
方式二:“ip link”直接开启trust模式:
ip link set dev <pf接口名> vf <vf编号> 0 trust on
设置后可通过“ip link show <PF接口名>”查看对应的是否出现“trust on”,如下所示:
7: enp65s0f1np1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 20:fa:db:e2:84:ed brd ff:ff:ff:ff:ff:ff vf 0 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust on, query_rss off vf 1 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off vf 2 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off vf 3 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off vf 4 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking off, link-state auto, trust off, query_rss off
父主题: 部署