Debian Codegraph @

README.md

raw
1 ![CNI Logo](logo.png)
2
3 ---
4
5 # CNI - the Container Network Interface
6
7 [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2446/badge)](https://bestpractices.coreinfrastructure.org/projects/2446)
8 [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/containernetworking/cni/badge)](https://securityscorecards.dev/viewer/?uri=github.com/containernetworking/cni)
9
10 ## What is CNI?
11
12 CNI (_Container Network Interface_), a [Cloud Native Computing Foundation](https://cncf.io) project, consists of a specification and libraries for writing plugins to configure network interfaces in Linux containers, along with a number of supported plugins.
13 CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted.
14 Because of this focus, CNI has a wide range of support and the specification is simple to implement.
15
16 As well as the [specification](SPEC.md), this repository contains the Go source code of a [library for integrating CNI into applications](libcni) and an [example command-line tool](cnitool) for executing CNI plugins. A [separate repository contains reference plugins](https://github.com/containernetworking/plugins) and a template for making new plugins.
17
18 The template code makes it straight-forward to create a CNI plugin for an existing container networking project.
19 CNI also makes a good framework for creating a new container networking project from scratch.
20
21 Here are the recordings of two sessions that the CNI maintainers hosted at KubeCon/CloudNativeCon 2019:
22
23 - [Introduction to CNI](https://youtu.be/YjjrQiJOyME)
24 - [CNI deep dive](https://youtu.be/zChkx-AB5Xc)
25
26
27 ## Contributing to CNI
28
29 We welcome contributions, including [bug reports](https://github.com/containernetworking/cni/issues), and code and documentation improvements.
30 If you intend to contribute to code or documentation, please read [CONTRIBUTING.md](CONTRIBUTING.md). Also see the [contact section](#contact) in this README.
31
32 The CNI project has a [weekly meeting](https://meet.jit.si/CNIMaintainersMeeting). It takes place Mondays at 11:00 US/Eastern. All are welcome to join.
33
34 ## Why develop CNI?
35
36 Application containers on Linux are a rapidly evolving area, and within this area networking is not well addressed as it is highly environment-specific.
37 We believe that many container runtimes and orchestrators will seek to solve the same problem of making the network layer pluggable.
38
39 To avoid duplication, we think it is prudent to define a common interface between the network plugins and container execution: hence we put forward this specification, along with libraries for Go and a set of plugins.
40
41 ## Who is using CNI?
42 ### Container runtimes
43 - [rkt - container engine](https://coreos.com/blog/rkt-cni-networking.html)
44 - [Kubernetes - a system to simplify container operations](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
45 - [OpenShift - Kubernetes with additional enterprise features](https://github.com/openshift/origin/blob/master/docs/openshift_networking_requirements.md)
46 - [Cloud Foundry - a platform for cloud applications](https://github.com/cloudfoundry-incubator/cf-networking-release)
47 - [Apache Mesos - a distributed systems kernel](https://github.com/apache/mesos/blob/master/docs/cni.md)
48 - [Amazon ECS - a highly scalable, high performance container management service](https://aws.amazon.com/ecs/)
49 - [Singularity - container platform optimized for HPC, EPC, and AI](https://github.com/sylabs/singularity)
50 - [OpenSVC - orchestrator for legacy and containerized application stacks](https://docs.opensvc.com/latest/fr/agent.configure.cni.html)
51
52 ### 3rd party plugins
53 - [Project Calico - a layer 3 virtual network](https://github.com/projectcalico/calico)
54 - [Weave - a multi-host Docker network](https://github.com/weaveworks/weave)
55 - [Contiv Networking - policy networking for various use cases](https://github.com/contiv/netplugin)
56 - [SR-IOV](https://github.com/hustcat/sriov-cni)
57 - [Cilium - BPF & XDP for containers](https://github.com/cilium/cilium)
58 - [Infoblox - enterprise IP address management for containers](https://github.com/infobloxopen/cni-infoblox)
59 - [Multus - a Multi plugin](https://github.com/k8snetworkplumbingwg/multus-cni)
60 - [Romana - Layer 3 CNI plugin supporting network policy for Kubernetes](https://github.com/romana/kube)
61 - [CNI-Genie - generic CNI network plugin](https://github.com/Huawei-PaaS/CNI-Genie)
62 - [Nuage CNI - Nuage Networks SDN plugin for network policy kubernetes support ](https://github.com/nuagenetworks/nuage-cni)
63 - [Silk - a CNI plugin designed for Cloud Foundry](https://github.com/cloudfoundry-incubator/silk)
64 - [Linen - a CNI plugin designed for overlay networks with Open vSwitch and fit in SDN/OpenFlow network environment](https://github.com/John-Lin/linen-cni)
65 - [Vhostuser - a Dataplane network plugin - Supports OVS-DPDK & VPP](https://github.com/intel/vhost-user-net-plugin)
66 - [Amazon ECS CNI Plugins - a collection of CNI Plugins to configure containers with Amazon EC2 elastic network interfaces (ENIs)](https://github.com/aws/amazon-ecs-cni-plugins)
67 - [Bonding CNI - a Link aggregating plugin to address failover and high availability network](https://github.com/Intel-Corp/bond-cni)
68 - [ovn-kubernetes - an container network plugin built on Open vSwitch (OVS) and Open Virtual Networking (OVN) with support for both Linux and Windows](https://github.com/openvswitch/ovn-kubernetes)
69 - [Juniper Contrail](https://www.juniper.net/cloud) / [TungstenFabric](https://tungstenfabric.io) - Provides overlay SDN solution, delivering multicloud networking, hybrid cloud networking, simultaneous overlay-underlay support, network policy enforcement, network isolation, service chaining and flexible load balancing
70 - [Knitter - a CNI plugin supporting multiple networking for Kubernetes](https://github.com/ZTE/Knitter)
71 - [DANM - a CNI-compliant networking solution for TelCo workloads running on Kubernetes](https://github.com/nokia/danm)
72 - [VMware NSX – a CNI plugin that enables automated NSX L2/L3 networking and L4/L7 Load Balancing; network isolation at the pod, node, and cluster level; and zero-trust security policy for your Kubernetes cluster.](https://docs.vmware.com/en/VMware-NSX-T/2.2/com.vmware.nsxt.ncp_kubernetes.doc/GUID-6AFA724E-BB62-4693-B95C-321E8DDEA7E1.html)
73 - [cni-route-override - a meta CNI plugin that override route information](https://github.com/redhat-nfvpe/cni-route-override)
74 - [Terway - a collection of CNI Plugins based on alibaba cloud VPC/ECS network product](https://github.com/AliyunContainerService/terway)
75 - [Cisco ACI CNI - for on-prem and cloud container networking with consistent policy and security model.](https://github.com/noironetworks/aci-containers)
76 - [Kube-OVN - a CNI plugin that bases on OVN/OVS and provides advanced features like subnet, static ip, ACL, QoS, etc.](https://github.com/kubeovn/kube-ovn)
77 - [Project Antrea - an Open vSwitch k8s CNI](https://github.com/vmware-tanzu/antrea)
78 - [OVN4NFV-K8S-Plugin - a OVN based CNI controller plugin to provide cloud native based Service function chaining (SFC), Multiple OVN overlay networking](https://github.com/opnfv/ovn4nfv-k8s-plugin)
79 - [Azure CNI - a CNI plugin that natively extends Azure Virtual Networks to containers](https://github.com/Azure/azure-container-networking)
80 - [Hybridnet - a CNI plugin designed for hybrid clouds which provides both overlay and underlay networking for containers in one or more clusters. Overlay and underlay containers can run on the same node and have cluster-wide bidirectional network connectivity.](https://github.com/alibaba/hybridnet)
81 - [Spiderpool - An IP Address Management (IPAM) CNI plugin of Kubernetes for managing static ip for underlay network](https://github.com/spidernet-io/spiderpool)
82 - [AWS VPC CNI - Networking plugin for pod networking in Kubernetes using Elastic Network Interfaces on AWS](https://github.com/aws/amazon-vpc-cni-k8s)
83
84 The CNI team also maintains some [core plugins in a separate repository](https://github.com/containernetworking/plugins).
85
86
87 ## How do I use CNI?
88
89 ### Requirements
90
91 The CNI spec is language agnostic. To use the Go language libraries in this repository, you'll need a recent version of Go. You can find the Go versions covered by our [automated tests](https://travis-ci.org/containernetworking/cni/builds) in [.travis.yaml](.travis.yml).
92
93 ### Reference Plugins
94
95 The CNI project maintains a set of [reference plugins](https://github.com/containernetworking/plugins) that implement the CNI specification.
96 NOTE: the reference plugins used to live in this repository but have been split out into a [separate repository](https://github.com/containernetworking/plugins) as of May 2017.
97
98 ### Running the plugins
99
100 After building and installing the [reference plugins](https://github.com/containernetworking/plugins), you can use the `priv-net-run.sh` and `docker-run.sh` scripts in the `scripts/` directory to exercise the plugins.
101
102 **note - priv-net-run.sh depends on `jq`**
103
104 Start out by creating a netconf file to describe a network:
105
106 ```bash
107 $ mkdir -p /etc/cni/net.d
108 $ cat >/etc/cni/net.d/10-mynet.conf <<EOF
109 {
110 "cniVersion": "0.2.0",
111 "name": "mynet",
112 "type": "bridge",
113 "bridge": "cni0",
114 "isGateway": true,
115 "ipMasq": true,
116 "ipam": {
117 "type": "host-local",
118 "subnet": "10.22.0.0/16",
119 "routes": [
120 { "dst": "0.0.0.0/0" }
121 ]
122 }
123 }
124 EOF
125 $ cat >/etc/cni/net.d/99-loopback.conf <<EOF
126 {
127 "cniVersion": "0.2.0",
128 "name": "lo",
129 "type": "loopback"
130 }
131 EOF
132 ```
133
134 The directory `/etc/cni/net.d` is the default location in which the scripts will look for net configurations.
135
136 Next, build the plugins:
137
138 ```bash
139 $ cd $GOPATH/src/github.com/containernetworking/plugins
140 $ ./build_linux.sh # or build_windows.sh
141 ```
142
143 Finally, execute a command (`ifconfig` in this example) in a private network namespace that has joined the `mynet` network:
144
145 ```bash
146 $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
147 $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
148 $ sudo CNI_PATH=$CNI_PATH ./priv-net-run.sh ifconfig
149 eth0 Link encap:Ethernet HWaddr f2:c2:6f:54:b8:2b
150 inet addr:10.22.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
151 inet6 addr: fe80::f0c2:6fff:fe54:b82b/64 Scope:Link
152 UP BROADCAST MULTICAST MTU:1500 Metric:1
153 RX packets:1 errors:0 dropped:0 overruns:0 frame:0
154 TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
155 collisions:0 txqueuelen:0
156 RX bytes:90 (90.0 B) TX bytes:0 (0.0 B)
157
158 lo Link encap:Local Loopback
159 inet addr:127.0.0.1 Mask:255.0.0.0
160 inet6 addr: ::1/128 Scope:Host
161 UP LOOPBACK RUNNING MTU:65536 Metric:1
162 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
163 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
164 collisions:0 txqueuelen:0
165 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
166 ```
167
168 The environment variable `CNI_PATH` tells the scripts and library where to look for plugin executables.
169
170 ## Running a Docker container with network namespace set up by CNI plugins
171
172 Use the instructions in the previous section to define a netconf and build the plugins.
173 Next, docker-run.sh script wraps `docker run`, to execute the plugins prior to entering the container:
174
175 ```bash
176 $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
177 $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
178 $ sudo CNI_PATH=$CNI_PATH ./docker-run.sh --rm busybox:latest ifconfig
179 eth0 Link encap:Ethernet HWaddr fa:60:70:aa:07:d1
180 inet addr:10.22.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
181 inet6 addr: fe80::f860:70ff:feaa:7d1/64 Scope:Link
182 UP BROADCAST MULTICAST MTU:1500 Metric:1
183 RX packets:1 errors:0 dropped:0 overruns:0 frame:0
184 TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
185 collisions:0 txqueuelen:0
186 RX bytes:90 (90.0 B) TX bytes:0 (0.0 B)
187
188 lo Link encap:Local Loopback
189 inet addr:127.0.0.1 Mask:255.0.0.0
190 inet6 addr: ::1/128 Scope:Host
191 UP LOOPBACK RUNNING MTU:65536 Metric:1
192 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
193 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
194 collisions:0 txqueuelen:0
195 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
196 ```
197
198 ## What might CNI do in the future?
199
200 CNI currently covers a wide range of needs for network configuration due to its simple model and API.
201 However, in the future CNI might want to branch out into other directions:
202
203 - Dynamic updates to existing network configuration
204 - Dynamic policies for network bandwidth and firewall rules
205
206 If these topics are of interest, please contact the team via the mailing list or IRC and find some like-minded people in the community to put a proposal together.
207
208 ## Where are the binaries?
209
210 The plugins moved to a separate repo:
211 https://github.com/containernetworking/plugins, and the releases there
212 include binaries and checksums.
213
214 Prior to release 0.7.0 the `cni` release also included a `cnitool`
215 binary; as this is a developer tool we suggest you build it yourself.
216
217 ## Contact
218
219 For any questions about CNI, please reach out via:
220 - Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev)
221 - IRC: #[containernetworking](irc://irc.freenode.net:6667/#containernetworking) channel on [freenode.net](https://freenode.net/)
222 - Slack: #cni on the [CNCF slack](https://slack.cncf.io/). NOTE: the previous CNI Slack (containernetworking.slack.com) has been sunsetted.
223
224 ## Security
225
226 If you have a _security_ issue to report, please do so privately to the email addresses listed in the [MAINTAINERS](MAINTAINERS) file.