containernetworking/cni
GitHub: containernetworking/cni
CNI 是一个云原生基金会项目,为 Linux 容器定义标准化的网络接口规范并提供 Go 实现库,使容器运行时能够以可插拔方式接入各种网络插件。
Stars: 6057 | Forks: 1152

# CNI - the Container Network Interface
[](https://bestpractices.coreinfrastructure.org/projects/2446)
[](https://securityscorecards.dev/viewer/?uri=github.com/containernetworking/cni)
## 什么是 CNI?
CNI(_Container Network Interface_)是一个 [Cloud Native Computing Foundation](https://cncf.io) 项目,它包含一个规范和用于编写插件以配置 Linux 容器中网络接口的库,以及一些受支持的插件。
CNI 仅关注容器的网络连通性,以及在容器被删除时移除已分配的资源。
正是由于这种专注点,CNI 获得了广泛的支持,并且其规范实现起来非常简单。
除了[规范](SPEC.md)之外,这个仓库还包含了用于[将 CNI 集成到应用程序的库](libcni)的 Go 源代码,以及一个用于执行 CNI 插件的[示例命令行工具](cnitool)。一个[单独的仓库包含了参考插件](https://github.com/containernetworking/plugins)以及用于制作新插件的模板。
使用模板代码,为现有的容器网络项目创建 CNI 插件变得非常直接。
CNI 也是一个很好的框架,适合从头开始创建一个新的容器网络项目。
以下是 CNI 维护者在 KubeCon/CloudNativeCon 2019 上主持的两场会议的录像:
- [CNI 简介](https://youtu.be/YjjrQiJOyME)
- [CNI 深入探讨](https://youtu.be/zChkx-AB5Xc)
## 为什么要开发 CNI?
Linux 上的应用程序容器是一个快速发展的领域,而在这个领域中,由于高度依赖特定环境,网络问题的解决并不完善。
我们相信,许多容器运行时和编排器都会寻求解决同一个问题,即使得网络层变得可插拔。
为了避免重复工作,我们认为在网络插件和容器执行之间定义一个标准接口是明智的:因此我们提出了这个规范,同时附带了 Go 的库和一组插件。
## 谁在使用 CNI?
### 容器运行时
- [Kubernetes - 一个简化容器操作的系统](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)
- [OpenShift - 具有额外企业功能的 Kubernetes](https://github.com/openshift/origin/blob/master/docs/openshift_networking_requirements.md)
- [Cloud Foundry - 一个用于云应用程序的平台](https://github.com/cloudfoundry-incubator/cf-networking-release)
- [Apache Mesos - 一个分布式系统内核](https://github.com/apache/mesos/blob/master/docs/cni.md)
- [Amazon ECS - 一个高度可扩展、高性能的容器管理服务](https://aws.amazon.com/ecs/)
- [Singularity - 为 HPC、EPC 和 AI 优化的容器平台](https://github.com/sylabs/singularity)
- [OpenSVC - 用于遗留和容器化应用程序堆栈的编排器](https://docs.opensvc.com/latest/fr/agent.configure.cni.html)
### 第三方 plugins
- [Project Calico - 一个三层虚拟网络](https://github.com/projectcalico/calico)
- [Contiv Networking - 适用于各种用例的策略网络](https://github.com/contiv/netplugin)
- [SR-IOV](https://github.com/hustcat/sriov-cni)
- [Cilium - 用于容器的 eBPF 和 XDP](https://github.com/cilium/cilium)
- [Multus - 一个 Multi 插件](https://github.com/k8snetworkplumbingwg/multus-cni)
- [Romana - 支持 Kubernetes 网络策略的三层 CNI 插件](https://github.com/romana/kube)
- [CNI-Genie - 通用的 CNI 网络插件](https://github.com/Huawei-PaaS/CNI-Genie)
- [Nuage CNI - 为 Kubernetes 网络策略提供支持的 Nuage Networks SDN 插件 ](https://github.com/nuagenetworks/nuage-cni)
- [Linen - 一个专为基于 Open vSwitch 的 overlay 网络设计的 CNI 插件,适用于 SDN/OpenFlow 网络环境](https://github.com/John-Lin/linen-cni)
- [Vhostuser - 一个 Dataplane 网络插件 - 支持 OVS-DPDK 和 VPP](https://github.com/intel/vhost-user-net-plugin)
- [Amazon ECS CNI Plugins - 一组用于配置带有 Amazon EC2 弹性网络接口 (ENI) 的容器的 CNI 插件](https://github.com/aws/amazon-ecs-cni-plugins)
- [Bonding CNI - 一个用于解决故障转移和高可用性网络的链路聚合插件](https://github.com/Intel-Corp/bond-cni)
- [ovn-kubernetes - 一个基于 Open vSwitch (OVS) 和 Open Virtual Networking (OVN) 构建的容器网络插件,同时支持 Linux 和 Windows](https://github.com/openvswitch/ovn-kubernetes)
- [Juniper Contrail](https://www.juniper.net/cloud) / [TungstenFabric](https://tungstenfabric.io) - 提供 overlay SDN 解决方案,提供多云网络、混合云网络、同步 overlay-underlay 支持、网络策略实施、网络隔离、服务链和灵活的负载均衡
- [Knitter - 一个支持 Kubernetes 多网络的 CNI 插件](https://github.com/ZTE/Knitter)
- [DANM - 一个适用于运行在 Kubernetes 上的 TelCo 工作负载的 CNI 兼容网络解决方案](https://github.com/nokia/danm)
- [cni-route-override - 一个覆盖路由信息的 meta CNI 插件](https://github.com/redhat-nfvpe/cni-route-override)
- [Terway - 一组基于阿里云 VPC/ECS 网络产品的 CNI 插件](https://github.com/AliyunContainerService/terway)
- [Cisco ACI CNI - 适用于本地和云容器网络,具有一致策略和安全模型。](https://github.com/noironetworks/aci-containers)
- [Kube-OVN - 一个基于 OVN/OVS 的 CNI 插件,提供子网、静态 IP、ACL、QoS 等高级功能。](https://github.com/kubeovn/kube-ovn)
- [Project Antrea - 一个基于 Open vSwitch 的 k8s CNI](https://github.com/vmware-tanzu/antrea)
- [Azure CNI - 一个将 Azure Virtual Networks 原生扩展到容器的 CNI 插件](https://github.com/Azure/azure-container-networking)
- [Hybridnet - 一个专为混合云设计的 CNI 插件,可为一个或多个集群中的容器同时提供 overlay 和 underlay 网络。Overlay 和 underlay 容器可以在同一节点上运行,并拥有集群范围内的双向网络连接。](https://github.com/alibaba/hybridnet)
- [Spiderpool - Kubernetes 的 IP 地址管理 (IPAM) CNI 插件,用于管理 underlay 网络的静态 IP](https://github.com/spidernet-io/spiderpool)
- [AWS VPC CNI - 使用 AWS 上的 Elastic Network Interfaces 进行 Kubernetes 中 pod 网络连接的网络插件](https://github.com/aws/amazon-vpc-cni-k8s)
CNI 团队还在[单独的仓库中维护了一些核心插件](https://github.com/containernetworking/plugins)。
## 如何使用 CNI?
### 要求
CNI 规范是跨语言的。要使用此仓库中的 Go 语言库,您需要最新版本的 Go。您可以在 [.travis.yaml](.travis.yml) 中找到我们的[自动化测试](https://travis-ci.org/containernetworking/cni/builds)所涵盖的 Go 版本。
### 参考插件
CNI 项目维护着一组实现了 CNI 规范的[参考插件](https://github.com/containernetworking/plugins)。
注意:参考插件曾经存放在此仓库中,但自 2017 年 5 月起已被拆分到一个[单独的仓库](https://github.com/containernetworking/plugins)中。
### 运行插件
在构建并安装了[参考插件](https://github.com/containernetworking/plugins)之后,您可以使用 `scripts/` 目录中的 `priv-net-run.sh` 和 `docker-run.sh` 脚本来测试这些插件。
**注意 - priv-net-run.sh 依赖于 `jq`**
首先,创建一个 netconf 文件来描述网络:
```
$ mkdir -p /etc/cni/net.d
$ cat >/etc/cni/net.d/10-mynet.conf </etc/cni/net.d/99-loopback.conf <
标签:EVTX分析, 日志审计