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.

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