Member-only story
K8s Network — CNI Introduction
Introduction to K8s container network interface

What is CNI?
CNI stands for “Container Network Interface”, it is a standard, common network interface. CNI is one of the CNCF (Cloud native computing foundation) project, and it consists of a specification and libs for writing plugins to configure container network interfaces.
CNI concerns itself only with network connectivity of containers and removing allocated resources when the container is deleted. Because of this focus, CNI has a wide range of support and the specification is simple to implement.
There is currently no perfect, ultimate, and a universal solution in terms of network for containers. Different users and organizations use different network solutions for various reasons.
At present, there are network solutions such as flannel
, calico
, openvswitch
, weave
, ipvlan
, etc., and there will be other network solutions in the future. These solutions have different interfaces and usage methods, and different container platforms require network functions. If there is no unified standard, there will be a lot of workload and duplication of work. To avoid work duplications, CNI defines a common interface between network plugins and container runtimes.

As you can see from the above diagram, CNI provides a plug-in-oriented networking solution.
Originally CNI was proposed by CoreOS and adopted by projects such as Apache Mesos
, Cloud Foundry
, K8s
, Kurma
and rkt
.
Who is Using CNI?
The following container runtimes and orchestration systems are currently using CNI:

CNI Flow
CNI is used to connect container management systems and network plugins. It provides a network namespace where the container is located, insert the network interface into the network namespace, then do some necessary…