## How to use multus-cni? ### Prerequisite Kubelet must be configured to run with the CNI network plugin. Please see [Kubernetes document for CNI](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#cni) for its detail. ### Install multus You could copy binary directory or could use daemonset yaml in multus repository. - copy multus binary Copy multus binary into CNI binary directory, usually `/opt/cni/bin`. ``` # Execute following commands at all Kubernetes nodes (i.e. master and minions) $ cp multus /opt/cni/bin ``` - use daemonset As [Quickstart](https://github.com/intel/multus-cni/README.md#quickstart-guide), you could apply as such: ``` # Execute following command at Kubernetes master $ cat ./images/{multus-daemonset.yml,flannel-daemonset.yml} | kubectl apply -f - ``` ### Set up conf file in /etc/cni/net.d/ (daemonset automatically does) **If you use daemonset to install multus, skip this section and go to "Create network attachment"** You put CNI config file in `/etc/cni/net.d`. Kubernetes CNI runtime uses the alphabetically first file in the directory. (`"NOTE1"`, `"NOTE2"` are just comments, you can remove them at your configuration) ``` # Execute following commands at all Kubernetes nodes (i.e. master and minions) $ mkdir -p /etc/cni/net.d $ cat >/etc/cni/net.d/30-multus.conf < /etc/cni/net.d/multus.d/multus.kubeconfig < /etc/cni/multus/net.d/macvlan2.conf { "cniVersion": "0.3.0", "type": "macvlan", "name": "macvlan-conf-2", "master": "eth1", "mode": "bridge", "ipam": { "type": "host-local", "ranges": [ [ { "subnet": "11.10.0.0/16", "rangeStart": "11.10.1.20", "rangeEnd": "11.10.3.50", "gateway": "11.10.0.254" } ] ] } } ``` ### Run pod with network annotation #### Lauch pod with text annotation ``` # Execute following command at Kubernetes master $ cat <`. ``` # Execute following command at Kubernetes master $ cat <"`. ``` # Execute following command at Kubernetes master $ cat < 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 promiscuity 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 3: eth0@if11: mtu 1450 qdisc noqueue state UP group default link/ether 0a:58:0a:f4:02:06 brd ff:ff:ff:ff:ff:ff link-netnsid 0 promiscuity 0 veth numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 10.244.2.6/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::ac66:45ff:fe7c:3a19/64 scope link valid_lft forever preferred_lft forever 4: macvlan1@if3: mtu 1500 qdisc noqueue state UNKNOWN group default link/ether 4e:6d:7a:4e:14:87 brd ff:ff:ff:ff:ff:ff link-netnsid 0 promiscuity 0 macvlan mode bridge numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 10.10.1.22/16 scope global macvlan1 valid_lft forever preferred_lft forever inet6 fe80::4c6d:7aff:fe4e:1487/64 scope link valid_lft forever preferred_lft forever 5: net2@if3: mtu 1500 qdisc noqueue state UNKNOWN group default link/ether 6e:e3:71:7f:86:f7 brd ff:ff:ff:ff:ff:ff link-netnsid 0 promiscuity 0 macvlan mode bridge numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 inet 11.10.1.22/16 scope global net2 valid_lft forever preferred_lft forever inet6 fe80::6ce3:71ff:fe7f:86f7/64 scope link valid_lft forever preferred_lft forever ``` | Interface name | Description | | --- | --- | | lo | loopback | | eth0 | Default network interface (flannel) | | macvlan1 | macvlan interface (macvlan-conf-1) | | net2 | macvlan interface (macvlan-conf-2) |