kubectl exec包含多容器Pod [英] kubectl exec into contain of multi container pod
问题描述
我无法登录到多容器吊舱的一个容器中.
我从kubectl describe pod <pod-name>
I have problem login into one container of a multi-container pod.
I get the container id from the kubectl describe pod <pod-name>
kubectl describe pod ipengine-net-benchmark-488656591-gjrpc -c <container id>
当我尝试:
kubectl exec -ti ipengine-net-benchmark-488656591-gjrpc -c 70761432854f /bin/bash
它说:来自服务器的错误:容器70761432854f对于pod ipengine-net-benchmark-488656591-gjrpc无效
It says: Error from server: container 70761432854f is not valid for pod ipengine-net-benchmark-488656591-gjrpc
推荐答案
嗯,再次详细阅读了kubectl exec的手册页:
ah once more detailed reading the man page of kubectl exec :
标志: -c,--container =":容器名称.如果省略,将选择容器中的第一个容器 -p,--pod =":容器名称 -i,-stdin [= false]:将stdin传递到容器 -t,--tty [= false]:Stdin是TTY
Flags: -c, --container="": Container name. If omitted, the first container in the pod will be chosen -p, --pod="": Pod name -i, --stdin[=false]: Pass stdin to the container -t, --tty[=false]: Stdin is a TTY
因此,我只是使用了manifest.yaml中的容器名称,它的工作方式就像是魅力.希望这对其他人有帮助...
So i just used the container name from my manifest.yaml and it worked like charm. Hope this helps others ...
Name of the container: ipengine-net-benchmark-iperf-server
kubectl exec -ti ipengine-net-benchmark-488656591-gjrpc -c ipengine-net-benchmark-iperf-server /bin/bash
这篇关于kubectl exec包含多容器Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!