k8snetworkplumbingwg / multus-cni

A CNI meta-plugin for multi-homed pods in Kubernetes
Apache License 2.0
2.29k stars 575 forks source link

How to use host-device plugin inside microk8s #1209

Closed kouamdo closed 6 months ago

kouamdo commented 6 months ago

Hi , since , i'm trying to make a simple config. so, using this config :

cat <<EOF | kubectl create -f -
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
  name: macvlan-conf-1
spec:
  config: '{
            "cniVersion": "0.3.1",
            "type": "host-device",
            "device": "eth0"
        }'
--- 
apiVersion: v1
kind: Pod
metadata:
  name: pod-case-01
  annotations:
    k8s.v1.cni.cncf.io/networks: macvlan-conf-1
spec:
  containers:
  - name: pod-case-01
    image: docker.io/centos/tools:latest
    command:
    - /sbin/init
EOF

i have getting this error :

Warning FailedCreatePodSandBox 2m17s (x930 over 27m) kubelet (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "ba1cdf53d8de5004b0eb3f22e21c22b9014b563a8d118696fa209d46894e6740": plugin type="multus" name="multus-cni-network" failed (add): [default/pod-case-01/35f7a2f3-e44b-4f49-9d8c-ef3bbb911a91:macvlan-conf-1]: error adding container to network "macvlan-conf-1": failed to move link file exists

image

so i'm using

{
  "cniVersion": "0.3.1",
  "name": "multus-cni-network",
  "type": "multus",
  "capabilities": {
    "portMappings": true,
    "bandwidth": true
  },
  "kubeconfig": "/var/snap/microk8s/current/args/cni-network/multus.d/multus.kubeconfig",
  "delegates": [
    {
      "name": "k8s-pod-network",
      "cniVersion": "0.3.1",
      "plugins": [
        {
          "type": "calico",
          "log_level": "info",
          "log_file_path": "/var/snap/microk8s/common/var/log/calico/cni/cni.log",
          "datastore_type": "kubernetes",
          "nodename": "k8s-ashburn",
          "nodename_file": "/var/snap/microk8s/current/var/lib/calico/nodename",
          "mtu": 0,
          "ipam": {
            "assign_ipv4": "true",
            "type": "calico-ipam"
          },
          "policy": {
            "type": "k8s"
          },
          "kubernetes": {
            "kubeconfig": "/var/snap/microk8s/current/args/cni-network/calico-kubeconfig"
          }
        },
        {
          "type": "portmap",
          "snat": true,
          "capabilities": {
            "portMappings": true
          }
        },
        {
          "type": "bandwidth",
          "capabilities": {
            "bandwidth": true
          }
        }
      ]
    }
  ]
}

so please , where i have mistaken ?

kouamdo commented 6 months ago

Thank you too , ... The issue it was that i could change the interface inside the net-attach-def.

So just to change eth0 by another free interface like esp for exemple