SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
BPF
Turning Linux into a
Microservices-aware
Operating System
About the Speaker
Thomas Graf
● Linux kernel developer for ~15 years working on
networking and security
● Helped write one of the biggest monoliths ever
● Worked on many Linux components over the years (IP,
TCP, routing, netfilter/iptables, tc, Open vSwitch, …)
● Creator of Cilium to leverage BPF in a cloud native and
microservices context
● Co-Founder & CTO of the company building Cilium
2
Agenda
● Evolution of running applications
○ From single task processes to microservices
● Problems of the Linux kernel
○ The kernel
● What is BPF?
○ Turning Linux into a modern, microservices-aware operating system
● Cilium - BPF-based networking security for microservices
○ What is Cilium?
○ Use Cases & Deep Dive
● Q&A
3
Evolution: Running applications
Split the CPU and
memory. Shared
libraries, package
management, Linux
distributions.
4
Virtualization
Microservices
Containers
Multi tasking
Ship the OS together
with application and run
it in a VM for better
resource isolation.
Virtualized hardware
and software defined
infrastructure.
Dark Age:
Single tasking
The simple age. Back to a shared
operating system.
Applications directly
interact with the host
operating system again.
Problems of the
Linux Kernel in the
age of microservices
5
Problem #1: Abstractions
6
ProcessProcess
HW
System Call Interface
IPv4
Netdevice / Drivers
Sockets
Ethernet
TCP
IPv6
Netfilter
UDP Raw
Traffic Shaping
Bridge OVS ..
The Linux kernel is split into layers to
provide strong abstractions.
Pros:
● Strong userspace API compatibility
guarantee. A 20 years old binary still
works.
● Majority of Linux source code is not
hardware specific.
Cons:
● Every layer pays the cost of the
layers above and below.
● Very hard to bypass layers.
Problem #2: Per subsystem APIs
7
ProcessProcess
HW
System Call Interface
IPv4
Netdevice / Drivers
Sockets
Ethernet
TCP
IPv6
Netfilter
UDP Raw
Traffic Shaping
Bridge OVS
iptablesseccomp tcethtool
..
ip
brctl /
ovsctl
tcpdump
8
Problem #3: Development Process
The Good:
● Open and transparent process
● Excellent code quality
● Stability
● Available everywhere
● Almost entirely vendor neutral
The Bad:
● Hard to change
● Shouting is involved (getting better)
● Large and complicated codebase
● Upstreaming code is hard, consensus has to
be found.
● Upstreaming is time consuming
● Depending on the Linux distribution,
merged code can take years to become
generally available
● Everybody maintains forks with 100-1000s
backports
9
Problem #4: What is a container?
What the kernel knows about:
● Processes & thread groups
● Cgroups
○ Limits and accounting of CPU,
memory, network, … Configured by
container runtime.
● Namespaces
○ Isolation of process, CPU, mount,
user, network, IPC, cgroup, UTS
(hostname). Configured by container
○ runtime
● IP addresses & port numbers
○ Configured by container networking
● System calls made & SELinux context
○ Optionally configured by container
runtime
What the kernel does not know:
● Containers or Kubernetes pods
○ There is no container ID in the kernel
● Exposure requirements
○ The kernel no longer knows whether
an application should be exposed
outside of the host or not.
● API calls made between containers/pods
○ Awareness stops at layer 4 (ports).
While SELinux can control IPC, it can’t
control service to service API calls.
● Servicemesh, huh?
What now? Alternatives?
Linus was wrong. The
app should provide its
own OS.
10
Move OS to
Userspace
Rewrite
Everything?Unikernel
We don’t need kernel
mode for most of the
logic. Build on top of a
minimal Linux.
Examples: ClickOS,
MirageOS, Rumprun, ...
Give user
space access
to hardware
Examples: User mode
Linux, gVisor, ...
Expose the hardware
directly to user space.
It will be fine.
Examples: DPDK,
UDMA, ..
Total Estimated Cost
to Develop Linux
(average salary =
$75,662.08/year,
overhead = 2.40).
$1,372,340,206
What is BPF?
Highly efficient sandboxed
virtual machine in the Linux
kernel making the Linux kernel
programmable at native
execution speed.
Jointly maintained by Cilium
and Facebook with
collaborations from Google,
Red Hat, Netflix, Netronome,
and many others.
11
$ clang -target bpf -emit-llvm -S 
32-bit-example.c
$ llc -march=bpf 32-bit-example.ll
$ cat 32-bit-example.s
cal:
r1 = *(u32 *)(r1 + 0)
r2 = *(u32 *)(r2 + 0)
r2 += r1
*(u32 *)(r3 + 0) = r2
exit
The Linux kernel is event driven
12
Process Process
CPU RAM MMU NIC Disk Disk
System Call Interface
USB
Drivers
12M lines of source code
Process Process
System calls
Interrupts
Run BPF program on event
13
Process
NICDisk
Process
BPF
BPF
BPF
IORead
Sendnetwork
packet
connect()
Sockets
TCP/IP
Network Device
BPF
TCP
retrans
BPF
read()
File Descriptor
VFS
Block Device
Attachment points
● Kernel functions (kprobes)
● Userspace functions (uprobe)
● System calls
● Tracepoints
● Network devices (packet level)
● Sockets (data level)
● Network device (DMA level) [XDP]
● ...
Process
BPF Maps
14
BPF
BPF Maps
BPF map use cases:
● Hold program state
● Share state between programs
● Share state with user space
● Export metrics & statistics
● Configure programs
Map types:
● Hash tables
● Arrays
● LRU (Least recently used)
● Ring buffer
● Stack trace
● LPM (Longest prefix match)
BPF Helpers
15
bpf_get_prandom_u32()
BPF
BPF helpers:
● Stable kernel API exposed to BPF
programs to interact with the kernel
● Includes ability to:
○ Get process/cgroup context
○ Manipulate network packets
and forwarding
○ Access BPF maps
○ Access socket data
○ Send metrics to user space
○ ...
bpf_skb_store_bytes()
bpf_redirect()
bpf_get_current_pid_tgid()
bpf_perf_event_output()
BPF Tail Calls
16
BPF
BPF
BPF tail calls:
● Chain logical programs together
● Implement function calls
● Must be within same program type
BPF
BPF
BPF
BPF JIT Compiler
17
JIT Compiler
● Ensures native execution
performance without requiring to
understand CPU
● Compiles BPF bytecode to CPU
architecture specific instruction set
Supported architectures:
● X86_64, arm64, ppc64, s390x, mips64,
sparc64, arm
Byte
code
Byte
code
x86_64
generic
Byte
code
generic
JIT
BPF Contributors
380 Daniel Borkmann (Cilium, Maintainer)
161 Alexei Starovoitov (Facebook, Maintainer)
160 Jakub Kicinski Netronome
110 John Fastabend (Cilium)
96 Yonghong Song (Facebook)
95 Martin KaFai Lau (Facebook)
94 Jesper Dangaard Brouer (Red Hat)
74 Quentin Monnet (Netronome)
45 Roman Gushchin (Facebook)
45 Andrey Ignatov (Facebook)
Top contributors of
the total 186
contributors to BPF
from January 2016 to
November 2018.
18
BPF Use Cases
● L3-L4 Load balancing
● Network security
● Traffic optimization
● Profiling
https://code.fb.com/open-s
ource/linux/
● QoS & Traffic optimization
● Network Security
● Profiling
● Replacing iptables with BPF
(bpfilter)
● NFV & Load balancing (XDP)
● Profiling & Tracing
● Performance
Troubleshooting
● Tracing & Systems Monitoring
● Networking
19
Simple Kprobe Example
20
Example: BPF program using gobpf/bcc:
What is Cilium?
At the foundation of Cilium is the new Linux kernel
technology BPF, which enables the dynamic insertion
of powerful security, visibility, and networking control
logic within Linux itself. Besides providing traditional
network level security, the flexibility of BPF enables
security on API and process level to secure
communication within a container or pod.
Read More
Cilium is open source software for transparently
providing and securing the network and API
connectivity between application services deployed
using Linux container management platforms like
Kubernetes, Docker, and Mesos.
21
Project Goals
22
Approachable BPF
● Make the efficiency and flexibility of BPF
available in an approachable way
● Automate program creation and
management
● Provide an extendable platform
Microservices-aware Linux
● Use the flexibility of BPF to make the Linux
kernel aware of cloud native concepts
such as containers and APIs.
Security
● Use the additional visibility of BPF to
provide security for microservices
including:
○ API awareness
○ Identity based enforcement
○ Process level context enforcement
Performance
● Leverage the execution performance and
JIT compiler to provide a highly efficient
implementation.
Cilium Use Cases
23
Container Networking
● Highly efficient and flexible
networking
● CNI and CMM plugins
● IPv4, IPv6, NAT46, direct routing,
encapsulation
● Multi cluster routing
Service Load balancing:
● Highly scalable L3-L4 load balancing
implementation
● Kubernetes service implementation or
API driven.
Microservices Security
● Identity-based L3-L4 network security
● Accelerated API-aware security via
Envoy (HTTP, gRPC, Kafka, Cassandra,
memcached, ..)
● DNS aware policies
● SSL data visibility via kTLS
Servicemesh acceleration:
● Minimize overhead when injecting
servicemesh sidecar proxies
BPF-based servicemesh
Acceleration
24
Service
Container
Sidecar proxy
Service
Container
Sidecar proxy
How it really looks:
BPF-based servicemesh
Acceleration
25
Accelerate the service to
sidecar communication
~3.5x performance improvement
Other BPF projects
26
Tracing / Profiling:
● BPFTrace - DTrace for Linux (Brendan
Gregg, et al.)
● bpfd - Load BPF programs into entire
clusters (Joel Fernandes, Google)
Frameworks:
● gobpf - Go based framework to write BPF
programs
● BCC - Python framework to write BPF
programs
Load balancing:
● Katran - Source code of Facebook’s
primary L3-L4 LB (Facebook team)
Security:
● Seccomp - Advanced BPF version of
Seccomp (Kernel team)
DDoS mitigation:
● bpftools - DDOS mitigation tool with
iptables like syntax (Cloudflare)
… and many more
Thank you!
Source Code:
https://github.com/cilium/cilium
BPF reference guide:
http://docs.cilium.io/en/stable/bpf/
Twitter:
@ciliumproject
Website:
https://cilium.io/

