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.

84 lines
2.5 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/k8snetworkplumbingwg/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. ### Cilium compatibility
  14. If you are using `cilium` as the primary CNI you'll have to set `cilium_cni_exclusive` to `false` to avoid cillium reverting multus config.
  15. ```yml
  16. kube_network_plugin: cilium
  17. kube_network_plugin_multus: true
  18. cilium_cni_exclusive: false
  19. ```
  20. ## Using Multus
  21. 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.
  22. ```ShellSession
  23. cat <<EOF | kubectl create -f -
  24. apiVersion: "k8s.cni.cncf.io/v1"
  25. kind: NetworkAttachmentDefinition
  26. metadata:
  27. name: macvlan-conf
  28. spec:
  29. config: '{
  30. "cniVersion": "0.4.0",
  31. "type": "macvlan",
  32. "master": "eth0",
  33. "mode": "bridge",
  34. "ipam": {
  35. "type": "host-local",
  36. "subnet": "192.168.1.0/24",
  37. "rangeStart": "192.168.1.200",
  38. "rangeEnd": "192.168.1.216",
  39. "routes": [
  40. { "dst": "0.0.0.0/0" }
  41. ],
  42. "gateway": "192.168.1.1"
  43. }
  44. }'
  45. EOF
  46. ```
  47. 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.
  48. ```ShellSession
  49. cat <<EOF | kubectl create -f -
  50. apiVersion: v1
  51. kind: Pod
  52. metadata:
  53. name: samplepod
  54. annotations:
  55. k8s.v1.cni.cncf.io/networks: macvlan-conf
  56. spec:
  57. containers:
  58. - name: samplepod
  59. command: ["/bin/bash", "-c", "sleep 2000000000000"]
  60. image: dougbtv/centos-network
  61. EOF
  62. ```
  63. You may now inspect the pod and see that there is an additional interface configured:
  64. ```ShellSession
  65. kubectl exec -it samplepod -- ip a
  66. ```
  67. For more details on how to use Multus, please visit <https://github.com/k8snetworkplumbingwg/multus-cni>