kubectl-debug
kubectl-debug copied to clipboard
I copied a file into pod and put it under /opt. You can see it with exEC-it, but you can't see it with debug.
Exec -it can see this file
root@web-0-f449b476d-w95ms:/opt# ls
dns-test
You can't see this file with Debug
kubectl debug web-0-f449b476d-w95ms -n kube-system -a
Agent Pod info: [Name:debug-agent-pod-9917540e-cc0c-11ea-912f-005056872b09, Namespace:default, Image:aylei/debug-agent:latest, HostPort:10027, ContainerPort:10027]
Waiting for pod debug-agent-pod-9917540e-cc0c-11ea-912f-005056872b09 to run...
pulling image nicolaka/netshoot:latest...
latest: Pulling from nicolaka/netshoot
Digest: sha256:04786602e5a9463f40da65aea06fe5a825425c7df53b307daa21f828cfe40bf8
Status: Image is up to date for nicolaka/netshoot:latest
starting debug container...
container created, open tty...
bash-5.0# pwd
/
bash-5.0# cd /root/
bash-5.0# pwd
/root
bash-5.0# cd /opt/
bash-5.0# ls
bash-5.0# pwd
/opt
bash-5.0# ls
Pod's file namespace is difference from debug container's file namespace.
Firstly, use command ps -elf to determin the pid of your pod's main thread.
Then find the pod's /root dir at /proc/${pid}/root/