您应该以 root 身份连接到 pod 以查看跟踪。
使用最新的opensuse/tumbleweed 例如 pod
#suse-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: suse
spec:
containers:
- name: suse
image: opensuse/tumbleweed
command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]
以常规方式连接到 pod 并启动进程
suse:/ # kubectl exec suse -ti -- bash
suse:/ # sleep 100000&
[1] 677
suse:/ # ps aux | grep sleep
root 677 0.0 0.0 2324 764 pts/3 S 14:16 0:00 sleep 100000
检查:
suse:/ # gstack 677 --> empty
suse:/ # gdb
(gdb) attach 677
Attaching to process 677
ptrace: Operation not permitted.
ptrace:不允许操作。
你可以做什么:
1) 你可以(和我一样)安装 3rd party awesome kubectl-plugins 并使用 kubectl ssh -u root [pod] 访问 root 下的 pod。
git clone https://github.com/jordanwilson230/kubectl-plugins.git
cd kubectl-plugins
./install-plugins.sh
source ~/.bash_profile
kubectl ssh -u root suse
Connecting...
Pod: suse
Namespace: NONE
User: root
Container: NONE
Command: /bin/sh
If you don't see a command prompt, try pressing enter.
sh-5.0# gstack 677
#0 0x00007f8eeb2a7603 in nanosleep () from /lib64/libc.so.6
#1 0x000055fd4fc88677 in ?? ()
#2 0x000055fd4fc88450 in ?? ()
#3 0x000055fd4fc85500 in ?? ()
#4 0x00007f8eeb201e0b in __libc_start_main () from /lib64/libc.so.6
#5 0x000055fd4fc855da in ?? ()
sh-5.0# gdb
GNU gdb (GDB; openSUSE Tumbleweed) 8.3.1
(gdb) attach 677
Attaching to process 677
Reading symbols from /usr/bin/sleep...
(No debugging symbols found in /usr/bin/sleep)
Reading symbols from /lib64/libc.so.6...
(No debugging symbols found in /lib64/libc.so.6)
Reading symbols from /lib64/ld-linux-x86-64.so.2...
(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
0x00007f8eeb2a7603 in nanosleep () from /lib64/libc.so.6
Missing separate debuginfos, use: zypper install coreutils-debuginfo-8.31-2.2.x86_64
2) 你可以关注@mac answer
-找出它在 kubectl get po -n [NAMESPACE] -o wide 上运行的节点
-ssh 节点
-找到 docker 容器 sudo docker ps | grep [命名空间]
-以root身份登录容器 sudo docker exec -it -u root [DOCKER ID] /bin/bash
希望对你有帮助