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
kubectl debugを試してみた / k8snovice8-kubectl-debug
Search
Naoki Oketani
February 08, 2021
Technology
2.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
kubectl debugを試してみた / k8snovice8-kubectl-debug
Kubernetes Novice Tokyo #8
Naoki Oketani
February 08, 2021
More Decks by Naoki Oketani
See All by Naoki Oketani
Observe the Conference / observe-the-conference
okepy
0
490
最小権限を目指して / least privilege of service account
okepy
0
1.9k
security-profiles-operatorをさわってみた / try-security-profiles-operator
okepy
0
2.4k
Other Decks in Technology
See All in Technology
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
480
AI時代のAPI品質を支えるガードレール / API Guardrails for API quality in the AI era
yokawasa
1
210
AI 駆動 Terraform 開発/SRE_BizReach_MIXI_2
visional_engineering_and_design
3
2k
作り直せるコードは迅速に 作り直せないDBは慎重に - AI時代のプロダクトエンジニアが「判断の不可逆性」で開発速度を変える話
kinosuke01
0
300
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
160
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
350
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
600
Reactの設計論
uhyo
14
7.7k
日経電子版を支えていく Kasane Design System/fec_fukuoka
nikkei_engineer_recruiting
0
640
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1.1k
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
140
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
500
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Product Roadmaps are Hard
iamctodd
55
13k
How to build a perfect <img>
jonoalderson
1
6k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
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