Cilium

Cilium 是一种网络、可观测性和安全解决方案,采用基于 eBPF 的数据平面。它提供了一个简单扁平的第 3 层网络,能够以本地路由或覆盖模式跨越多个集群。它具有 L7 协议感知功能,可使用与网络寻址分离的基于身份的安全模型在 L3-L7 上执行网络策略。「Cilium is a networking, observability, and security solution with an eBPF-based dataplane. It provides a simple flat Layer 3 network with the ability to span multiple clusters in either a native routing or overlay mode. It is L7-protocol aware and can enforce network policies on L3-L7 using an identity based security model that is decoupled from network addressing.」

Github星跟蹤圖

Cilium是一款开源软件,用于在应用程序工作负载(如应用程序容器或进程)之间提供透明的网络连接保护和负载平衡。Cilium在第3/4层提供传统的网络和安全服务,在第7层保护和安全使用HTTP、gRPC和Kafka等现代应用程序协议。Cilium集成到公共编配框架中,如Kubernetes和Mesos。

一种名为BPF的新Linux内核技术是Cilium的基础。 它支持在各种集成点(例如,网络IO,应用程序套接字和跟踪点)将BPF字节码动态插入Linux内核,以实现安全性、网络和可见性逻辑。 BPF非常高效灵活。 要了解有关BPF的更多信息,请阅读我们广泛的BPF和XDP参考指南中的更多内容。

功能概述

透明地保护和安全API

能够保护现代应用程序协议,如REST/HTTP、gRPC和Kafka。传统防火墙在第3层和第4层运行。在特定端口上运行的协议要么完全受信任,要么完全阻止。 Cilium提供了过滤各个应用程序协议请求的功能,例如:

  • 允许所有使用方法GET和路径/public/.*的HTTP请求。拒绝所有其他请求。
  • 在Kafka主题topic1 和service2 上产生`service1 代码>到 消费topic1 `。拒绝所有其他卡夫卡消息。
  • 允许service1在Kafka主题topic1和service2上生成以在topic1上使用。拒绝所有其他Kafka消息。
  • 要求在所有REST调用中都存在"HTTP标头X-Token:[0-9]+"。

有关支持的协议的最新列表以及如何使用它的示例,请参阅我们的文档中的第7层策略一节。

基于身份确保服务通信的安全服务

现代分布式应用程序依赖于诸如应用程序容器之类的技术来促进部署中的敏捷性并按需扩展。这导致在短时间内启动大量应用容器。典型的容器防火墙通过过滤源IP地址和目标端口来保护工作负载。这个概念要求在集群中的任何位置启动容器时都要操作所有服务器上的防火墙。

为了避免这种限制扩展的情况,Cilium为共享相同安全策略的应用程序容器组分配安全标识。然后,该标识与应用程序容器发出的所有网络数据包相关联,从而允许验证接收节点处的身份。使用键值存储执行安全身份管理。

安全访问外部服务

基于标签的安全性是集群内部访问控制的首选工具。为了保护对外部服务的访问,支持入口和出口的传统基于CIDR的安全策略。这允许限制对应用程序容器的访问以及对特定IP范围的访问。

简单的网络

一个简单的平面第3层网络能够跨越多个集群,连接所有应用程序容器。使用主机范围分配器可以简化IP分配。这意味着每个主机可以在主机之间没有任何协调的情况下分配IP。

支持以下多节点网络模式:

  • 覆盖:基于封装的虚拟网络产生所有主机。目前VXLAN和Geneve已经完成,但可以启用Linux支持的所有封装格式。 何时使用此模式:此模式具有最小的基础架构和集成要求。它适用于几乎所有网络基础设施,因为唯一的要求是主机之间的IP连接,这通常已经给出。
  • 本地路由:使用Linux主机的常规路由表。网络必须能够路由应用程序容器的IP地址。 何时使用此模式:此模式适用于高级用户,需要了解底层网络基础结构。此模式适用于:
    • 本地IPv6网络
    • 与云网络路由器配合使用
    • 如果您已经在运行路由守护进程

负载平衡

应用程序容器之间的流量的分布式负载平衡 EXTErnal服务。负载平衡是使用BPF使用高效实现的 哈希表允许几乎无限的规模和支持直接服务器 如果未在源上执行负载平衡操作,则返回(DSR) 主机。

