{"id":13839314,"url":"https://github.com/k8snetworkplumbingwg/bond-cni","last_synced_at":"2025-06-18T16:40:27.733Z","repository":{"id":38257272,"uuid":"114366881","full_name":"k8snetworkplumbingwg/bond-cni","owner":"k8snetworkplumbingwg","description":"Bond-cni is for fail-over and high availability of networking in cloudnative orchestration","archived":false,"fork":false,"pushed_at":"2024-08-01T10:24:41.000Z","size":6148,"stargazers_count":61,"open_issues_count":3,"forks_count":26,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-04T17:05:41.097Z","etag":null,"topics":["active-backup","alb","bonding-cni","cni","failover","fault-tolerance","high-availability","interface-bonding","link-aggregator","load-balancing","networking","tlb"],"latest_commit_sha":null,"homepage":"https://networkbuilders.intel.com/network-technologies/container-experience-kits","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k8snetworkplumbingwg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-15T12:11:35.000Z","updated_at":"2024-08-04T17:05:45.562Z","dependencies_parsed_at":"2023-10-12T22:03:22.515Z","dependency_job_id":"4c8983e7-9656-459b-805f-689bf3f9be7e","html_url":"https://github.com/k8snetworkplumbingwg/bond-cni","commit_stats":null,"previous_names":["intel-corp/bond-cni","intel/bond-cni"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8snetworkplumbingwg%2Fbond-cni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8snetworkplumbingwg%2Fbond-cni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8snetworkplumbingwg%2Fbond-cni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k8snetworkplumbingwg%2Fbond-cni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k8snetworkplumbingwg","download_url":"https://codeload.github.com/k8snetworkplumbingwg/bond-cni/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225675073,"owners_count":17506273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-backup","alb","bonding-cni","cni","failover","fault-tolerance","high-availability","interface-bonding","link-aggregator","load-balancing","networking","tlb"],"created_at":"2024-08-04T17:00:18.820Z","updated_at":"2024-11-21T04:30:35.280Z","avatar_url":"https://github.com/k8snetworkplumbingwg.png","language":"Go","funding_links":[],"categories":["NetWork"],"sub_categories":[],"readme":"# Bond CNI plugin\n\n[![Coverage Status](https://coveralls.io/repos/github/k8snetworkplumbingwg/bond-cni/badge.svg?branch=master)](https://coveralls.io/github/k8snetworkplumbingwg/bond-cni?branch=master)\n\n- Bonding provides a method for aggregating multiple network interfaces into a single logical \u0026quot;bonded\u0026quot; interface.\n- According to the 802.3ad specification, Linux Bonding drivers provides various flavours of bonded interfaces depending on the mode (bonding policies), such as round robin, active aggregation\n- When Bond CNI is configured as a standalone plugin, interfaces are obtained from the host network namespace. With these physical interfaces a bonded interface is created in the container network namespace.\n- When used with [Multus](https://github.com/intel/multus-cni) users can bond two interfaces that have previously been passed into the container.\n- A major use case for bonding in containers is network redundancy of an application in the case of network device or path failure and unavailability. For more information - refer to [network redundancy using interface bonding](https://www.howtoforge.com/tutorial/how-to-configure-high-availability-and-network-bonding-on-linux/)\n- And for more information on the bonding driver please refer to [kernel doc](https://www.kernel.org/doc/Documentation/networking/bonding.txt)\n\n## Build\n\nIt is recommended that Bond CNI be built with Go 1.12+ with dependencies managed using Go modules.\n\n- Build the source code to binary:\n\n```\nmake build-bin\n```\n\n- Copy the binary to the CNI folder for the testing:\n\n```\ncp ./bin/bond /opt/cni/bin/\n```\n\nThe binary should be placed at /opt/cni/bin on all nodes on which bonding will take place. That is all nodes to which a container with a bonded interface can be deployed.\n\n## Network configuration reference\n\n- name (string, required): the name of the network\n- type (string, required): \u0026quot;bond\u0026quot;\n- miimon (int, required): specifies the arp link monitoring frequency in milliseconds\n- mtu (int, optional): the mtu of the bond. Default is 1500.\n- failOverMac (int, optional): specifies the failOverMac setting for the bond. Should be set to 1 for active-backup bond modes. Default is 0.\n- linksInContainer(boolean, optional): specifies if slave links are in container to start. Default is false i.e. look for interfaces on host before bonding.\n- links (dictionary, required): master interface names\n- ipam (dictionary, required): IPAM configuration to be used for this network\n\n## Usage\n\n### Standalone operation\n\nGiven the following network configuration:\n```json\n# cat \u003e /etc/cni/net.d/00-flannel-bonding.conf \u003c\u003cEOF\n{\n\t\"name\": \"mynet\",\n\t\"type\": \"flannel\",\n\t\"delegate\": {\n\t\t\"type\": \"bond\",\n\t\t\"mode\": \"active-backup\",\n\t\t\"miimon\": \"100\",\n\t\t\"mtu\": 1500,\n                \"failOverMac\": 1,\n\t\t\"links\": [\n            {\n\t\t\t\t\"name\": \"ens3f2\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"ens3f2d1\"\n\t\t\t}\n\t\t]\n\t}\n}\nEOF\n```\nNote: In this example configuration above required \u0026quot;ipam\u0026quot; is provided by flannel plugin implicitly.\n\n## Integration with Multus, SRIOV CNI and SRIOV Device Plugin\n\nUsers can take advantage of [Multus](https://github.com/intel/multus-cni) to enable adding multiple interfaces to a K8s Pod. The [SRIOV CNI](https://github.com/intel/sriov-cni) plugin allows a SRIOV VF (Virtual Function) to be added to a container. Additionally the [SRIOV Device Plugin](https://github.com/intel/sriov-network-device-plugin) allows Kubelet to manage SRIOV virtual functions. This example shows how Bond CNI could be used in conjunction with these plugins to handle more advanced use cases e.g, high performance container networking solution for NFV environment. Specifically the below functionality shows how to set up failover for SR-IOV interfaces in Kubernetes.\nThis configuration is only applicable to SRIOV VFs using the kernel driver. Userspace driver VFs - such as those used in DPDK workloads - can not be bonded with the Bond CNI.\n- [Multus CNI- Multi Network plugin](https://github.com/intel/multus-cni)\n- [SRIOV CNI](https://github.com/intel/sriov-cni)\n- [SRIOV Network Device Plugin](https://github.com/intel/sriov-network-device-plugin)\n\nConfiguration is based on the Multus CRD Network Attachment Definition. Please follow the configuration details in the link: [Usage with Kubernetes CRD based Network Objects](https://github.com/intel/multus-cni/blob/master/doc/configuration.md#configuration-example)\n\nFor more information and advanced use refer to the [Network Custom Resource standard](https://docs.google.com/document/d/1TW3P4c8auWwYy-w_5afIPDcGNLK3LZf0m14943eVfVg/edithttps://docs.google.com/document/d/1Ny03h6IDVy_e_vmElOqR7UdTPAG_RNydhVE1Kx54kFQ/edit#heading=h.hylsbqoj5fxd) for more details.\n\n### Bonded failover for SRIOV Workloads \n\nPrerequisites:\n\n- Multus configured as per the [quick start guide](https://github.com/intel/multus-cni/blob/master/doc/quickstart.md)\n\n- SRIOV CNI and Multus CNI placed in /opt/cni/bin\n\n- SRIOV Device Plugin running as a Daemonset on the cluster\n\nThe SRIOV Device Plugin will need to be configured to ensure the VFs in the pod are from different network cards. This is important because failover requires that the bonded interface still have connection even if one of the slave interfaces goes down. If both virtual functions are from the same root any connection issues on the physical interface and card will be reflected in both VFs at the same time.\n\nAn example SRIOV config - which works on the basis of physical interface names- is:\n\n```\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: sriovdp-config\n  namespace: kube-system\ndata:\n  config.json: |\n    {\n        \"resourceList\": [{\n                \"resourceName\": \"intel_sriov_PF_1\",\n                \"selectors\": {\n                    \"vendors\": [\"8086\"],\n                    \"devices\": [\"154c\", \"10ed\"],\n                    \"drivers\": [\"i40evf\", \"ixgbevf\"],\n                    \"pfNames\": [\"\u003cPF_NAME_2\u003e\"]\n\n                }\n            },\n        {\n                \"resourceName\": \"intel_sriov_PF_2\",\n                \"selectors\": {\n                    \"vendors\": [\"8086\"],\n                    \"devices\": [\"154c\", \"10ed\"],\n                    \"drivers\": [\"i40evf\", \"ixgbevf\"],\n                    \"pfNames\": [\"\u003cPF_NAME_2\u003e\"]\n                }\n            }\n        ]\n    }\n\n```\nIn the above specific PF names will have to be entered - based on available PFs in the cluster - in order to make the selectors pick up the correct VFs. The other selectors in the above configuration are identical.\nNote that SRIOV device plugin only picks up new configuration at startup - so if the daemonset was previously running the pods will have to be killed and redeployed before this is advertised again.\n\n## Steps for deployment\n1) Deploy Network Attach Definiton for SRIOV\n\n```\napiVersion: \"k8s.cni.cncf.io/v1\"\nkind: NetworkAttachmentDefinition\nmetadata:\n  name: sriov-net1\n  annotations:\n    k8s.v1.cni.cncf.io/resourceName: intel.com/intel_sriov_PF_1\nspec:\n  config: '{\n  \"type\": \"sriov\",\n  \"name\": \"sriov-network\",\n  \"spoofchk\":\"off\"\n}'\n```\n\nWe will create a separate - but equivalent except for naming - SRIOV network attach definition. This allows us to keep our definitions seperate for our two Physical Function pools as definited above.\n```\napiVersion: \"k8s.cni.cncf.io/v1\"\nkind: NetworkAttachmentDefinition\nmetadata:\n  name: sriov-net2\n  annotations:\n    k8s.v1.cni.cncf.io/resourceName: intel.com/intel_sriov_PF_2\nspec:\n  config: '{\n  \"type\": \"sriov\",\n  \"name\": \"sriov-network\",\n  \"spoofchk\":\"off\"\n}'\n```\n2) Deploy Network Attach Definition for Bond CNI:\n```\napiVersion: \"k8s.cni.cncf.io/v1\"\nkind: NetworkAttachmentDefinition\nmetadata:\n  name: bond-net1\nspec:\n  config: '{\n  \"type\": \"bond\",\n  \"cniVersion\": \"0.3.1\",\n  \"name\": \"bond-net1\",\n  \"mode\": \"active-backup\",\n  \"failOverMac\": 1,\n  \"linksInContainer\": true,\n  \"miimon\": \"100\",\n  \"mtu\": 1500,\n  \"links\": [\n     {\"name\": \"net1\"},\n     {\"name\": \"net2\"}\n  ],\n  \"ipam\": {\n    \"type\": \"host-local\",\n    \"subnet\": \"10.56.217.0/24\",\n    \"routes\": [{\n      \"dst\": \"0.0.0.0/0\"\n    }],\n    \"gateway\": \"10.56.217.1\"\n  }\n}'\n```\nNote above the `\"linksInContainer\": true` flag. This tells the Bond CNI that the interfaces we're looking for are to be found inside the container. By default it will look for these interfaces on the host which does not work for integration with SRIOV/Multus.\n\n3) Deploy a pod which requests two SRIOV networks, one from each PF, and one bonded network.\n\n```\napiVersion: v1\nkind: Pod\nmetadata:\n  name: test-pod\n  annotations:\n        k8s.v1.cni.cncf.io/networks: '[\n{\"name\": \"sriov-net1\",\n\"interface\": \"net1\"\n},\n{\"name\": \"sriov-net2\",\n\"interface\": \"net2\"\n},\n{\"name\": \"bond-net\",\n\"interface\": \"bond0\"\n}]'\nspec:\n  restartPolicy: Never\n  containers:\n  - name: bond-test\n    image: alpine:latest\n    command:\n      - /bin/sh\n      - \"-c\"\n      - \"sleep 60m\"\n    imagePullPolicy: IfNotPresent\n    resources:\n      requests:\n        intel.com/intel_sriov_PF_1: '1'\n        intel.com/intel_sriov_PF_2: '1'\n      limits:\n        intel.com/intel_sriov_PF_1: '1'\n        intel.com/intel_sriov_PF_2: '1'\n```\n\nThe order in the request annotation `k8s.v1.cni.cncf.io/networks: sriov-net1, sriov-net2, bond-net1` is important as it is the same order in which networks will be added. In the above spec we add one SRIOV network, then we add another identically configured SRIOV network from our second SRIOV VF pool. Multus will give these networks the names net1 and net2 respectively.\n\nNext the bond-net1 network is created - using interfaces net1 and net2. If bond is created before the SRIOV networks the CNI will not be able to find the interfaces in the container.\n\nThe name of each interface can be set manually in the annotation according to the [CRD Spec](https://docs.google.com/document/d/1TW3P4c8auWwYy-w_5afIPDcGNLK3LZf0m14943eVfVg/edithttps://docs.google.com/document/d/1Ny03h6IDVy_e_vmElOqR7UdTPAG_RNydhVE1Kx54kFQ/edit#heading=h.hylsbqoj5fxd). Changing the names applied in the annotation configuration requires matching changes to be made in the bond network attachment definition. \n\nAfter deploying the above pod spec on Kubernetes running the following command:\n\n```kubectl exec -it test-pod -- ip a```\n\nWill result in  output like:\n\n```\n1: lo: \u003cLOOPBACK,UP,LOWER_UP\u003e mtu 65536 qdisc noqueue state UNKNOWN qlen 1000\n    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n    inet 127.0.0.1/8 scope host lo\n       valid_lft forever preferred_lft forever\n3: eth0@if150: \u003cBROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN\u003e mtu 1450 qdisc noqueue state UP \n    link/ether 62:b1:b5:c8:fb:7a brd ff:ff:ff:ff:ff:ff\n    inet 10.244.1.122/24 brd 10.244.1.255 scope global eth0\n       valid_lft forever preferred_lft forever\n4: bond0: \u003cBROADCAST,MULTICAST,UP,LOWER_UP400\u003e mtu 1500 qdisc noqueue state UP qlen 1000\n    link/ether 9e:23:69:42:fb:8a brd ff:ff:ff:ff:ff:ff\n    inet 10.56.217.66/24 scope global bond0\n       valid_lft forever preferred_lft forever\n43: net1: \u003cBROADCAST,MULTICAST,UP,LOWER_UP800\u003e mtu 1500 qdisc mq master bond0 state UP qlen 1000\n    link/ether 9e:23:69:42:fb:8a brd ff:ff:ff:ff:ff:ff\n44: net2: \u003cBROADCAST,MULTICAST,UP,LOWER_UP800\u003e mtu 1500 qdisc mq master bond0 state UP qlen 1000\n    link/ether 9e:23:69:42:fb:8a brd ff:ff:ff:ff:ff:ff\n```\n\nWe have three new interfaces added to our pod - net1 and net2 are SRIOV interfaces while bond0 is the bond over the two of them. Net1 and Net2 don't require IP addresses - and this can be changed in their CRD.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8snetworkplumbingwg%2Fbond-cni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk8snetworkplumbingwg%2Fbond-cni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk8snetworkplumbingwg%2Fbond-cni/lists"}