0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

KubernetesのPodにshellがない時のデバッグ方法

Posted at

はじめに

kubectl exec -itでコンテナに入ろうとすると、時々/bin/bash/bin/shがない時があって困ったので、その場合の対処方法。kubernetesのマニュアルに全部書いてあった。

流れ

対象のPodでcontainerを立ち上げ、そのcontainerをPodにアタッチする模様。
デバッグしたいPodがephemeral-demoで、そのPodに/bin/bashがインストールされていない場合の例として、kubernetesマニュアルではbusybox:1.28のコンテナを接続する例を記載していたが、自分の使いたいコンテナならなんでも良さそう。

ephemeral-demoのPodにbusyboxのコンテナをアタッチする例

kubectl debug -it ephemeral-demo --image=busybox:1.28 --target=ephemeral-demo

うまくいけば対象のPodにログインできる。

Defaulting debug container name to debugger-r58ht.
If you don't see a command prompt, try pressing enter.
root@ephemeral-demo:/# 

ただし、デバッグ用のコンテナはget podしても見えない

$ kubectl get pod
NAME             READY   STATUS    RESTARTS   AGE
ephemeral-demo   1/1     Running   0          44m

#Readyなコンテナが一つだけ、busyboxのコンテナは何処に・・・

まとめ

知らなかったのは私だけ?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?