github.com/baraj55/containernetworking-cni@v0.7.2-0.20200219164625-56ace59a9e7f/README.md (about)

     1  [![Linux Build Status](https://travis-ci.org/containernetworking/cni.svg?branch=master)](https://travis-ci.org/containernetworking/cni)
     2  [![Windows Build Status](https://ci.appveyor.com/api/projects/status/wtrkou8oow7x533e/branch/master?svg=true)](https://ci.appveyor.com/project/cni-bot/cni/branch/master)
     3  [![Coverage Status](https://coveralls.io/repos/github/containernetworking/cni/badge.svg?branch=master)](https://coveralls.io/github/containernetworking/cni?branch=master)
     4  
     5  ![CNI Logo](logo.png)
     6  
     7  ---
     8  
     9  # CNI at KubeCon / CloudNativeCon
    10  
    11  The CNI maintainers are hosting two sessions at KubeCon / CloudNativeCon 2019:
    12  
    13  - [Introduction to CNI](https://kccncna19.sched.com/event/Uaif/introduction-to-cni-the-container-network-interface-project-bryan-boreham-weaveworks-dan-williams-red-hat)
    14  - [CNI deep dive](https://kccncna19.sched.com/event/Uaga/deep-dive-cni-bryan-boreham-weaveworks-dan-williams-red-hat)
    15  
    16  ---
    17  
    18  # CNI Slack
    19  
    20  The CNI slack has been sunsetted - please join us in #cni and #cni-dev on the [CNCF slack](https://slack.cncf.io/)
    21  
    22  
    23  ---
    24  
    25  # CNI - the Container Network Interface
    26  
    27  ## What is CNI?
    28  
    29  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.
    30  CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted.
    31  Because of this focus, CNI has a wide range of support and the specification is simple to implement.
    32  
    33  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.
    34  
    35  The template code makes it straight-forward to create a CNI plugin for an existing container networking project.
    36  CNI also makes a good framework for creating a new container networking project from scratch.
    37  
    38  ## Why develop CNI?
    39  
    40  Application containers on Linux are a rapidly evolving area, and within this area networking is not well addressed as it is highly environment-specific.
    41  We believe that many container runtimes and orchestrators will seek to solve the same problem of making the network layer pluggable.
    42  
    43  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.
    44  
    45  ## Who is using CNI?
    46  ### Container runtimes
    47  - [rkt - container engine](https://coreos.com/blog/rkt-cni-networking.html)
    48  - [Kubernetes - a system to simplify container operations](https://kubernetes.io/docs/admin/network-plugins/)
    49  - [OpenShift - Kubernetes with additional enterprise features](https://github.com/openshift/origin/blob/master/docs/openshift_networking_requirements.md)
    50  - [Cloud Foundry - a platform for cloud applications](https://github.com/cloudfoundry-incubator/cf-networking-release)
    51  - [Apache Mesos - a distributed systems kernel](https://github.com/apache/mesos/blob/master/docs/cni.md)
    52  - [Amazon ECS - a highly scalable, high performance container management service](https://aws.amazon.com/ecs/)
    53  - [Singularity - container platform optimized for HPC, EPC, and AI](https://github.com/sylabs/singularity)
    54  - [OpenSVC - orchestrator for legacy and containerized application stacks](https://docs.opensvc.com/latest/fr/agent.configure.cni.html)
    55  
    56  ### 3rd party plugins
    57  - [Project Calico - a layer 3 virtual network](https://github.com/projectcalico/calico-cni)
    58  - [Weave - a multi-host Docker network](https://github.com/weaveworks/weave)
    59  - [Contiv Networking - policy networking for various use cases](https://github.com/contiv/netplugin)
    60  - [SR-IOV](https://github.com/hustcat/sriov-cni)
    61  - [Cilium - BPF & XDP for containers](https://github.com/cilium/cilium)
    62  - [Infoblox - enterprise IP address management for containers](https://github.com/infobloxopen/cni-infoblox)
    63  - [Multus - a Multi plugin](https://github.com/Intel-Corp/multus-cni)
    64  - [Romana - Layer 3 CNI plugin supporting network policy for Kubernetes](https://github.com/romana/kube)
    65  - [CNI-Genie - generic CNI network plugin](https://github.com/Huawei-PaaS/CNI-Genie)
    66  - [Nuage CNI - Nuage Networks SDN plugin for network policy kubernetes support ](https://github.com/nuagenetworks/nuage-cni)
    67  - [Silk - a CNI plugin designed for Cloud Foundry](https://github.com/cloudfoundry-incubator/silk)
    68  - [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)
    69  - [Vhostuser - a Dataplane network plugin - Supports OVS-DPDK & VPP](https://github.com/intel/vhost-user-net-plugin)
    70  - [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)
    71  - [Bonding CNI - a Link aggregating plugin to address failover and high availability network](https://github.com/Intel-Corp/bond-cni)
    72  - [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)
    73  - [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
    74  - [Knitter - a CNI plugin supporting multiple networking for Kubernetes](https://github.com/ZTE/Knitter)
    75  - [DANM - a CNI-compliant networking solution for TelCo workloads running on Kubernetes](https://github.com/nokia/danm)
    76  - [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)
    77  - [cni-route-override - a meta CNI plugin that override route information](https://github.com/redhat-nfvpe/cni-route-override)
    78  - [Terway - a collection of CNI Plugins based on alibaba cloud VPC/ECS network product](https://github.com/AliyunContainerService/terway)
    79  - [Cisco ACI CNI - for on-prem and cloud container networking with consistent policy and security model.](https://github.com/noironetworks/aci-containers)
    80  - [Kube-OVN - a CNI plugin that bases on OVN/OVS and provides advanced features like subnet, static ip, ACL, QoS, etc.](https://github.com/alauda/kube-ovn)
    81  - [Project Antrea - an Open vSwitch k8s CNI](https://github.com/vmware-tanzu/antrea)
    82  
    83  The CNI team also maintains some [core plugins in a separate repository](https://github.com/containernetworking/plugins).
    84  
    85  
    86  ## Contributing to CNI
    87  
    88  We welcome contributions, including [bug reports](https://github.com/containernetworking/cni/issues), and code and documentation improvements.
    89  If you intend to contribute to code or documentation, please read [CONTRIBUTING.md](CONTRIBUTING.md). Also see the [contact section](#contact) in this README.
    90  
    91  ## How do I use CNI?
    92  
    93  ### Requirements
    94  
    95  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).
    96  
    97  ### Reference Plugins
    98  
    99  The CNI project maintains a set of [reference plugins](https://github.com/containernetworking/plugins) that implement the CNI specification.
   100  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.
   101  
   102  ### Running the plugins
   103  
   104  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.
   105  
   106  **note - priv-net-run.sh depends on `jq`**
   107  
   108  Start out by creating a netconf file to describe a network:
   109  
   110  ```bash
   111  $ mkdir -p /etc/cni/net.d
   112  $ cat >/etc/cni/net.d/10-mynet.conf <<EOF
   113  {
   114  	"cniVersion": "0.2.0",
   115  	"name": "mynet",
   116  	"type": "bridge",
   117  	"bridge": "cni0",
   118  	"isGateway": true,
   119  	"ipMasq": true,
   120  	"ipam": {
   121  		"type": "host-local",
   122  		"subnet": "10.22.0.0/16",
   123  		"routes": [
   124  			{ "dst": "0.0.0.0/0" }
   125  		]
   126  	}
   127  }
   128  EOF
   129  $ cat >/etc/cni/net.d/99-loopback.conf <<EOF
   130  {
   131  	"cniVersion": "0.2.0",
   132  	"name": "lo",
   133  	"type": "loopback"
   134  }
   135  EOF
   136  ```
   137  
   138  The directory `/etc/cni/net.d` is the default location in which the scripts will look for net configurations.
   139  
   140  Next, build the plugins:
   141  
   142  ```bash
   143  $ cd $GOPATH/src/github.com/containernetworking/plugins
   144  $ ./build_linux.sh # or build_windows.sh
   145  ```
   146  
   147  Finally, execute a command (`ifconfig` in this example) in a private network namespace that has joined the `mynet` network:
   148  
   149  ```bash
   150  $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
   151  $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
   152  $ sudo CNI_PATH=$CNI_PATH ./priv-net-run.sh ifconfig
   153  eth0      Link encap:Ethernet  HWaddr f2:c2:6f:54:b8:2b  
   154            inet addr:10.22.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
   155            inet6 addr: fe80::f0c2:6fff:fe54:b82b/64 Scope:Link
   156            UP BROADCAST MULTICAST  MTU:1500  Metric:1
   157            RX packets:1 errors:0 dropped:0 overruns:0 frame:0
   158            TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
   159            collisions:0 txqueuelen:0
   160            RX bytes:90 (90.0 B)  TX bytes:0 (0.0 B)
   161  
   162  lo        Link encap:Local Loopback  
   163            inet addr:127.0.0.1  Mask:255.0.0.0
   164            inet6 addr: ::1/128 Scope:Host
   165            UP LOOPBACK RUNNING  MTU:65536  Metric:1
   166            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   167            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
   168            collisions:0 txqueuelen:0
   169            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
   170  ```
   171  
   172  The environment variable `CNI_PATH` tells the scripts and library where to look for plugin executables.
   173  
   174  ## Running a Docker container with network namespace set up by CNI plugins
   175  
   176  Use the instructions in the previous section to define a netconf and build the plugins.
   177  Next, docker-run.sh script wraps `docker run`, to execute the plugins prior to entering the container:
   178  
   179  ```bash
   180  $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
   181  $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
   182  $ sudo CNI_PATH=$CNI_PATH ./docker-run.sh --rm busybox:latest ifconfig
   183  eth0      Link encap:Ethernet  HWaddr fa:60:70:aa:07:d1  
   184            inet addr:10.22.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
   185            inet6 addr: fe80::f860:70ff:feaa:7d1/64 Scope:Link
   186            UP BROADCAST MULTICAST  MTU:1500  Metric:1
   187            RX packets:1 errors:0 dropped:0 overruns:0 frame:0
   188            TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
   189            collisions:0 txqueuelen:0
   190            RX bytes:90 (90.0 B)  TX bytes:0 (0.0 B)
   191  
   192  lo        Link encap:Local Loopback  
   193            inet addr:127.0.0.1  Mask:255.0.0.0
   194            inet6 addr: ::1/128 Scope:Host
   195            UP LOOPBACK RUNNING  MTU:65536  Metric:1
   196            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   197            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
   198            collisions:0 txqueuelen:0
   199            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
   200  ```
   201  
   202  ## What might CNI do in the future?
   203  
   204  CNI currently covers a wide range of needs for network configuration due to its simple model and API.
   205  However, in the future CNI might want to branch out into other directions:
   206  
   207  - Dynamic updates to existing network configuration
   208  - Dynamic policies for network bandwidth and firewall rules
   209  
   210  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.
   211  
   212  ## Where are the binaries?
   213  
   214  The plugins moved to a separate repo:
   215  https://github.com/containernetworking/plugins, and the releases there
   216  include binaries and checksums.
   217  
   218  Prior to release 0.7.0 the `cni` release also included a `cnitool`
   219  binary; as this is a developer tool we suggest you build it yourself.
   220  
   221  ## Contact
   222  
   223  For any questions about CNI, please reach out on the mailing list:
   224  - Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev)
   225  - IRC: #[containernetworking](irc://irc.freenode.org:6667/#containernetworking) channel on freenode.org
   226  - #cni on the [CNCF slack](https://slack.cncf.io/)
   227