{"id":19364640,"url":"https://github.com/john-lin/linen-cni","last_synced_at":"2025-04-23T14:30:59.301Z","repository":{"id":70854650,"uuid":"96002962","full_name":"John-Lin/linen-cni","owner":"John-Lin","description":"A CNI plugin designed for overlay networks with Open vSwitch","archived":false,"fork":false,"pushed_at":"2017-12-08T14:18:23.000Z","size":1675,"stargazers_count":52,"open_issues_count":0,"forks_count":14,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-06-20T05:22:43.734Z","etag":null,"topics":["cni"],"latest_commit_sha":null,"homepage":"","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/John-Lin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2017-07-02T04:49:16.000Z","updated_at":"2024-01-04T16:31:42.000Z","dependencies_parsed_at":"2024-01-14T04:40:12.622Z","dependency_job_id":"30bddf38-0b9e-4c20-995c-23906d48b1b5","html_url":"https://github.com/John-Lin/linen-cni","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/John-Lin%2Flinen-cni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/John-Lin%2Flinen-cni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/John-Lin%2Flinen-cni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/John-Lin%2Flinen-cni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/John-Lin","download_url":"https://codeload.github.com/John-Lin/linen-cni/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223926658,"owners_count":17226443,"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":["cni"],"created_at":"2024-11-10T07:37:53.954Z","updated_at":"2024-11-10T07:37:54.035Z","avatar_url":"https://github.com/John-Lin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linen CNI plugin\n\nA CNI plugin designed for overlay networks with [Open vSwitch](http://openvswitch.org).\n\n## About Linen CNI plugin\nLinen provides a convenient way to easily setup networking between pods across nodes. To support multi-host overlay networking and large scale isolatio, VxLAN tunnel end point (VTEP) is used instead of GRE. Linen creates an OVS bridge and added as a port to the linux bridge.\n\nThis CNI plugin implementation was inspired by the document from [Kubernetes OVS networking](https://kubernetes.io/docs/admin/ovs-networking/) and designed to meet the requirements of SDN environment.\n\nPlease read [CNI](https://github.com/containernetworking/cni/blob/master/SPEC.md) for more detail on container networking.\n\n## Prerequisite\n```\n$ sudo apt-get install openvswitch-switch\n```\n\n# Should I use this or ovn-kubernetes?\novn-kubernetes provides more advanced features and use vRouter (Layer 3 approach) to achieve multi-host networking. \nIf you're going to create vRouters and vSwitches to build any network topologies you desire, ovn-kubernetes is a complete solution. \n\nThis CNI plugin creates only vSwitches in each node and uses VxLAN for achieving network overlay.\nFor the PODs in cluster are managed by linux bridges and the IP allocation is configured through `IPAM` plugin.\n\n# Kubernetes\n**Kubernetes 1.7+ and CNI 0.6.0 are required**.\n\nLinen CNI is not only a plugin which support for network namespace (e.g., docker, ip-netns), but also a option for Kubernetes cluster networking.\n\n## Usage\n1. Create a Linen CNI configuration list file in the `/etc/cni/net.d/linen.conflist` directories.\n2. Make sure that the `linen`, `bridge` and `host-local` binaries are in the `/opt/cni/bin` directories directories.\n3. (Optional) Create a daemon set to manager ovsdb `kubectl create -f flaxd.yaml`.\n3. Test to create a POD/Deployment.\n\n## Architecture\n\n### Management Workflow\n\n- `flax daemon`: Runs on each host in order to monitor new node join and add it to current overlay network.\n- `linen-cni`: Executed by the container runtime and set up the network stack for containers.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"/images/mgmt-workflow.png\" width=\"541\" /\u003e\n\u003c/p\u003e\n\n### Packet Processing\n\nTo provide overlay network, Linen utilize Open vSwitch to create VxLAN tunneling in the backend.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"/images/ovs-networking.png\" width=\"586\" /\u003e\n\u003c/p\u003e\n\n## Example network configuration\nPlease check example network configuration in the `examples` folder\n\n\n### Network configuration reference\n\nLinen is a chained plugin. It always comes after `bridge` plugin, so configure Linux Bridge is needed.\n\nFor the **Linux Bridge plugin** options\n- `name` (string, required): the name of the network.\n- `type` (string, required): \"bridge\".\n- `bridge` (string, optional): name of the bridge to use/create. Defaults to \"cni0\".\n- `isGateway` (boolean, optional): assign an IP address to the bridge. Defaults to false.\n- `isDefaultGateway` (boolean, optional): Sets isGateway to true and makes the assigned IP the default route. Defaults to false.\n- `forceAddress` (boolean, optional): Indicates if a new IP address should be set if the previous value has been changed. Defaults to false.\n- `ipMasq` (boolean, optional): set up IP Masquerade on the host for traffic originating from this network and destined outside of it. Defaults to false.\n- `mtu` (integer, optional): explicitly set MTU to the specified value. Defaults to the value chosen by the kernel.\n- `hairpinMode` (boolean, optional): set hairpin mode for interfaces on the bridge. Defaults to false.\n- `ipam` (dictionary, required): IPAM configuration to be used for this network.\n- `promiscMode` (boolean, optional): set promiscuous mode on the bridge. Defaults to false.\n\nFor the **Open vSwitch Bridge plugin** options\n- `isMaster`(boolean, optional): sets isMaster to true if the host is the Kubernetes master node in cluster. Defaults to false.\n- `ovsBridge`(string, optional): name of the ovs bridge to use/create.\n- `vtepIPs` (list, optional): list of the VxLAN tunnel end point IP addresses.\n- `controller` (string, optional): sets SDN controller, assigns an IP address, port number like `192.168.100.20:6653`. Controller is not not essential for overlay network. \n\n## Build\nYou may need to build the binary from source. The \"build-essential\" package is required.\n\n```\n$ sudo apt-get install build-essential\n```\n\nExecute `build.sh`\n\n```\n$ ./build.sh\n```\n\nWhen build succeed, binary will be in the `bin` folder.\n\n# Example\nLinen-CNI also provides a vagrantfile to help you setup a demo environment to try Linen-CNI.\n\n## Environment\nYou should install vagrant in your system and make sure everything goes well.\n\n## Setup Linen-CNI\n- Change directory to `Linen-CNI` and type `vagrant up` to init a virtual machine.\n- Use ssh to connect vagrant VM via `vagrant ssh`.\n- Type following commang to build the `linen-cni` binary and move it to CNI directory.\n```\ncd linen-cni\nsh build.sh\ncp bin/linen ../cni/ \n```\n- We need to provide a CNI config for `Linen-CNI`, and you can use build-in config from example directory. Use following command to copy the config to `/root` directory.\n\n```\nsudo cp examples/master.linen.conflist  /root/linen.conflist\n```\n\n## Create NS\nIn this vagrant environment, we don't install docker related services but you can use `namespace(ns)` to test `Linen-CNI`.\nType following command to create a namespace named ns1\n\n```\nsudo ip netns add ns1\n```\n\n## Start CNI\nWe have setup Linen-CNI environement and testing namespace(ns1), we can use the following commands to inform CNI to add a network for the namespace.\n\n```\ncd ~/cni\nsudo CNI_PATH=`pwd` NETCONFPATH=/root ./cnitool \\ add linen-network /var/run/netns/ns1\n```\nand the result looks like below\n```\n{\n    \"cniVersion\": \"0.3.1\",\n    \"interfaces\": [\n        {\n            \"name\": \"veth7df4d2c0\",\n            \"mac\": \"56:b1:e8:32:e4:b7\"\n        },\n        {\n            \"name\": \"eth0\",\n            \"mac\": \"0a:58:0a:f4:01:0a\",\n            \"sandbox\": \"/var/run/netns/ns1\"\n        }\n    ],\n    \"ips\": [\n        {\n            \"version\": \"4\",\n            \"interface\": 2,\n            \"address\": \"10.244.1.10/16\",\n            \"gateway\": \"10.244.1.1\"\n        }\n    ],\n    \"routes\": [\n        {\n            \"dst\": \"0.0.0.0/0\"\n        },\n        {\n            \"dst\": \"0.0.0.0/0\",\n            \"gw\": \"10.244.1.1\"\n        }\n    ],\n    \"dns\": {}\n}\n```\n\nNow, we can use some tools to help us check the current network setting, for example.  \nYou can use `ovs-vsctl show` to show current OVS setting and it looks like: \n\n```\ne6289dc2-a181-4316-b902-a50fc6d854b6\n    Bridge \"br0\"\n        Controller \"tcp:192.168.2.100:6653\"\n        fail_mode: standalone\n        Port \"vxif10_245_2_2\"\n            Interface \"vxif10_245_2_2\"\n                type: vxlan\n                options: {key=flow, remote_ip=\"10.245.2.2\"}\n        Port \"br0\"\n            Interface \"br0\"\n                type: internal\n        Port \"vxif10_245_2_3\"\n            Interface \"vxif10_245_2_3\"\n                type: vxlan\n                options: {key=flow, remote_ip=\"10.245.2.3\"}\n    ovs_version: \"2.5.2\"\n```\nIn this setting, the OVS will try to connect to Openflow controller (it not exist, change to L2 bridge mode) and it also contains three ports, including two vxlan ports.  \n\nBesides, you can use `brctl show` to see that the OVS bridge (br0) has been attached to Linux bridge(kbr).\n\n```\nbridge name     bridge id               STP enabled     interfaces\nkbr0            8000.0a580af40101       no              br0\n                                                        veth7df4d2c0\n```\n\nIf you want to check the namepsace's networking setting, you can use `sudo ip netns exec ns1 ifconfig` to see it's IP config.\n```\nubuntu@dev:~$ sudo ip netns exec ns1 ifconfig\neth0      Link encap:Ethernet  HWaddr 0a:58:0a:f4:01:0a\n          inet addr:10.244.1.10  Bcast:0.0.0.0  Mask:255.255.0.0\n          inet6 addr: fe80::bc15:faff:fe6b:b414/64 Scope:Link\n          UP BROADCAST RUNNING MULTICAST  MTU:1400  Metric:1\n          RX packets:18 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:0\n          RX bytes:1476 (1.4 KB)  TX bytes:828 (828.0 B)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohn-lin%2Flinen-cni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohn-lin%2Flinen-cni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohn-lin%2Flinen-cni/lists"}