事象
KubernetesにてNodeで任意のコマンドを打つためにkubectl debug node
を実施するも
$ kubectl debug node/test_node -it --image=busybox Creating debugging pod node-debugger-test_node-b4gg2 with container debugger on node test_node.
上記からプロンプトが進まない。
環境情報
Kubernetes 1.21.4
原因/解決策
コンテナイメージの取得に失敗している。
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning Failed 99s kubelet Failed to pull image "busybox": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/busybox:latest": failed to resolve reference "docker.io/library/busybox:latest": failed to do request: Head "https://registry-1.docker.io/v2/library/busybox/manifests/latest": dial tcp XX:443: i/o timeout Warning Failed 26s (x2 over 99s) kubelet Error: ErrImagePull...
よって取得実績のあるリポジトリのイメージに変更すると
$ kubectl debug node/XX -it --image=xx
defaultのネームスペースに以下のPodが生成された上で
$ kubectl get all NAME READY STATUS RESTARTS AGE pod/node-debugger-test_node-46snw 1/1 Running 0 ...
Node上でコマンドを打てる。
$ kubectl debug node/test_node -it --image=xx Creating debugging pod node-debugger-test_node-46snw with container debugger on node test_node. If you don't see a command prompt, try pressing enter. / # ls
以下、補足です。
補足
同PodはHostのルートディレクトリがマウントされているのでコンテナの中からNode上の情報を確認できます。
Volumes: host-root: Type: HostPath (bare host directory volume) Path: / HostPathType:
ちなみに同コマンドはOpenshiftにも存在しますが
こちらは以下のイメージが起動されようとします。
registry.redhat.io/rhel8/support-tools
以上です。