Skip to content

Instantly share code, notes, and snippets.

Last active October 30, 2023 14:08
  • Star 22 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Multus CNI with k3s and RKE

Using Multus CNI in K3S

By default, K3S will run with flannel as the CNI and use custom directories to store CNI plugin binaries and config files(You can inspect the kubelet args K3S uses via journalctl -u k3s|grep cni-conf-dir). So you need to configure that properly When deploying Multus CNI.

For example given the official Multus manifests in, the following changes are needed:

  - name: cni
      path: /var/lib/rancher/k3s/agent/etc/cni/net.d
  - name: cnibin
      path: /var/lib/rancher/k3s/data/<replace-with-your-hash>/bin
  - name: kube-multus
    image: nfvpe/multus:v3.4.1
    command: ["/"]
      - "--multus-conf-file=auto"
      - "--cni-version=0.3.1"
      # Add the following arg
      - "--multus-kubeconfig-file-host=/var/lib/rancher/k3s/agent/etc/cni/net.d/multus.d/multus.kubeconfig"

Once Multus CNI is deployed properly it works as normal in K3S.

Copy link

shpwrck commented Jun 8, 2021

I believe you can replace <replace-with-your-hash> with current to simplify this.

Copy link

MaxThom commented Sep 2, 2021

Hey, Ive been able to install MultusCNI with your solution and use macvlan. I have a net-attach with the spec inside. I've been trying to use the NetworkAttachmentDefinition with CNI config file instead of the spec inside the yaml file and I cant make it work. I keep getting this error:

Multu ││ s: [max-dev/mc-file2]: error loading k8s delegates k8s args: TryLoadPodDelegates: error in getting k8s network for p ││ od: GetNetworkDelegates: failed getting the delegate: GetCNIConfig: err in GetCNIConfigFromFile: No networks found in /etc/cni/multus/net.d                     

Any idea on how to solve this? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment