2.创建一个有问题的pod,我直接用官网的例子了 这镜像是拉取之后传到harbor里的 kubectl run ephemeral-demo --image=192.168.10.130/library/pause:3.1 --restart=Never kubectl get pods NAME READY STATUS RESTARTS AGE ephemeral-demo 1/1 Running 0 17s
此时容器内部是有报错的,无法使用exec进行调试 kubectl exec -it ephemeral-demo -- sh error: Internal error occurred: error executing commandin container: failed to execin container: failed to start exec"385c28c52c6c46981cc48c67757e2a6441fb14dd739757a12001247e0162edff": OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in$PATH: unknown
3.通过debug创建临时容器 (1) kubectl debug -it ephemeral-demo --image=192.168.10.130/library/busybox:1.28 --target=ephemeral-demo 添加一个新的 busybox 容器并将其挂接到该容器 Ephemeral Containers: debugger-dgfwj: Container ID: containerd://e4adae36f30c196abb5f589b5412493ce752940ce2b794269a3915112abea685 Image: 192.168.10.130/library/busybox:1.28 Image ID: 192.168.10.130/library/busybox@sha256:74f634b1bc1bd74535d5209589734efbd44a25f4e2 Normal Pulled 2m26s kubelet Container image "192.168.10.130/library/busybox:1.28" already present on machine Normal Created 2m26s kubelet Created container debugger-dgfwj Normal Started 2m26s kubelet Started container debugger-dgfwj
/ # ps aux PID USER TIME COMMAND 1 root 0:00 /pause 7 root 0:00 sh 13 root 0:00 ps aux