You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

  1. # Multus
  2. Multus is a meta CNI plugin that provides multiple network interface support to
  3. pods. For each interface, Multus delegates CNI calls to secondary CNI plugins
  4. such as Calico, macvlan, etc.
  5. See [multus documentation](https://github.com/intel/multus-cni).
  6. ## Multus installation
  7. 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,
  8. ```yml
  9. kube_network_plugin: calico
  10. kube_network_plugin_multus: true
  11. ```
  12. will install Multus and Calico and configure Multus to use Calico as the primary network plugin.
  13. ## Using Multus
  14. 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.
  15. ```ShellSession
  16. cat <<EOF | kubectl create -f -
  17. apiVersion: "k8s.cni.cncf.io/v1"
  18. kind: NetworkAttachmentDefinition
  19. metadata:
  20. name: macvlan-conf
  21. spec:
  22. config: '{
  23. "cniVersion": "0.3.0",
  24. "type": "macvlan",
  25. "master": "eth0",
  26. "mode": "bridge",
  27. "ipam": {
  28. "type": "host-local",
  29. "subnet": "192.168.1.0/24",
  30. "rangeStart": "192.168.1.200",
  31. "rangeEnd": "192.168.1.216",
  32. "routes": [
  33. { "dst": "0.0.0.0/0" }
  34. ],
  35. "gateway": "192.168.1.1"
  36. }
  37. }'
  38. EOF
  39. ```
  40. 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.
  41. ```ShellSession
  42. cat <<EOF | kubectl create -f -
  43. apiVersion: v1
  44. kind: Pod
  45. metadata:
  46. name: samplepod
  47. annotations:
  48. k8s.v1.cni.cncf.io/networks: macvlan-conf
  49. spec:
  50. containers:
  51. - name: samplepod
  52. command: ["/bin/bash", "-c", "sleep 2000000000000"]
  53. image: dougbtv/centos-network
  54. EOF
  55. ```
  56. You may now inspect the pod and see that there is an additional interface configured:
  57. ```ShellSession
  58. kubectl exec -it samplepod -- ip a
  59. ```
  60. For more details on how to use Multus, please visit <https://github.com/intel/multus-cni>