Weitere ähnliche Inhalte

Was ist angesagt?

Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 

Was ist angesagt? (20)

Cilium - Network security for microservices
Cilium - Network security for microservicesCilium - Network security for microservices
Cilium - Network security for microservices
 
EBPF and Linux Networking
EBPF and Linux NetworkingEBPF and Linux Networking
EBPF and Linux Networking
 
UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of Software
 
BPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveBPF Hardware Offload Deep Dive
BPF Hardware Offload Deep Dive
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
eBPF Basics
eBPF BasicseBPF Basics
eBPF Basics
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
 
Kubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep DiveKubernetes Networking with Cilium - Deep Dive
Kubernetes Networking with Cilium - Deep Dive
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
 
Xdp and ebpf_maps
Xdp and ebpf_mapsXdp and ebpf_maps
Xdp and ebpf_maps
 
Linux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityLinux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network Security
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
Cilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPFCilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPF
 
Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 
Understanding kube proxy in ipvs mode
Understanding kube proxy in ipvs modeUnderstanding kube proxy in ipvs mode
Understanding kube proxy in ipvs mode
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
Access Network Evolution
Access Network Evolution Access Network Evolution
Access Network Evolution
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDK
 
eBPF Workshop
eBPF WorkshopeBPF Workshop
eBPF Workshop
 
