Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
少しわかるCiliumのeBPFプログラム
Search
Tomoya Terashima
February 17, 2024
Programming
2.4k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
少しわかるCiliumのeBPFプログラム
Tomoya Terashima
February 17, 2024
Other Decks in Programming
See All in Programming
SREの越境 / SRE Collaboration
y0hgi
2
300
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
1
410
phperだってパンチカードでコーディングしたい
o0h
PRO
0
250
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
130
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.6k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
5.8k
パーソナライズPodcastを作った話
repunit11
0
130
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
590
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.5k
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
950
Jetpack Compose Mechanisms
skydoves
2
650
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
160
Featured
See All Featured
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
400
Technical Leadership for Architectural Decision Making
baasie
3
600
Documentation Writing (for coders)
carmenintech
77
5.6k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
370
Git: the NoSQL Database
bkeepers
PRO
433
67k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Mind Mapping
helmedeiros
1
400
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
320
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Unsuck your backbone
ammeep
672
58k
Transcript
少しわかるCiliumのeBPFプログラム eBPF & コンテナ情報交換会 @ 福岡 寺嶋 友哉 1
⾃⼰紹介 ▌寺嶋友哉(てらしま ともや) ▌お仕事 n サイボウズのオンプレKubernetesクラスタの開発運⽤ n Network関連のコンポーネントを主に担当 ▌趣味 n
Network関連ソフトウェアの⾃作 n github.com/terassyi n 将棋観戦 2
⽬次 1. ⽬的 2. Ciliumとは 3. サイボウズでのCiliumの活⽤ 4. Ciliumの通信の仕組み 5.
CiliumのeBPFプログラム 6. eBPFプログラムの処理の追い⽅ 7. まとめ 3
⽬的 ▌対象 n Ciliumやネットワーク分野でのeBPFに興味がある⼈ ▌⽬的 n CiliumがどのようにeBPFを活⽤しているかなんとなくわかる n Ciliumの内部構造の雰囲気を掴む 4
Cilium ▌CNIプラグイン ▌eBPFベースの⾼速かつ柔軟なネットワーク機能を提供 n Network Policy n L4LB n kube-proxy
replacement n Service Mesh n etc… 5
サイボウズでのCiliumの活⽤ ▌⾃社開発のCNIプラグインCoilと組み合わせて利⽤ n https://blog.cybozu.io/entry/2020/10/28/194333 ▌Coil n IPAM + 経路広報 ▌Cilium
n Kube-proxy replacement n Network Policy n L4LB 6
サイボウズでのCiliumの活⽤ ▌現在はL4LB機能にパッチを当てて運⽤中 n CNDT 2023で発表 n CiliumにおけるGeneveプロトコルを⽤いたDSRの実装と導⼊ n 発表時は本番適⽤前だったが、現在は本番でも元気に動作中 ▌UpstreamにPullRequestを提出してマージされた
7 ソースコードレベルで調査する事も多い
Ciliumの通信の仕組み ▌Kube-proxy replacement n Kube-proxy(iptables)をeBPFで置き換えて⾼速な通信を実現 8 Replacing iptables with eBPF
in Kubernetes with Cilium
CiliumのeBPFプログラム概要 9 cil_from_container-<devname> はコンテナごとにアタッチされる cil_from(to)_netdev はノードごとにアタッチされる cilium_*デバイスはデフォルトでは現在使⽤さ れない
各プログラムの役割(ホスト側) ▌cil_from_netdev n ノード外部から来たパケットを最初に処理する n NodePort(LoadBalancer)関連の処理 n 関連公式ドキュメント n cilium/bpf/bpf_host.c#cil_from_netdev
▌cil_to_netdev n ノードから外に出るパケットを処理する n NodePort(LoadBalancer)関連の処理 n cilium/bpf/bpf_host.c#cil_to_netdev 10
各プログラムの概要(コンテナ側) ▌cil_from_container n cil_from_netdevからパケットを引き渡されてパケットを処理する n cilium/bpf/bpf_lxc.c#cil_from_container n Service経由の通信のバックエンド選択とDNAT n Connection
Trackingのエントリ管理 n Network Policyの適⽤ n Etc… 11
通信の追い⽅ ▌Hubbleを使って通信を可視化する n クラスタ内にhubble-relayがいれば全てのノードの通信を⾒れる n いなければ各ノードのcilium-agentに乗り込んでコマンド実⾏ 12 NodePort経由でPodに アクセスした時の通信 どのポイントで観測したか
ソースコードを軽くみてみる 13 ① ② ③ エントリーポイント Tail callして別関数へ Hubbleの観測⽤ に情報を記録
Tail call ▌関数呼び出しのように異なるeBPFプログラムに⾶ぶ n 通常の関数呼び出しと異なり呼び出し元に戻ってこない n 命令数制限を緩和する 14 https://ebpf.io/what-is-ebpf/
CiliumのeBPFコードを追っていくコツ ▌Tail call まみれの処理を追う n エディタの定義ジャンプが効かないのでキーワードで検索していく 15
まとめ ▌ホスト側デバイスに2つのeBPFプログラム n cil_to_netdev n cil_from_netdev ▌コンテナ側のデバイスに1つのeBPFプログラム n cil_from_container ▌どの機能がどのプログラムで処理されるかをなんとなくわかると⾯⽩い
▌Tail callが多いので⾶ぶ関数を⽂字列検索で探しながら読む 16
参考資料 ▌Life of a Packet in Cilium: Discovering the Pod-to-Service
Traffic Path and BPF Processing Logics ▌Replacing iptables with eBPF in Kubernetes with Cilium ▌CiliumにおけるGeneveプロトコルを⽤いたDSRの実装と導⼊ 17