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
kubectl debugを試してみた / k8snovice8-kubectl-debug
Search
Naoki Oketani
February 08, 2021
Technology
0
2.1k
kubectl debugを試してみた / k8snovice8-kubectl-debug
Kubernetes Novice Tokyo #8
Naoki Oketani
February 08, 2021
Tweet
Share
More Decks by Naoki Oketani
See All by Naoki Oketani
Observe the Conference / observe-the-conference
okepy
0
460
最小権限を目指して / least privilege of service account
okepy
0
1.7k
security-profiles-operatorをさわってみた / try-security-profiles-operator
okepy
0
2.2k
Other Decks in Technology
See All in Technology
Flutterでキャッチしないエラーはどこに行く
taiju59
0
220
会社紹介資料 / Sansan Company Profile
sansan33
PRO
6
380k
Webアプリケーションにオブザーバビリティを実装するRust入門ガイド
nwiizo
6
740
Automating Web Accessibility Testing with AI Agents
maminami373
0
1.2k
現場で効くClaude Code ─ 最新動向と企業導入
takaakikakei
1
210
MCPで変わる Amebaデザインシステム「Spindle」の開発
spindle
PRO
3
3.2k
[ JAWS-UG 東京 CommunityBuilders Night #2 ]SlackとAmazon Q Developerで 運用効率化を模索する
sh_fk2
3
380
「何となくテストする」を卒業するためにプロダクトが動く仕組みを理解しよう
kawabeaver
0
320
なぜテストマネージャの視点が 必要なのか? 〜 一歩先へ進むために 〜
moritamasami
0
210
サラリーマンの小遣いで作るtoCサービス - Cloudflare Workersでスケールする開発戦略
shinaps
2
400
なぜSaaSがMCPサーバーをサービス提供するのか?
sansantech
PRO
8
2.7k
S3アクセス制御の設計ポイント
tommy0124
3
190
Featured
See All Featured
A designer walks into a library…
pauljervisheath
207
24k
Rails Girls Zürich Keynote
gr2m
95
14k
Navigating Team Friction
lara
189
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Fireside Chat
paigeccino
39
3.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
GitHub's CSS Performance
jonrohan
1032
460k
Practical Orchestrator
shlominoach
190
11k
Transcript
Kubernetes Novice Tokyo #8 kubectl debug を試してみた February 9, 2021
Naoki Oketani
$ cat whoami.yaml social: github: oke-py twitter: ngoktanio job: role:
Cloud Native Security Architect keyword: [“NIST SP 800-190”, “Sysdig”]
目次 1. kubectl debugのユースケース 2. kubectl debugの使い方 3. まとめ
目次 1. kubectl debugのユースケース 2. kubectl debugの使い方 3. まとめ
distroless 使ってる?
攻撃ベクトルを小さくする centos distroless App App bash openssl “Minimal images lower
operational burden and reduce attack vectors.” [3][4]
デプロイを高速化する REPOSITORY TAG SIZE alpine latest 5.35MB ubuntu 18.04 56.7MB
centos 7 301MB gcr.io/distroless/base-debian10 latest 16.1MB “Smaller image size reduces resource usage and speeds deployments.” [3][4]
distrolessベースのコンテナを運用していた、ある日のこと
ん、おかしいな。デバッグしよう。
$ kubectl exec -it ephemeral-demo -- sh [2] OCI runtime
exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"sh\": executable file not found in $PATH": unknown あ、”sh”が入っていなくてトラブルシューティングできない・・・ ここで、エフェメラルコンテナとkubectl debugの出番
目次 1. kubectl debugのユースケース 2. kubectl debugの使い方 3. まとめ
エフェメラルコンテナを利用する $ k run demo --image=k8s.gcr.io/pause:3.1 --restart=Never $ k debug
-it demo --image=busybox # ps aux PID USER TIME COMMAND 1 root 0:00 sh 7 root 0:00 ps aux プロセスをみることができない Pod: demo Container pause EphemeralContainer busybox
エフェメラルコンテナを利用する $ k run demo --image=k8s.gcr.io/pause:3.1 --restart=Never $ k debug
-it demo --image=busybox --target=demo # ps aux PID USER TIME COMMAND 1 root 0:00 /pause 8 root 0:00 sh 15 root 0:00 ps aux Pod: demo Container pause EphemeralContainer busybox
Podのコピーを利用する $ k run myapp --image=busybox --restart=Never -- sleep 1d
$ k debug myapp -it --image=ubuntu --share-processes \ --copy-to=myapp-debug $ k get pod NAME READY ... myapp 1/1 myapp-debug 2/2 Pod: myapp-debug Container busybox Container ubuntu Pod: myapp Container busybox
Nodeのデバッグをする $ k debug node/mynode -it --image=ubuntu “The container runs
in the host IPC, Network, and PID namespaces. The root filesystem of the Node will be mounted at /host.” [2] 強力すぎてセキュリティおじさんはヒヤヒヤしてしまう マルチテナントクラスターでは使えるとまずいかも?
目次 1. kubectl debugのユースケース 2. kubectl debugの使い方 3. まとめ
kubectl debugは強力、Minimal imagesを実現しよう centos distroless App App bash openssl “Minimal
images lower operational burden and reduce attack vectors.” [3][4]
GAしていないため変更の可能性あり エフェメラルコンテナ • v1.16 alpha • v1.21 beta [5] kubectl
debug • v1.18 alpha • v1.20 beta
kubectl debug 完全に理解した
reference [1] Ephemeral Containers https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/ [2] Debug Running Pods https://kubernetes.io/docs/tasks/debug-application-cluster/debug-running-pod/
[3] KEP-277: Ephemeral Containers https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/277-ephemeral-containers [4] KEP-1441: kubectl debug https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/1441-kubectl-debug [5] Update Ephemeral Containers KEP for beta in 1.21 https://github.com/kubernetes/enhancements/pull/2244