Container By Joseph

K8s 除錯神器:kubectl debug 指令詳解

不再需要 SSH

當 Pod 崩潰且容器內沒有 Shell 時,kubectl debug 是救星。

它利用 Ephemeral Containers 技術,將一個帶有除錯工具 (如 busybox 或 netshoot) 的容器掛載到目標 Pod 的 Namespace 中。

指令範例:
kubectl debug -it <target-pod> --image=nicolaka/netshoot --target=<container-name>
這讓你能在不重啟 Pod 的情況下進行網路抓包或 Process 檢查。