BPF - in-kernel virtual machine
BPF - in-kernel virtual machineBPF - in-kernel virtual machine
BPF - in-kernel virtual machine
 

Ähnlich wie BPF & Cilium - Turning Linux into a Microservices-aware Operating System

A Kernel of Truth: Intrusion Detection and Attestation with eBPF
A Kernel of Truth: Intrusion Detection and Attestation with eBPFA Kernel of Truth: Intrusion Detection and Attestation with eBPF
A Kernel of Truth: Intrusion Detection and Attestation with eBPF
oholiab
 
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
DevSecCon
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
Juraj Hantak
 

Ähnlich wie BPF & Cilium - Turning Linux into a Microservices-aware Operating System (20)

Feedback on Big Compute & HPC on Windows Azure
Feedback on Big Compute & HPC on Windows AzureFeedback on Big Compute & HPC on Windows Azure
Feedback on Big Compute & HPC on Windows Azure
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and tools
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storageWebinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
 
A Kernel of Truth: Intrusion Detection and Attestation with eBPF
A Kernel of Truth: Intrusion Detection and Attestation with eBPFA Kernel of Truth: Intrusion Detection and Attestation with eBPF
A Kernel of Truth: Intrusion Detection and Attestation with eBPF
 
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
DevSecCon London 2019: A Kernel of Truth: Intrusion Detection and Attestation...
 
