Multus

Multus is a meta CNI plugin that provides multiple network interface support to pods. For each interface, Multus delegates CNI calls to secondary CNI plugins such as Calico, macvlan, etc.

See multus documentation.

Multus installation

Since Multus itself does not implement networking, it requires a master plugin, which is specified through the variable kube_network_plugin. To enable Multus an additional variable kube_network_plugin_multus must be set to true. For example,

  1. kube_network_plugin: calico
  2. kube_network_plugin_multus: true

will install Multus and Calico and configure Multus to use Calico as the primary network plugin.

Using Multus

Once Multus is installed, you can create CNI configurations (as a CRD objects) for additional networks, in this case a macvlan CNI configuration is defined. You may replace the config field with any valid CNI configuration where the CNI binary is available on the nodes.

  1. cat <<EOF | kubectl create -f -
  2. apiVersion: "k8s.cni.cncf.io/v1"
  3. kind: NetworkAttachmentDefinition
  4. metadata:
  5. name: macvlan-conf
  6. spec:
  7. config: '{
  8. "cniVersion": "0.4.0",
  9. "type": "macvlan",
  10. "master": "eth0",
  11. "mode": "bridge",
  12. "ipam": {
  13. "type": "host-local",
  14. "subnet": "192.168.1.0/24",
  15. "rangeStart": "192.168.1.200",
  16. "rangeEnd": "192.168.1.216",
  17. "routes": [
  18. { "dst": "0.0.0.0/0" }
  19. ],
  20. "gateway": "192.168.1.1"
  21. }
  22. }'
  23. EOF

You may then create a pod with and additional interface that connects to this network using annotations. The annotation correlates to the name in the NetworkAttachmentDefinition above.

  1. cat <<EOF | kubectl create -f -
  2. apiVersion: v1
  3. kind: Pod
  4. metadata:
  5. name: samplepod
  6. annotations:
  7. k8s.v1.cni.cncf.io/networks: macvlan-conf
  8. spec:
  9. containers:
  10. - name: samplepod
  11. command: ["/bin/bash", "-c", "sleep 2000000000000"]
  12. image: dougbtv/centos-network
  13. EOF

You may now inspect the pod and see that there is an additional interface configured:

  1. kubectl exec -it samplepod -- ip a

For more details on how to use Multus, please visit https://github.com/intel/multus-cni