Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kubeshark で Kubernetes の Traffic を眺めてみよう/Let's ...
Search
kota2and3kan
December 11, 2024
Technology
940
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kubeshark で Kubernetes の Traffic を眺めてみよう/Let's Look at k8s Traffic with Kubeshark
kota2and3kan
December 11, 2024
More Decks by kota2and3kan
See All by kota2and3kan
Keycloak を使った SSO で CockroachDB にログインする / CockroachDB SSO with Keycloak
kota2and3kan
0
240
Quarkus で FizzBuzz する CLI を作ってみた / FizzBuzz with Quarkus
kota2and3kan
0
58
CockroachDB Enterprise Features Overview
kota2and3kan
1
280
CockroachDB はどのくらい「しぶとい」のか? / How tough is CockroachDB?
kota2and3kan
21
13k
JRE しか入ってない Pod で Java の heap dump を取りたい / Get heap dump on JRE container
kota2and3kan
2
1.2k
Let's try CockroachDB
kota2and3kan
1
670
分散トランザクション in CockroachDB / Distributed Tx in CockroachDB
kota2and3kan
1
2.2k
Resolving Tx Conflicts in CockroachDB ~Short Version~
kota2and3kan
0
250
Resolving Tx Conflicts in CockroachDB
kota2and3kan
6
1.4k
Other Decks in Technology
See All in Technology
AIエージェントとPhysical AIが拓く製造業の変革(ハノーバーメッセリキャップ)
iotcomjpadmin
0
210
AWS Blocks を触ってみた/first-tach-aws-blocks
fossamagna
2
140
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
200
SRE依存からの脱却 運用を開 発チームへ移す、 フルサイ クル開 発体制の実践
joooee0000
0
120
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
360
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
500
AI時代のエンジニアキャリアについて今一度考える
sakamoto_582
1
1.2k
デジタル・デザイン:次の50年を描く「進化する青写真」
y150saya
0
800
AI Agent SaaS を支える自社仮想化基盤への挑戦と実運用 / ai-agent-saas-virtualization
flatt_security
1
750
From Prompt Engineering to Loop Engineering
shibuiwilliam
1
330
AWS Summit Japan 2026の振り返りと2027へ向けて / AWS Summit Japan 2026 Recap and Prospects for 2027
kaminashi
1
190
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
Featured
See All Featured
Believing is Seeing
oripsolob
1
160
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
190
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
270
Tell your own story through comics
letsgokoyo
1
980
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
170
Optimizing for Happiness
mojombo
378
71k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
380
Automating Front-end Workflow
addyosmani
1370
210k
The Limits of Empathy - UXLibs8
cassininazir
1
390
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
330
Docker and Python
trallard
47
3.9k
Transcript
2024/12/11 Oracle Cloud Hangout Cafe Season 9 #3 Kubeshark で
Kubernetes の Traffic を眺めてみよう #ochacafe
Name: こたつ&&みかん Account: @kota2and3kan Company: Name: Scalar, Inc. Product: -
ScalarDB (Distributed Transaction Manager) - ScalarDL (Byzantine Fault Detection Middleware) Job: [Technical Support, Infra Engineer] Like: DB: [PostgreSQL, CockroachDB] Bouldering: 5Q Dislike: Real Cockroach Who am I.
今日は Kubeshark のお話をします
Kubeshark Overview
Kubeshark Overview • Network Observability for Kubernetes ◦ Kubernetes Cluster
内の Traffic を監視できるツール。 ◦ TCP, UDP, HTTP, DNS, gRPC, Redis, Kafka 等の様々なプロトコルに対 応。 ◦ Kubernetes 用の Wireshark 的なもの。 ◦ Kubernetes の metadata (Pod 名や Namespace 名等) を利用した柔軟な filtering ができる。 • 公式サイト ◦ https://www.kubeshark.co/ • 公式ドキュメント ◦ https://docs.kubeshark.co/en/introduction • GitHub ◦ https://github.com/kubeshark/kubeshark
Kubeshark Overview • いい感じの Dashboard (Web UI) が提供されており、Kubernetes Cluster 内の
Traffic の情報をいい感じに参照できる。
• 4 Node の Kubernetes Cluster までなら Free でつかえる。 ◦
https://www.kubeshark.co/pricing ◦ https://docs.kubeshark.co/en/license Kubeshark Overview
• Sharky というマスコットがいる。かわいい。 ◦ https://docs.kubeshark.co/en/mascot Kubeshark Overview
Install
Install • Install (Kubernetes 上への deploy) 方法は 2つある。 ◦ kubeshark
tap (CLI) ◦ Helm Chart $ kubeshark tap $ helm repo add kubeshark https://helm.kubeshark.co $ helm install kubeshark kubeshark/kubeshark
Install • Deploy するといくつかの Pod が起動する。 $ kubectl get pod
NAME READY STATUS RESTARTS AGE kubeshark-front-75f798fbd-27w4c 1/1 Running 0 70m kubeshark-hub-79b98b497c-cmb8z 1/1 Running 0 70m kubeshark-worker-daemon-set-vfdc8 1/1 Running 0 70m
Demo
Demo • Workload の Sample として以下の 3つを deploy。 ◦ Guestbook
▪ https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook ◦ Bookinfo ▪ https://github.com/digitalocean/kubernetes-sample-apps/tree/master/ bookinfo-example ◦ etcd ▪ https://etcd.io/docs/v3.5/op-guide/kubernetes/
Demo • Guestbook $ kubectl get pod -n guestbook NAME
READY STATUS RESTARTS AGE frontend-6b5f4cf68c-djzqp 1/1 Running 0 13m redis-follower-6d7fccb64f-prmrp 1/1 Running 0 13m redis-follower-6d7fccb64f-x4hdp 1/1 Running 0 13m redis-leader-57f98b4cfd-d66zg 1/1 Running 0 13m
Demo • Bookinfo $ kubectl get pod -n bookinfo NAME
READY STATUS RESTARTS AGE details-v1-848ff745bf-s8zks 1/1 Running 0 11m productpage-v1-fffc79d49-6ccxw 1/1 Running 0 11m ratings-v1-7fcb6784b9-52bkm 1/1 Running 0 11m reviews-v1-59cfbf87cf-r4m78 1/1 Running 0 11m reviews-v2-587ddf67d9-fx9c6 1/1 Running 0 11m reviews-v3-7f67685b4c-d27m9 1/1 Running 0 11m
Demo • etcd $ kubectl get pod -n etcd NAME
READY STATUS RESTARTS AGE etcd-0 1/1 Running 0 43m etcd-1 1/1 Running 0 43m etcd-2 1/1 Running 0 43m
Demo (DNS request / A record)
Demo (DNS response / A record)
Demo (gRPC request / etcd Range API)
Demo (gRPC response / etcd Range API)
Demo (HTTP request / Readiness probe)
Demo (HTTP response / Readiness probe)
Demo (Redis request / GET)
Demo (Redis response / GET)
Demo (Service Map)
Demo (Filtering / Exclude DNS)
Demo (Filtering / “etcd” namespace only)
Demo (Automation / Alert 404 responses) • JavaScript を使って、packet や
request / response の内容に応じた処理を独自 に実装することができる。 • 例えば、以下のような Script を登録すると、HTTP response の Status Code が 404 だった場合に Dashboard 上の表示を「赤」に、それ以外は「緑」にすることが できる。 function onItemQueried(data) { if (data.response.status === 404) return test.fail(data); else return test.pass(data); }
Demo (Automation / Alert 404 responses)
Demo (Automation / Alert 404 responses)
Demo (Automation / Log 404 error to console) • JavaScript
を使って、packet や request / response の内容に応じた処理を独自 に実装することができる。 • 例えば、以下のような Script を登録すると、HTTP response の Status Code が 404 だった場合に、Console に任意の Log を出力することができる。 function onItemCaptured(data) { if (data.response.status === 404) { console.log("404 occurred. Request path:", data.request.path) } }
Demo (Automation / Log 404 error to console)
Demo (Automation / Log 404 error to console)
Demo (Automation / Log 404 error to console) • kubeshark
console コマンドを利用すると、CLI (Termial) 上でも console に出力さ れる Log を確認できる。 $ kubeshark console 2024-12-08T19:26:53+09:00 INF console.go:45 > Starting scripting console ... 2024-12-08T19:26:58+09:00 INF console.go:61 > Connecting to: host=127.0.0.1 url=http://127.0.0.1:8899/api [minikube-1] 404 occurred. Request path: /wrong/path [minikube-1] 404 occurred. Request path: /wrong/path/baz [minikube-1] 404 occurred. Request path: /wrong/path/foo [minikube-1] 404 occurred. Request path: /wrong/path/bar
Other Features
Other Features • JavaScript を使った Automation では、外部のサービスとの連携もできる。 ◦ Prometheus 用の
custom metrics (packet の情報を含む metrics) を export する。 ◦ 特定の条件に合致した request を検知した場合は、その情報を Slack に通知 する。 ◦ 特定の条件に合致した packet を含む packet capture (.pcap ファイル) を S3 や GCS に保存する。 ◦ 特定の条件に合致した packet の情報を Elasticsearch や InfluxDB に送信 する。 ◦ 特定の条件に合致する packet を検出した場合、任意の Webhook を実行す る。 ◦ etc… ◦ https://docs.kubeshark.co/en/automation_introduction
Other Features • TLS で暗号化された Traffic の中身も見れる (らしい / 今回は未検証)。
◦ eBPF を使って以下の処理を hook し、いい感じに処理しているらしい。 ▪ OpenSSL の SSL_read() および SSL_write()。 ▪ Go 言語の crypto/tls.(*Conn).Read および crypto/tls.(*Conn).Write。 ▪ 上記以外の library 等を使って暗号化された packet の内容は参照でき ないのではないかと思われる (未検証)。 ◦ https://docs.kubeshark.co/en/encrypted_traffic
まとめ
まとめ • Kubeshark を使うと Kubernetes Cluster 内の Traffic をいい感じに監視/可視化で きる。
• いい感じの Dashboard があり、視覚的に Kubernetes Cluster 内の Traffic を表 示してくれる。 • マスコットがかわいい。 • JavaScript で独自の処理を実装し、Traffic の監視や他のサービスとの連携ができ る。 • Node 数が 4 までの Kubernetes Cluster であれば Free で使えるので、ちょっとし た検証等には便利だと思われる。 • サメ。
宣伝
Database Engineering Meetup をやってます!!! https://scalar.connpass.com/ 次回は KubeDay Japan Revisit (日本語
recap) です!!!
Thank you!