error: unable to upgrade connection: pod does not exist 解决方案

在vagrant 创建的VirtualBox 里部署了k8s ,

[root@master yaml]# kubectl get pods
NAME                          READY   STATUS             RESTARTS   AGE
app-7bcbdd4dfd-l2xkv          0/1     CrashLoopBackOff   582        2d5h
db-756759796-gfl8d            1/1     Running            0          25m
mosquitto-c5ddcff77-qvzhr     1/1     Running            1          2d5h
mqtt-7b9dcdc467-cxwrm         1/1     Running            1          2d5h
web-server-77d9d9f8fc-4lnn2   1/1     Running            1          2d5h

但是:

[root@master yaml]# kubectl exec -it db-756759796-gfl8d bash
error: unable to upgrade connection: pod does not exist
[root@master yaml]# kubectl exec -it db-756759796-gfl8d bash
error: unable to upgrade connection: pod does not exist

原因是 vagrant 创建的box,eth0 ip默认是10开头的。eth1才是可以互联的IP。
因此需要指定一下。

在master 和 worker (node)上都做修改
注意。

CENTOS 中,打开:/etc/sysconfig/kubelet

ubuntu中,打开:/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

#/etc/default/kubernetes ,添加如下内容:--node-ip

KUBELET_EXTRA_ARGS=--node-ip=ABCXYZ 
ABCXYZ为eth1的IP。

重启kubelet

systemctl restart kubelet

然后查看:

[root@master yaml]# kubectl get nodes -o wide
NAME                  STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION                CONTAINER-RUNTIME
master.localdomain    Ready    master   3d    v1.16.0   192.168.56.9    <none>        CentOS Linux 7 (Core)   3.10.0-1160.53.1.el7.x86_64   docker://18.9.9
worker1.localdomain   Ready    <none>   3d    v1.16.0   192.168.56.10   <none>        CentOS Linux 7 (Core)   3.10.0-1127.el7.x86_64        docker://18.9.9
worker2               Ready    <none>   3d    v1.16.0   192.168.56.11   <none>        CentOS Linux 7 (Core)   3.10.0-1127.el7.x86_64        docker://18.9.9

INTERNAL-IP显示正常了。

参考:
https://stackoverflow.com/questions/51154911/kubectl-exec-results-in-error-unable-to-upgrade-connection-pod-does-not-exi

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值