インフラ系SEの技術メモ

雑なエンジニアが低信頼性のメモを書いています。参考程度にとどめてください。

(Kubernetes)あるPodの中に入りたくて試行錯誤したけど結局は入れなかった

やりたかったこと

とあるPodの中で好きなコマンドを打つために exec sh で侵入しようとすると以下エラー。

$ kubectl exec -it coredns-xx sh -n kube-system
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "xx": OCI runtime exec failed: exec failed: container_linux.go:380: starting container
 process caused: exec: "sh": executable file not found in $PATH: unknown

ぐぬぬ...

試したこと

debugコマンド。

$ kubectl debug coredns-xx -it --image=busybox --copy-to=my-debugger -n kube-system
Defaulting debug container name to debugger-pw5gg.
If you don't see a command prompt, try pressing enter.
/ # ls
bin   dev   etc   home  proc  root  sys   tmp   usr   var

入れた~と思っていましたが、ファイルシステムが共用されていないのでtcmdumpなどで解析はできてもファイルの中身は見えない。

Nodeの中に入ってdockerコマンドで入り込む・・なんて記事もありましたが、Nodeがクラウド管理だとお手上げ。
うまいことできる方法あればぜひコメントで教えてください。