Multus CNI是OpenShift的容器網絡接口(CNI)插件,可將多個網絡接口附加到Pod。 一般,在OpenShift中,每一個Pod僅具備一個網絡接口(除了回送),Multus支持建立具備多個接口的多宿主Pod。 這是經過Multus充當「meta-plugin」來完成的,它支持調用多個其餘CNI插件的CNI插件。centos
如圖,這樣在Multus安裝狀況下,部署應用時能夠經過annotation決定是否啓用(缺省不啓用),若是啓用,Pod將會有兩個ip,一個是容器網段ip,另外一個是macvlan獲取的IP. 這樣若是須要高速網絡鏈接,就能夠經過這個ip進行基於下層網絡的通信。api
在OpenShift 4的版本中還會支持SR-IOV Plug-in,進一步提高網絡高速性能。bash
cd /usr/share/ansible/openshift-ansible
ansible-playbook -i /etc/ansible/hosts playbooks/openshift-multinetwork/config.yml
部署完成後,發如今每一個節點除了ovs外,還有有一個daemonset:服務器
[root@master test]# oc get pods -n openshift-sdn NAME READY STATUS RESTARTS AGE kube-multus-ds-amd64-29gvf 1/1 Running 3 1d kube-multus-ds-amd64-ps4gh 1/1 Running 5 1d kube-multus-ds-amd64-zwjnr 1/1 Running 3 1d ovs-dzbjv 1/1 Running 23 23d ovs-fg96b 1/1 Running 15 23d ovs-przqm 1/1 Running 20 23d sdn-2qwrv 1/1 Running 17 23d sdn-jcldg 1/1 Running 24 23d sdn-w2nzh 1/1 Running 27 23d
apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: macvlan-conf spec: config: '{ "cniVersion": "0.3.0", "type": "macvlan", "master": "ens33", "mode": "bridge", "ipam": { "type": "host-local", "subnet": "192.168.174.0/24", "rangeStart": "192.168.174.200", "rangeEnd": "192.168.174.216", "routes": [ { "dst": "0.0.0.0/0" } ], "gateway": "192.168.174.2" } }'
修改相應的網段,網卡名稱,以及網管地址網絡
oc create -f macvlan.yaml
apiVersion: v1 kind: Pod metadata: name: samplepod annotations: k8s.v1.cni.cncf.io/networks: macvlan-conf spec: containers: - name: samplepod command: ["/bin/bash", "-c", "sleep 2000000000000"] image: registry.example.com/centos-network
進入Pod後,經過ifconfig看到有兩個網卡eth0和net1,分別綁定了容器網絡和macvlan網絡。架構
基於OCP外的機器訪問地址能通性能
針對現有的deploymentconfig中修改爲multus方式,只須要在dc中加入測試
annotations:spa
k8s.v1.cni.cncf.io/networks: macvlan-conf插件
Pod啓動之後自動獲取macvlan地址並設置網關。