Cilium is open source software for providing and transparently securing network connectivity and load balancing between application workloads such as application containers or processes. Cilium operates at Layer 3/4 to provide traditional networking and security services as well as Layer 7 to protect and secure use of modern application protocols such as HTTP, gRPC and Kafka. The foundation of Cilium is the new Linux kernel technology BPF which supports the dynamic insertion of BPF bytecode into the Linux kernel at various integration points. This presentation reveals the secrets of Kubernetes networking and gives you a deep dive into Cilium and why it is awesome!
4. 4
Linux network has many abstraction layers
Application Layer
System Call Interface
Sockets
Protocols
TCP UDP
Traffic Shaping
sk_buff
Network drivers
5. 5
BPF allows to hook into them
Application Layer
System Call Interface
Sockets
Protocols
TCP UDP
Traffic Shaping
sk_buff
Network drivers
XDP – DMA to the NIC
BPF – after kernel parses the packet
BPF – System Call tracing
BPF – sockmap, sockops
10. 10
Cilium as CNI plugin
Node A
Pod A
Cilium + BPF
Node B
Cilium + BPF
Container
eth0
Pod B
Container
eth0
Pod C
Container
eth0
11. 11
Networking modes
Use case:
Cilium handling routing between nodes
Encapsulation
Use case:
Using cloud provider routers, using BGP
routing daemon
Direct routing
Node A
Node B
Node C
VXLAN
VXLAN
VXLAN
Node A
Node B Node C
Cloud or BGP
routing
12. 12
L3 filtering – label based, ingress
Pod
Labels: role=frontend
IP: 10.0.0.1
Pod
Labels: role=frontend
IP: 10.0.0.2
Pod
IP: 10.0.0.5
Pod
Labels: role=backend
IP: 10.0.0.3
Pod
Labels: role=frontend
IP: 10.0.0.4
allow
deny
20. 20
Standalone proxy, L7 filtering
Node A
Pod A
Cilium + BPF
Envoy
Generating BPF programs for
L7 filtering through libcilium.so
Node B
Pod B
Cilium + BPF
Envoy
Generating BPF programs for
L7 filtering through libcilium.so
Generating BPF
programs
for L3/L4 filtering
Generating BPF
programs
for L3/L4 filtering
22. 22
Cluster Mesh
Cluster A Cluster B
Node A
Pod A
Cilium + BPF
Node B
Cilium + BPF
Container
eth0
Pod B
Container
eth0
Pod C
Container
eth0
External etcd
23. 23
Istio without Cilium
Node A
Pod A
App container
Application
socket
Envoy
Socket
eth0
loopback
CNI driver
Node B
Pod B
App container
Application
socket
Envoy
Socket
eth0
loopback
CNI driver
Here packets need to go
through the whole kernel
network abstraction.
Using TCP protocol.
Performance loss.
24. 24
Istio with Cilium and sockmap
Node A
Pod A
App container
Application
socket
Cilium+BPF
Envoy
Socket
eth0
Node B
Pod B
App container
Application
socket
Cilium+BPF
Envoy
Socket
eth0
25. 25
Kubernetes Services
●
Hash table.
BPF, Cilium
●
Linear list.
●
All rules in the chain have to be
replaced as a whole.
Iptables, kube-proxy
Key
Key
Key
Value
Value
Value
Rule 1
Rule 2
Rule n
...
Search O(1)
Insert O(1)
Delete O(1)
Search O(n)
Insert O(1)
Delete O(n)
26. 26
Kubernetes Services – benchmark
1 100 1000 2000 2768
0
100
200
300
400
500
600
700
Cilium (BPF)
kube-proxy (iptables)
Number of services in cluster
usec
30. 30
Why Cilium is awesome?
●
It makes disadvantages of iptables disappear. And always gets the best
from the Linux kernel.
●
Cluster Mesh / multi-cluster.
●
Makes Istio faster.
●
Offers L7 API Aware filtering as a Kubernetes resource.
●
Integrates with the other popular CNI plugins – Calico, Flannel, Weave,
Lyft, AWS CNI.