应用程序容器和外部服务之间的流量的分布式负载平衡。负载平衡是使用BPF实现的,它使用高效的散列表,允许几乎不受限制的扩展,如果负载平衡操作不在源主机上执行,则支持直接服务器返回(DSR)。注意:负载平衡需要启用连接跟踪。这是默认值。

监测和故障排除

获得可见性和解决问题的能力是任何分布式系统运行的基础。虽然我们学会了喜欢tcpdump和ping这样的工具,虽然他们总会在我们心中找到一个特殊的地方,但我们会努力为故障排除提供更好的工具。这包括提供以下工具:

  • 使用元数据进行事件监控:当数据包被丢弃时,该工具不仅仅报告数据包的源IP和目标IP,该工具还提供了许多其他信息中发送方和接收方的完整标签信息。
  • 策略决策追踪:为什么丢弃数据包或拒绝请求。策略跟踪框架允许跟踪运行工作负载和基于任意标签定义的策略决策过程。
  • 通过Prometheus导出指标:通过Prometheus导出关键指标,以便与现有仪表板集成。

集成

入门

什么是eBPF和XDP?

伯克利数据包过滤器(Berkeley Packet Filter,BPF)是最初用于过滤网络数据包的Linux内核字节码解释器,例如,用于tcpdump和套接字过滤器。最近,BPF指令集和周围架构已经通过其他数据结构(如散列表和数组)进行了大量重新设计,以保持状态以及支持数据包重整、转发、封装等的其他操作。此外,LLVM的编译器后端允许程序用C编写并编译成BPF指令。内核验证程序确保BPF程序可以安全运行,并且JIT编译器将BPF字节代码转换为CPU体系结构特定指令,以实现本机执行效率。 BPF程序可以在内核中的各个挂钩点运行,例如传入数据包,传出数据包,系统调用,kprobes,uprobes,tracepoints等。

每个新的Linux版本,BPF都在不断发展并获得更多功能。 Cilium利用BPF执行核心数据路径过滤,修改,监控和重定向,并且需要任何Linux内核版本4.8.0或更高版本(最新的当前稳定Linux内核为4.14.x)中的BPF功能。

许多Linux发行版,包括CoreOS、Debian、Docker的LinuxKit、Fedora、openSUSE和Ubuntu,已经发布了内核版本= 4.8.x。您可以通过运行uname -a来检查Linux内核版本。如果您还没有运行最新的内核,请查看Linux发行版的文档,了解如何运行Linux内核4.9.x或更高版本。

要阅读必要的内核版本以运行BPF运行时,请参阅先决条件部分。

XDP是进一步发展的一步,它支持从网络驱动程序直接访问数据包的DMA缓冲区来运行特定风格的BPF程序。根据定义,这是软件堆栈中可能的最早的点,在这里可以附加程序,以便在Linux内核网络数据路径中使用可编程的高性能数据包处理器。

有关针对开发人员的BPF和XDP的更多信息,请参阅BPF和XDP参考指南

主要指標

概覽
名稱與所有者cilium/cilium
主編程語言Go
編程語言Go (語言數: 11)
平台Linux
許可證Apache License 2.0
所有者活动
創建於2015-12-16 12:33:31
推送於2025-06-08 12:39:47
最后一次提交
發布數743
最新版本名稱1.18.0-pre.3 (發布於 2025-06-03 10:23:42)
第一版名稱v0.8.0 (發布於 )
用户参与
星數21.8k
關注者數311
派生數3.2k
提交數37.7k
已啟用問題?
問題數10832
打開的問題數923
拉請求數24288
打開的拉請求數162
關閉的拉請求數4462
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
<picture>
   <source media="(prefers-color-scheme: light)" srcset="https://cdn.jsdelivr.net/gh/cilium/cilium@main/Documentation/images/logo.png" width="350" alt="Cilium Logo">
   <img src="https://cdn.jsdelivr.net/gh/cilium/cilium@main/Documentation/images/logo-dark.png" width="350" alt="Cilium Logo">
</picture>

CII Best Practices
Go Report Card
CLOMonitor
Artifact Hub
Join the Cilium slack channel
GoDoc
Read the Docs
Apache licensed
BSD licensed
GPL licensed
FOSSA Status
Gateway API Status
Github Codespaces