State of ARM-based HPC
State of ARM-based HPCState of ARM-based HPC
State of ARM-based HPC
 
PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...
PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...
PuppetConf 2016: Why Network Automation Matters, and What You Can Do About It...
 
Comparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetesComparison of existing cni plugins for kubernetes
Comparison of existing cni plugins for kubernetes
 
Kernel bug hunting
Kernel bug huntingKernel bug hunting
Kernel bug hunting
 
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
4. CNCF kubernetes Comparison of-existing-cni-plugins-for-kubernetes
 
Using VPP and SRIO-V with Clear Containers
Using VPP and SRIO-V with Clear ContainersUsing VPP and SRIO-V with Clear Containers
Using VPP and SRIO-V with Clear Containers
 
Hackerworkshop exercises
Hackerworkshop exercisesHackerworkshop exercises
Hackerworkshop exercises
 
Making our networking stack truly extensible
Making our networking stack truly extensible Making our networking stack truly extensible
Making our networking stack truly extensible
 
P4_tutorial.pdf
P4_tutorial.pdfP4_tutorial.pdf
P4_tutorial.pdf
 
LinuxKit: the first five months by Justin Cormack & Riyaz Faizullabhoy (Docker)
LinuxKit: the first five months by Justin Cormack & Riyaz Faizullabhoy (Docker)LinuxKit: the first five months by Justin Cormack & Riyaz Faizullabhoy (Docker)
LinuxKit: the first five months by Justin Cormack & Riyaz Faizullabhoy (Docker)
 
HOW Series: Knights Landing
HOW Series: Knights LandingHOW Series: Knights Landing
HOW Series: Knights Landing
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
 
Using eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster HealthUsing eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster Health
 

Mehr von Thomas Graf

SDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center NetworkingSDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center Networking
Thomas Graf
 

Mehr von Thomas Graf (11)

Accelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux KernelAccelerating Envoy and Istio with Cilium and the Linux Kernel
Accelerating Envoy and Istio with Cilium and the Linux Kernel
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
 
Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersCilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 
Cilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPCilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDP
 
LinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSLinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVS
 
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
 
2015 FOSDEM - OVS Stateful Services
2015 FOSDEM - OVS Stateful Services2015 FOSDEM - OVS Stateful Services
2015 FOSDEM - OVS Stateful Services
 
Open vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NATOpen vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NAT
 
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThe Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
 
SDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center NetworkingSDN & NFV Introduction - Open Source Data Center Networking
SDN & NFV Introduction - Open Source Data Center Networking
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
 

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Kürzlich hochgeladen (20)

BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

