/Kubernetes-Multus-CNI

Kubernetes 上安装使用 Multus 网络插件

Creative Commons Attribution 4.0 InternationalCC-BY-4.0

Kubernetes-Multus-CNI

1. 在 Ubuntu上安装 Kubernetes 集群

具体方式可以见:ubuntu-Kubernetes

2. 部署Multus CNI到K8S

下载multus代码

git clone https://github.com/intel/multus-cni.git

进入image目录,部署Multus环境主要由“flannel-daemonset.yml multus-daemonset.yml ”这两个编排文件完成。flannel-daemonset.yaml部署flannel网络需要的基础组件。Multus在K8S环境中是作为CNI插件使用的,所以和部署一般的网络插件方式类似,由multus-daemonset.yml文件编排完成,主要动作包括权限配置,写入配置到K8S,运行提供CNI功能的容器

cd multus-cni/images
cat {flannel-daemonset.yml,multus-daemonset.yml} | kubectl apply -f -
cd ../..

在K8S环境中配置额外的CNI插件

$ ifconfig | grep ens
ensXXX      Link encap:Ethernet  HWaddr 02:42:ac:11:00:07

git clone https://github.com/yu3peng/Kubernetes-Multus-CNI.git
cd Kubernetes-Multus-CNI

vi macvlan-conf-1.yaml
替换文件中的ensXXX为通过ifconfig查询到的值

kubectl apply -f macvlan-conf-1.yaml

3. 使用Multus CNI部署多接口POD

kubectl apply -f pod-case-01.yaml 

部署完成后查看POD接口,eth0为flannel插件提供,net1由macvlan提供

$ kubectl get pod
NAME          READY   STATUS    RESTARTS   AGE
pod-case-01   1/1     Running   0          20m
$ kubectl exec pod-case-01 ip a
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
4: eth0@if69: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1440 qdisc noqueue state UP group default
    link/ether 56:9b:8e:77:e0:52 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.239.197/32 scope global eth0
       valid_lft forever preferred_lft forever
5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
    link/ether 6e:5a:08:a0:da:e0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.10.1.21/16 scope global net1
       valid_lft forever preferred_lft forever

4. 参考

  1. Kubernetes Multus-CNI