Cilium is a networking, observability, and security solution with an
eBPF-based dataplane. It provides a simple flat Layer 3 network with the
ability to span multiple clusters in either a native routing or overlay
mode. It is L7-protocol aware and can enforce network policies on L3-L7
using an identity based security model that is decoupled from network
addressing.

Cilium implements distributed load balancing for traffic between pods
and to external services, and is able to fully replace kube-proxy, using
efficient hash tables in eBPF allowing for almost unlimited scale. It
also supports advanced functionality like integrated ingress and egress
gateway, bandwidth management and service mesh, and provides deep
network and security visibility and monitoring.

A new Linux kernel technology called eBPF is at the
foundation of Cilium. It supports dynamic insertion of eBPF bytecode
into the Linux kernel at various integration points such as: network IO,
application sockets, and tracepoints to implement security, networking
and visibility logic. eBPF is highly efficient and flexible. To learn
more about eBPF, visit eBPF.io.

Overview of Cilium features for networking, observability, service mesh, and runtime security

<a href="https://cncf.io/">
   <picture>
      <source media="(prefers-color-scheme: light)" srcset="https://github.com/cncf/artwork/blob/main/other/cncf-member/graduated/color/cncf-graduated-color.svg" />
      <img src="https://github.com/cncf/artwork/blob/main/other/cncf-member/graduated/white/cncf-graduated-white.svg" alt="CNCF Graduated Project" height="80" />
   </picture>
</a>
<a href="https://ebpf.io/">
   <picture>
      <source media="(prefers-color-scheme: light)" srcset=".github/assets/powered-by-ebpf.svg" />
      <img src=".github/assets/powered-by-ebpf_white.svg" alt="Powered by eBPF" height="80" align="right" />
   </picture>
</a>

Stable Releases

The Cilium community maintains minor stable releases for the last three
minor Cilium versions. Older Cilium stable versions from minor releases
prior to that are considered EOL.

For upgrades to new minor releases please consult the Cilium Upgrade
Guide
.

Listed below are the actively maintained release branches along with
their latest patch release, corresponding image pull tags and their
release notes:


v1.17 2025-04-14 quay.io/cilium/cilium:v1.17.3 Release
Notes

v1.16 2025-04-14 quay.io/cilium/cilium:v1.16.9 Release
Notes

v1.15 2025-04-14 quay.io/cilium/cilium:v1.15.16 Release
Notes


Architectures

Cilium images are distributed for AMD64 and AArch64 architectures.

Software Bill of Materials

Starting with Cilium version 1.13.0, all images include a Software Bill
of Materials (SBOM). The SBOM is generated in SPDX
format. More information on this is available on Cilium
SBOM
.

Development

For development and testing purpose, the Cilium community publishes
snapshots, early release candidates (RC) and CI container images build
from the main branch.
These images are not for use in production.

For testing upgrades to new development releases please consult the
latest development build of the Cilium Upgrade
Guide
.

Listed below are branches for testing along with their snapshots or RC
releases, corresponding image pull tags and their release notes where
applicable:


main daily quay.io/cilium/cilium-ci:latest N/A

v1.18.0-pre.2 2025-05-01 quay.io/cilium/cilium:v1.18.0-pre.2 Release
Notes


Functionality Overview

Protect and secure APIs transparently

Ability to secure modern application protocols such as REST/HTTP, gRPC
and Kafka. Traditional firewalls operate at Layer 3 and 4. A protocol
running on a particular port is either completely trusted or blocked
entirely. Cilium provides the ability to filter on individual
application protocol requests such as:

  • Allow all HTTP requests with method GET and path /public/.*.
    Deny all other requests.
  • Allow service1 to produce on Kafka topic topic1 and service2
    to consume on topic1. Reject all other Kafka messages.
  • Require the HTTP header X-Token: [0-9]+ to be present in all REST
    calls.

See the section Layer 7
Policy

in our documentation for the latest list of supported protocols and
examples on how to use it.

Secure service to service communication based on identities

Modern distributed applications rely on technologies such as application
containers to facilitate agility in deployment and scale out on demand.
This results in a large number of application containers being started
in a short period of time. Typical container firewalls secure workloads
by filtering on source IP addresses and destination ports. This concept
requires the firewalls on all servers to be manipulated whenever a
container is started anywhere in the cluster.

