github.com/john-lin/cni@v0.6.0-rc1.0.20170712150331-b69e640cc0e2/README.md (about)

     1  [![Build Status](https://travis-ci.org/containernetworking/cni.svg?branch=master)](https://travis-ci.org/containernetworking/cni)
     2  [![Coverage Status](https://coveralls.io/repos/github/containernetworking/cni/badge.svg?branch=master)](https://coveralls.io/github/containernetworking/cni?branch=master)
     3  [![Slack Status](https://cryptic-tundra-43194.herokuapp.com/badge.svg)](https://cryptic-tundra-43194.herokuapp.com/)
     4  
     5  ![CNI Logo](logo.png)
     6  
     7  ---
     8  
     9  # Community Sync Meeting
    10  
    11  There is a community sync meeting for users and developers every 1-2 months. The next meeting will help on a Google Hangout and the link is in the [agenda](https://docs.google.com/document/d/10ECyT2mBGewsJUcmYmS8QNo1AcNgy2ZIe2xS7lShYhE/edit?usp=sharing) (Notes from previous meeting are also in this doc). The next meeting will be held on *Wednesday, June 21th* at *3:00pm UTC* [Add to Calendar]https://www.worldtimebuddy.com/?qm=1&lid=100,5,2643743,5391959&h=100&date=2017-6-21&sln=15-16).
    12  
    13  ---
    14  
    15  # CNI - the Container Network Interface
    16  
    17  ## What is CNI?
    18  
    19  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.
    20  CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted.
    21  Because of this focus, CNI has a wide range of support and the specification is simple to implement.
    22  
    23  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.
    24  
    25  The template code makes it straight-forward to create a CNI plugin for an existing container networking project.
    26  CNI also makes a good framework for creating a new container networking project from scratch.
    27  
    28  ## Why develop CNI?
    29  
    30  Application containers on Linux are a rapidly evolving area, and within this area networking is not well addressed as it is highly environment-specific.
    31  We believe that many container runtimes and orchestrators will seek to solve the same problem of making the network layer pluggable.
    32  
    33  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.
    34  
    35  ## Who is using CNI?
    36  ### Container runtimes
    37  - [rkt - container engine](https://coreos.com/blog/rkt-cni-networking.html)
    38  - [Kurma - container runtime](http://kurma.io/)
    39  - [Kubernetes - a system to simplify container operations](http://kubernetes.io/docs/admin/network-plugins/)
    40  - [OpenShift - Kubernetes with additional enterprise features](https://github.com/openshift/origin/blob/master/docs/openshift_networking_requirements.md)
    41  - [Cloud Foundry - a platform for cloud applications](https://github.com/cloudfoundry-incubator/cf-networking-release)
    42  - [Mesos - a distributed systems kernel](https://github.com/apache/mesos/blob/master/docs/cni.md)
    43  
    44  ### 3rd party plugins
    45  - [Project Calico - a layer 3 virtual network](https://github.com/projectcalico/calico-cni)
    46  - [Weave - a multi-host Docker network](https://github.com/weaveworks/weave)
    47  - [Contiv Networking - policy networking for various use cases](https://github.com/contiv/netplugin)
    48  - [SR-IOV](https://github.com/hustcat/sriov-cni)
    49  - [Cilium - BPF & XDP for containers](https://github.com/cilium/cilium)
    50  - [Infoblox - enterprise IP address management for containers](https://github.com/infobloxopen/cni-infoblox)
    51  - [Multus - a Multi plugin](https://github.com/Intel-Corp/multus-cni)
    52  - [Romana - Layer 3 CNI plugin supporting network policy for Kubernetes](https://github.com/romana/kube)
    53  - [CNI-Genie - generic CNI network plugin](https://github.com/Huawei-PaaS/CNI-Genie)
    54  - [Nuage CNI - Nuage Networks SDN plugin for network policy kubernetes support ](https://github.com/nuagenetworks/nuage-cni)
    55  - [Silk - a CNI plugin designed for Cloud Foundry](https://github.com/cloudfoundry-incubator/silk)
    56  
    57  The CNI team also maintains some [core plugins in a separate repository](https://github.com/containernetworking/plugins).
    58  
    59  
    60  ## Contributing to CNI
    61  
    62  We welcome contributions, including [bug reports](https://github.com/containernetworking/cni/issues), and code and documentation improvements.
    63  If you intend to contribute to code or documentation, please read [CONTRIBUTING.md](CONTRIBUTING.md). Also see the [contact section](#contact) in this README.
    64  
    65  ## How do I use CNI?
    66  
    67  ### Requirements
    68  
    69  The CNI spec is language agnostic.  To use the Go language libraries in this repository, you'll need a recent version of Go.  Our [automated tests](https://travis-ci.org/containernetworking/cni/builds) cover Go versions 1.7 and 1.8.
    70  
    71  ### Reference Plugins
    72  
    73  The CNI project maintains a set of [reference plugins](https://github.com/containernetworking/plugins) that implement the CNI specification.
    74  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.
    75  
    76  ### Running the plugins
    77  
    78  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.
    79  
    80  **note - priv-net-run.sh depends on `jq`**
    81  
    82  Start out by creating a netconf file to describe a network:
    83  
    84  ```bash
    85  $ mkdir -p /etc/cni/net.d
    86  $ cat >/etc/cni/net.d/10-mynet.conf <<EOF
    87  {
    88  	"cniVersion": "0.2.0",
    89  	"name": "mynet",
    90  	"type": "bridge",
    91  	"bridge": "cni0",
    92  	"isGateway": true,
    93  	"ipMasq": true,
    94  	"ipam": {
    95  		"type": "host-local",
    96  		"subnet": "10.22.0.0/16",
    97  		"routes": [
    98  			{ "dst": "0.0.0.0/0" }
    99  		]
   100  	}
   101  }
   102  EOF
   103  $ cat >/etc/cni/net.d/99-loopback.conf <<EOF
   104  {
   105  	"cniVersion": "0.2.0",
   106  	"type": "loopback"
   107  }
   108  EOF
   109  ```
   110  
   111  The directory `/etc/cni/net.d` is the default location in which the scripts will look for net configurations.
   112  
   113  Next, build the plugins:
   114  
   115  ```bash
   116  $ cd $GOPATH/src/github.com/containernetworking/plugins
   117  $ ./build.sh
   118  ```
   119  
   120  Finally, execute a command (`ifconfig` in this example) in a private network namespace that has joined the `mynet` network:
   121  
   122  ```bash
   123  $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
   124  $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
   125  $ sudo CNI_PATH=$CNI_PATH ./priv-net-run.sh ifconfig
   126  eth0      Link encap:Ethernet  HWaddr f2:c2:6f:54:b8:2b  
   127            inet addr:10.22.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
   128            inet6 addr: fe80::f0c2:6fff:fe54:b82b/64 Scope:Link
   129            UP BROADCAST MULTICAST  MTU:1500  Metric:1
   130            RX packets:1 errors:0 dropped:0 overruns:0 frame:0
   131            TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
   132            collisions:0 txqueuelen:0
   133            RX bytes:90 (90.0 B)  TX bytes:0 (0.0 B)
   134  
   135  lo        Link encap:Local Loopback  
   136            inet addr:127.0.0.1  Mask:255.0.0.0
   137            inet6 addr: ::1/128 Scope:Host
   138            UP LOOPBACK RUNNING  MTU:65536  Metric:1
   139            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   140            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
   141            collisions:0 txqueuelen:0
   142            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
   143  ```
   144  
   145  The environment variable `CNI_PATH` tells the scripts and library where to look for plugin executables.
   146  
   147  ## Running a Docker container with network namespace set up by CNI plugins
   148  
   149  Use the instructions in the previous section to define a netconf and build the plugins.
   150  Next, docker-run.sh script wraps `docker run`, to execute the plugins prior to entering the container:
   151  
   152  ```bash
   153  $ CNI_PATH=$GOPATH/src/github.com/containernetworking/plugins/bin
   154  $ cd $GOPATH/src/github.com/containernetworking/cni/scripts
   155  $ sudo CNI_PATH=$CNI_PATH ./docker-run.sh --rm busybox:latest ifconfig
   156  eth0      Link encap:Ethernet  HWaddr fa:60:70:aa:07:d1  
   157            inet addr:10.22.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
   158            inet6 addr: fe80::f860:70ff:feaa:7d1/64 Scope:Link
   159            UP BROADCAST MULTICAST  MTU:1500  Metric:1
   160            RX packets:1 errors:0 dropped:0 overruns:0 frame:0
   161            TX packets:0 errors:0 dropped:1 overruns:0 carrier:0
   162            collisions:0 txqueuelen:0
   163            RX bytes:90 (90.0 B)  TX bytes:0 (0.0 B)
   164  
   165  lo        Link encap:Local Loopback  
   166            inet addr:127.0.0.1  Mask:255.0.0.0
   167            inet6 addr: ::1/128 Scope:Host
   168            UP LOOPBACK RUNNING  MTU:65536  Metric:1
   169            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   170            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
   171            collisions:0 txqueuelen:0
   172            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
   173  ```
   174  
   175  ## What might CNI do in the future?
   176  
   177  CNI currently covers a wide range of needs for network configuration due to it simple model and API.
   178  However, in the future CNI might want to branch out into other directions:
   179  
   180  - Dynamic updates to existing network configuration
   181  - Dynamic policies for network bandwidth and firewall rules
   182  
   183  If these topics of are 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.
   184  
   185  ## Contact
   186  
   187  For any questions about CNI, please reach out on the mailing list:
   188  - Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev)
   189  - IRC: #[containernetworking](irc://irc.freenode.org:6667/#containernetworking) channel on freenode.org
   190  - Slack: [containernetworking.slack.com](https://cryptic-tundra-43194.herokuapp.com)