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
Amazon VPC CNIに学ぶCNI-LT版
Search
bells17
September 02, 2025
350
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Amazon VPC CNIに学ぶCNI-LT版
https://k8sjp.connpass.com/event/365262/
bells17
September 02, 2025
More Decks by bells17
See All by bells17
Kubernetes祭り #2 OP/ED
bells17
0
92
Kubernetes祭り #1 OP/ED
bells17
0
110
TFLintカスタムプラグインで始める Terraformコード品質管理
bells17
2
1.9k
コードを読んで理解するko build
bells17
1
730
Kubernetes History Inspector(KHI)を触ってみた
bells17
0
620
スリーシェイクにおけるOSSの取り組み
bells17
4
830
コミュニティ紹介: Kubernetes Meetup Novice
bells17
1
410
社内活動の取り組み紹介 ~ スリーシェイクでこんな取り組みしてます ~
bells17
1
940
モダンインフラの基礎を学ぼう!実践コンテナ入門
bells17
2
590
Featured
See All Featured
Making Projects Easy
brettharned
120
6.8k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
YesSQL, Process and Tooling at Scale
rocio
174
15k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
440
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
580
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
250
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
700
Transcript
Amazon VPC CNIに学ぶCNI LT版 Kubernetes Meetup Tokyo # 7 1
( 2 0 2 5 / 0 9 / 0 2 ) LT @bells 1 7
▶ @bells 1 7 ▶ Software Engineer@ 3 -shake inc.
▶ CNCF Ambassadors ▶ Kubernetes Novice Tokyo Organizer ▶ GitHub: @bells 1 7 ▶ @bells 1 7 _
Amazon VPC CNIについて
Amazon VPC CNI ▶ Amazon EKSにサポートされている唯 一 のCNIプラグイン ▶ CNIプラグイン本体+aws-k
8 s-agent(L-IPAMD)+αなどによって構成 ▶ Elastic Network Interface(ENI)をPodに割り当てることでVPC内から Podにリクエストできる構成になっている ▶ Pre fi xモード(pre fi x delegation)により予めNodeに対して /28 ( 1 6 IPアドレス)を割り当てておくことで、 Podに対するIPアドレスの割当を迅速に 行 うことができる ▶ その他様々な設定オプション有り(めっちゃある) 今回の検証バージョンはv 1 . 2 0 . 1 となります
Amazon VPC CNIの構成 画像: https://docs.aws.amazon.com/eks/latest/best-practices/vpc-cni.html より
Amazon VPC CNIの構成(補 足 説明版) 画像: https://docs.aws.amazon.com/eks/latest/best-practices/vpc-cni.html より
アプリケーション構成
Helm Chart構成 下記の2つにより構成 ▶ aws-vpc-cni ▶ cni-metrics-helper cni-metrics-helperだけ独 立 して
デプロイ可能 https://github.com/aws/amazon-vpc-cni-k 8 s/tree/v 1 . 2 0 . 1 /charts より
aws-vpc-cni(Chart) ▶ DaemonSetだけが動いてる ▶ 実 行 イメージ 一 覧: +
aws-vpc-cni-init(init container) + aws-vpc-cni + aws-network-policy-agent(optional) https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /charts/cni-metrics-helper/templates/deployment.yaml より
aws-vpc-cni-init 下記2つを 行 うinit container ▶ https://github.com/ containernetworking/plugins の プラグインバイナリ群を
ホストマシンにインストール ▶ カーネルパラメータを設定 https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /cmd/aws-vpc-cni-init/main.go より
aws-vpc-cni 下記を 行 うアプリケーション ▶ 独 自 CNIプラグインを ホストマシンにインストール ▶
CNI con fi gを 生 成を ホストマシンにインストール ▶ aws-k 8 s-agent(L-IPAMD)の起動 https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /cmd/aws-vpc-cni/main.go より
CNI Con fi g このテンプレートから 生 成される 設定ファイルから下記の4プラグイン が利 用
されていることがわかる ▶ aws-cni(routed-eni-cni-plugin) ▶ egress-cni + host-local ▶ portmap https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /misc/ 1 0 -aws.con fl ist より
aws-k 8 s-agent(L-IPAMD) https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0
. 1 /docs/cni-proposal.md より ▶ 名前の通りホストマシンに割り当てられたPodのためのIPアドレス 管理を 行 っている ▶ AWSのインスタンスメタデータサービス(IMDS)やAPIを通して現状 の割当状況の管理や把握を 行 っている ▶ aws-k 8 s-agent(L-IPAMD)が 行 っているのはあくまでNode(EC 2 インスタンス)に割り当てられたIPアドレスの管理までで、Podへの 割当作業などはCNIプラグインが 行 っている ▶ ただし、CNIプラグインからのIPアドレスを要求などを受けるため のgRPCが起動している
CNI構成
CNI Con fi g(再掲) このテンプレートから 生 成される 設定ファイルから下記の4プラグイン が利 用
されていることがわかる ▶ aws-cni(routed-eni-cni-plugin) ▶ egress-cni + host-local ▶ portmap https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /misc/ 1 0 -aws.con fl ist より
Pod間通信(これをaws-cniで設定する) 画像: https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 .
1 /docs/images/wire-network.png より
Pod間通信のパケットの流れ 画像: https://github.com/aws/amazon-vpc-cni-k 8 s/raw/v 1 . 2 0 .
1 /docs/images/ping.png より
aws-cniはL-IPAMDにgRPC経由でIPアドレスをリクエスト 画像: https://github.com/aws/amazon-vpc-cni-k 8 s/raw/v 1 . 2 0 .
1 /docs/images/ipam.png より
aws-cni(routed-eni-cni-plugin) L-IPAM払い出したIPアドレスを利 用 して下記のような ネットワーク設定を実 行 ▶ PodのMACアドレスを 生 成
▶ vethを設定(+IPアドレスを付与) ▶ static arpを設定 ▶ route tableを設定 ▶ route ruleを設定
ネットワーク設定の流れ https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1
/docs/cni-proposal.md より
Pod内のネットワーク設定 https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1
/docs/cni-proposal.md より
ホストマシンのネットワーク設定 https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1
/docs/cni-proposal.md より
egress-cni 外部ネットワークと通信するためのネットワーク設定を 行 う ▶ IPAMプラグインを実 行 (host-local)してegress 用 IPアドレスを設定
+ host-localは指定のアドレス範囲からアドレスの払い出しを 行 ってくれるCNIプラグイン ▶ vethなどを設定 ▶ snatを設定
外部ネットワークへのリクエストの際のパケットの流れ 画像: https://github.com/aws/amazon-vpc-cni-k 8 s/raw/v 1 . 2 0 .
1 /docs/images/ping 2 external.png より
portmap ▶ Pod の公開ポート(HostPort)をホストのIP:ポート → PodのIP:ポー トに転送する DNAT を設定してくれる ▶
k 8 s pod のhostPort マッピングするために必要らしい
まとめ
今回の感想 ▶ はじめてCNIのアプリケーションコードをちゃんと読んでみたけど、読んでみたらCNIの 「ネットワークわからん感」からくる抵抗感がかなりなくなったので良かった ▶ CNIプラグインの実 行 のされ 方 や、CNIプラグインと連携するコンポーネントの実装例とし
てかなり勉強になった ▶ 今回 生 成AIを多少駆使しながら読んでみたけど、 生 成AIに説明されてわかるのと実際に 自 分でも読むことで、点と点がつながって理解できるのとでは天と地の差があると思ったの で今回みたいなコード読みみたいのはこれからもやっていって良さそうだなと思った
参考リンク ・ 画像など引 用 元 一 覧 ▶ https://github.com/aws/amazon-vpc-cni-k 8
s/tree/v 1 . 2 0 . 1 ▶ https://github.com/aws/aws-network-policy-agent/tree/v 1 . 2 . 4 ▶ https://github.com/aws/amazon-vpc-resource-controller-k 8 s/tree/v 1 . 7 . 1 0 ▶ https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /docs/cni-proposal.md ▶ https://github.com/aws/amazon-vpc-cni-k 8 s/blob/v 1 . 2 0 . 1 /misc/ 1 0 -aws.con fl ist ▶ https://docs.aws.amazon.com/eks/latest/best-practices/vpc-cni.html ▶ https://docs.aws.amazon.com/eks/latest/best-practices/pre fi x-mode-linux.html ▶ https://docs.aws.amazon.com/ja_jp/eks/latest/userguide/cni-custom-network-tutorial.html ▶ http://docs.aws.amazon.com/eks/latest/userguide/security-groups-pods-deployment.html ▶ https://simyung.github.io/aws-eks-best-practices/networking/custom-networking/ ▶ https://github.com/containernetworking/plugins ▶ https://github.com/cncf/artwork/blob/main/projects/cni/stacked/color/cni-stacked-color.png ▶ https://github.com/cncf/artwork/blob/main/projects/cni/icon/color/cni-icon-color.png ▶ https://about.x.com/ja/who-we-are/brand-toolkit
Thanks / Question? ▶ @bells 1 7 ▶ zenn: https://zenn.dev/bells
1 7 /scraps/ 9 1 7 1 2 3 fda 6 8 3 4 d 本 日 の調査内容ベース ▶ Slide: https://speakerdeck.com/bells 1 7 ▶ @bells 1 7 _