BPF & Cilium - Turning Linux into a Microservices-aware Operating System

  • 1. BPF Turning Linux into a Microservices-aware Operating System
  • 2. About the Speaker Thomas Graf ● Linux kernel developer for ~15 years working on networking and security ● Helped write one of the biggest monoliths ever ● Worked on many Linux components over the years (IP, TCP, routing, netfilter/iptables, tc, Open vSwitch, …) ● Creator of Cilium to leverage BPF in a cloud native and microservices context ● Co-Founder & CTO of the company building Cilium 2
  • 3. Agenda ● Evolution of running applications ○ From single task processes to microservices ● Problems of the Linux kernel ○ The kernel ● What is BPF? ○ Turning Linux into a modern, microservices-aware operating system ● Cilium - BPF-based networking security for microservices ○ What is Cilium? ○ Use Cases & Deep Dive ● Q&A 3
  • 4. Evolution: Running applications Split the CPU and memory. Shared libraries, package management, Linux distributions. 4 Virtualization Microservices Containers Multi tasking Ship the OS together with application and run it in a VM for better resource isolation. Virtualized hardware and software defined infrastructure. Dark Age: Single tasking The simple age. Back to a shared operating system. Applications directly interact with the host operating system again.
  • 5. Problems of the Linux Kernel in the age of microservices 5
  • 6. Problem #1: Abstractions 6 ProcessProcess HW System Call Interface IPv4 Netdevice / Drivers Sockets Ethernet TCP IPv6 Netfilter UDP Raw Traffic Shaping Bridge OVS .. The Linux kernel is split into layers to provide strong abstractions. Pros: ● Strong userspace API compatibility guarantee. A 20 years old binary still works. ● Majority of Linux source code is not hardware specific. Cons: ● Every layer pays the cost of the layers above and below. ● Very hard to bypass layers.
  • 7. Problem #2: Per subsystem APIs 7 ProcessProcess HW System Call Interface IPv4 Netdevice / Drivers Sockets Ethernet TCP IPv6 Netfilter UDP Raw Traffic Shaping Bridge OVS iptablesseccomp tcethtool .. ip brctl / ovsctl tcpdump
  • 8. 8 Problem #3: Development Process The Good: ● Open and transparent process ● Excellent code quality ● Stability ● Available everywhere ● Almost entirely vendor neutral The Bad: ● Hard to change ● Shouting is involved (getting better) ● Large and complicated codebase ● Upstreaming code is hard, consensus has to be found. ● Upstreaming is time consuming ● Depending on the Linux distribution, merged code can take years to become generally available ● Everybody maintains forks with 100-1000s backports
  • 9. 9 Problem #4: What is a container? What the kernel knows about: ● Processes & thread groups ● Cgroups ○ Limits and accounting of CPU, memory, network, … Configured by container runtime. ● Namespaces ○ Isolation of process, CPU, mount, user, network, IPC, cgroup, UTS (hostname). Configured by container ○ runtime ● IP addresses & port numbers ○ Configured by container networking ● System calls made & SELinux context ○ Optionally configured by container runtime What the kernel does not know: ● Containers or Kubernetes pods ○ There is no container ID in the kernel ● Exposure requirements ○ The kernel no longer knows whether an application should be exposed outside of the host or not. ● API calls made between containers/pods ○ Awareness stops at layer 4 (ports). While SELinux can control IPC, it can’t control service to service API calls. ● Servicemesh, huh?
  • 10. What now? Alternatives? Linus was wrong. The app should provide its own OS. 10 Move OS to Userspace Rewrite Everything?Unikernel We don’t need kernel mode for most of the logic. Build on top of a minimal Linux. Examples: ClickOS, MirageOS, Rumprun, ... Give user space access to hardware Examples: User mode Linux, gVisor, ... Expose the hardware directly to user space. It will be fine. Examples: DPDK, UDMA, .. Total Estimated Cost to Develop Linux (average salary = $75,662.08/year, overhead = 2.40). $1,372,340,206
  • 11. What is BPF? Highly efficient sandboxed virtual machine in the Linux kernel making the Linux kernel programmable at native execution speed. Jointly maintained by Cilium and Facebook with collaborations from Google, Red Hat, Netflix, Netronome, and many others. 11 $ clang -target bpf -emit-llvm -S 32-bit-example.c $ llc -march=bpf 32-bit-example.ll $ cat 32-bit-example.s cal: r1 = *(u32 *)(r1 + 0) r2 = *(u32 *)(r2 + 0) r2 += r1 *(u32 *)(r3 + 0) = r2 exit
  • 12. The Linux kernel is event driven 12 Process Process CPU RAM MMU NIC Disk Disk System Call Interface USB Drivers 12M lines of source code Process Process System calls Interrupts
  • 13. Run BPF program on event 13 Process NICDisk Process BPF BPF BPF IORead Sendnetwork packet connect() Sockets TCP/IP Network Device BPF TCP retrans BPF read() File Descriptor VFS Block Device Attachment points ● Kernel functions (kprobes) ● Userspace functions (uprobe) ● System calls ● Tracepoints ● Network devices (packet level) ● Sockets (data level) ● Network device (DMA level) [XDP] ● ...
  • 14. Process BPF Maps 14 BPF BPF Maps BPF map use cases: ● Hold program state ● Share state between programs ● Share state with user space ● Export metrics & statistics ● Configure programs Map types: ● Hash tables ● Arrays ● LRU (Least recently used) ● Ring buffer ● Stack trace ● LPM (Longest prefix match)
  • 15. BPF Helpers 15 bpf_get_prandom_u32() BPF BPF helpers: ● Stable kernel API exposed to BPF programs to interact with the kernel ● Includes ability to: ○ Get process/cgroup context ○ Manipulate network packets and forwarding ○ Access BPF maps ○ Access socket data ○ Send metrics to user space ○ ... bpf_skb_store_bytes() bpf_redirect() bpf_get_current_pid_tgid() bpf_perf_event_output()
  • 16. BPF Tail Calls 16 BPF BPF BPF tail calls: ● Chain logical programs together ● Implement function calls ● Must be within same program type BPF BPF BPF
  • 17. BPF JIT Compiler 17 JIT Compiler ● Ensures native execution performance without requiring to understand CPU ● Compiles BPF bytecode to CPU architecture specific instruction set Supported architectures: ● X86_64, arm64, ppc64, s390x, mips64, sparc64, arm Byte code Byte code x86_64 generic Byte code generic JIT
  • 18. BPF Contributors 380 Daniel Borkmann (Cilium, Maintainer) 161 Alexei Starovoitov (Facebook, Maintainer) 160 Jakub Kicinski Netronome 110 John Fastabend (Cilium) 96 Yonghong Song (Facebook) 95 Martin KaFai Lau (Facebook) 94 Jesper Dangaard Brouer (Red Hat) 74 Quentin Monnet (Netronome) 45 Roman Gushchin (Facebook) 45 Andrey Ignatov (Facebook) Top contributors of the total 186 contributors to BPF from January 2016 to November 2018. 18
  • 19. BPF Use Cases ● L3-L4 Load balancing ● Network security ● Traffic optimization ● Profiling https://code.fb.com/open-s ource/linux/ ● QoS & Traffic optimization ● Network Security ● Profiling ● Replacing iptables with BPF (bpfilter) ● NFV & Load balancing (XDP) ● Profiling & Tracing ● Performance Troubleshooting ● Tracing & Systems Monitoring ● Networking 19
  • 20. Simple Kprobe Example 20 Example: BPF program using gobpf/bcc:
  • 21. What is Cilium? At the foundation of Cilium is the new Linux kernel technology BPF, which enables the dynamic insertion of powerful security, visibility, and networking control logic within Linux itself. Besides providing traditional network level security, the flexibility of BPF enables security on API and process level to secure communication within a container or pod. Read More Cilium is open source software for transparently providing and securing the network and API connectivity between application services deployed using Linux container management platforms like Kubernetes, Docker, and Mesos. 21
  • 22. Project Goals 22 Approachable BPF ● Make the efficiency and flexibility of BPF available in an approachable way ● Automate program creation and management ● Provide an extendable platform Microservices-aware Linux ● Use the flexibility of BPF to make the Linux kernel aware of cloud native concepts such as containers and APIs. Security ● Use the additional visibility of BPF to provide security for microservices including: ○ API awareness ○ Identity based enforcement ○ Process level context enforcement Performance ● Leverage the execution performance and JIT compiler to provide a highly efficient implementation.
  • 23. Cilium Use Cases 23 Container Networking ● Highly efficient and flexible networking ● CNI and CMM plugins ● IPv4, IPv6, NAT46, direct routing, encapsulation ● Multi cluster routing Service Load balancing: ● Highly scalable L3-L4 load balancing implementation ● Kubernetes service implementation or API driven. Microservices Security ● Identity-based L3-L4 network security ● Accelerated API-aware security via Envoy (HTTP, gRPC, Kafka, Cassandra, memcached, ..) ● DNS aware policies ● SSL data visibility via kTLS Servicemesh acceleration: ● Minimize overhead when injecting servicemesh sidecar proxies
  • 25. BPF-based servicemesh Acceleration 25 Accelerate the service to sidecar communication ~3.5x performance improvement
  • 26. Other BPF projects 26 Tracing / Profiling: ● BPFTrace - DTrace for Linux (Brendan Gregg, et al.) ● bpfd - Load BPF programs into entire clusters (Joel Fernandes, Google) Frameworks: ● gobpf - Go based framework to write BPF programs ● BCC - Python framework to write BPF programs Load balancing: ● Katran - Source code of Facebook’s primary L3-L4 LB (Facebook team) Security: ● Seccomp - Advanced BPF version of Seccomp (Kernel team) DDoS mitigation: ● bpftools - DDOS mitigation tool with iptables like syntax (Cloudflare) … and many more
  • 27. Thank you! Source Code: https://github.com/cilium/cilium BPF reference guide: http://docs.cilium.io/en/stable/bpf/ Twitter: @ciliumproject Website: https://cilium.io/