In order to avoid this situation which limits scale, Cilium assigns a
security identity to groups of application containers which share
identical security policies. The identity is then associated with all
network packets emitted by the application containers, allowing to
validate the identity at the receiving node. Security identity
management is performed using a key-value store.

Secure access to and from external services

Label based security is the tool of choice for cluster internal access
control. In order to secure access to and from external services,
traditional CIDR based security policies for both ingress and egress are
supported. This allows to limit access to and from application
containers to particular IP ranges.

Simple Networking

A simple flat Layer 3 network with the ability to span multiple clusters
connects all application containers. IP allocation is kept simple by
using host scope allocators. This means that each host can allocate IPs
without any coordination between hosts.

The following multi node networking models are supported:

  • Overlay: Encapsulation-based virtual network spanning all hosts.
    Currently, VXLAN and Geneve are baked in but all encapsulation
    formats supported by Linux can be enabled.

    When to use this mode: This mode has minimal infrastructure and
    integration requirements. It works on almost any network
    infrastructure as the only requirement is IP connectivity between
    hosts which is typically already given.

  • Native Routing: Use of the regular routing table of the Linux
    host. The network is required to be capable to route the IP
    addresses of the application containers.

    When to use this mode: This mode is for advanced users and requires
    some awareness of the underlying networking infrastructure. This
    mode works well with:

    • Native IPv6 networks
    • In conjunction with cloud network routers
    • If you are already running routing daemons

Load Balancing

Cilium implements distributed load balancing for traffic between
application containers and to external services and is able to fully
replace components such as kube-proxy. The load balancing is implemented
in eBPF using efficient hashtables allowing for almost unlimited scale.

For north-south type load balancing, Cilium's eBPF implementation is
optimized for maximum performance, can be attached to XDP (eXpress Data
Path), and supports direct server return (DSR) as well as Maglev
consistent hashing if the load balancing operation is not performed on
the source host.

For east-west type load balancing, Cilium performs efficient
service-to-backend translation right in the Linux kernel's socket layer
(e.g. at TCP connect time) such that per-packet NAT operations overhead
can be avoided in lower layers.

Bandwidth Management

Cilium implements bandwidth management through efficient EDT-based
(Earliest Departure Time) rate-limiting with eBPF for container traffic
that is egressing a node. This allows to significantly reduce
transmission tail latencies for applications and to avoid locking under
multi-queue NICs compared to traditional approaches such as HTB
(Hierarchy Token Bucket) or TBF (Token Bucket Filter) as used in the
bandwidth CNI plugin, for example.

Monitoring and Troubleshooting

The ability to gain visibility and troubleshoot issues is fundamental to
the operation of any distributed system. While we learned to love tools
like tcpdump and ping and while they will always find a special
place in our hearts, we strive to provide better tooling for
troubleshooting. This includes tooling to provide:

  • Event monitoring with metadata: When a packet is dropped, the tool
    doesn't just report the source and destination IP of the packet,
    the tool provides the full label information of both the sender and
    receiver among a lot of other information.
  • Metrics export via Prometheus: Key metrics are exported via
    Prometheus for integration with your existing dashboards.
  • Hubble: An observability
    platform specifically written for Cilium. It provides service
    dependency maps, operational monitoring and alerting, and
    application and security visibility based on flow logs.

Getting Started

Community

Slack

Join the Cilium Slack channel to chat with
Cilium developers and other Cilium users. This is a good place to learn
about Cilium, ask questions, and share your experiences.

Special Interest Groups (SIG)

See Special Interest
groups
for a
list of all SIGs and their meeting times.

Developer meetings

The Cilium developer community hangs out on Zoom to chat. Everybody is
welcome.

eBPF & Cilium Office Hours livestream

We host a weekly community YouTube livestream called
eCHO
which
(very loosely!) stands for eBPF & Cilium Office Hours. Join us live,
catch up with past episodes, or head over to the eCHO
repo
and let us know your ideas for
topics we should cover.

Governance

The Cilium project is governed by a group of Maintainers and
Committers
.
How they are selected and govern is outlined in our governance
document
.

Adopters

A list of adopters of the Cilium project who are deploying it in
production, and of their use cases, can be found in file
USERS.md.

License

The Cilium user space components are licensed under the Apache License,
Version 2.0
. The BPF code templates are dual-licensed under
the General Public License, Version 2.0 (only)
and the 2-Clause BSD License (you can use
the terms of either license, at your option).