请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

您好,请问一下进入pod报错.

[root@node1 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-busybox 2/2 Running 0 17m
[root@node1 ~]# kubectl exec nginx-busybox -c busybox /bin/sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] – [COMMAND] instead.
error: unable to upgrade connection: pod does not exist
[root@node1 ~]#

正在回答 回答被采纳积分+3

3回答

麦兜搞IT 2020-06-08 04:42:43
➜  pod git:(master) ✗ kubectl get pod
NAME            READY   STATUS    RESTARTS   AGE
nginx-busybox   2/2     Running   0          3m32s
➜  pod git:(master) ✗ kubectl exec -it nginx-busybox -c nginx bin/sh
#
#
# exit
➜  pod git:(master) ✗
➜  pod git:(master) ✗
➜  pod git:(master) ✗ kubectl exec -it nginx-busybox -c busybox bin/sh
/ #
/ #
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
12: eth0@if13: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
    link/ether 02:42:ac:11:00:05 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.5/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever
/ #

-c 可以指定到底进入那个container

0 回复 有任何疑惑可以回复我~
提问者 Alan_Z 2020-05-11 10:57:58

[root@node1 ~]# kubectl version

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

[root@node1 ~]# kubectl version

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:48:36Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

[root@node1 ~]# kubectl get pods

NAME            READY   STATUS    RESTARTS   AGE

nginx           1/1     Running   1          42h

nginx-busybox   2/2     Running   0          8m9s

[root@node1 ~]# kubectl exec -it nginx-busybox bin/sh

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.

Defaulting container name to nginx.

Use 'kubectl describe pod/nginx-busybox -n default' to see all of the containers in this pod.

error: unable to upgrade connection: pod does not exist


0 回复 有任何疑惑可以回复我~
麦兜搞IT 2020-05-10 03:57:37

试试 kubectl exec -it nginx-busybox bin/sh

0 回复 有任何疑惑可以回复我~
  • 同样问题,这个命令没有解决
    回复 有任何疑惑可以回复我~ 2020-06-08 00:42:35
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信