I have a error when i want to access to my pod:
error: unable to upgrade connection: pod does not exist
it's a cluster with 3 nodes, below some details. Thanks in advance
root@kubm:~/deploy/nginx# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
kubm Ready master 37h v1.17.0 10.0.2.15 <none> Ubuntu 16.04.6 LTS 4.4.0-150-generic docker://19.3.5
kubnode Ready <none> 37h v1.17.0 10.0.2.15 <none> Ubuntu 16.04.6 LTS 4.4.0-150-generic docker://19.3.5
kubnode2 Ready <none> 37h v1.17.0 10.0.2.15 <none> Ubuntu 16.04.6 LTS 4.4.0-150-generic docker://19.3.5
root@kubm:~/deploy/nginx# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-59c9f8dff-v7dvg 1/1 Running 0 16h 10.244.2.3 kubnode2 <none> <none>
root@kubm:~/deploy/nginx# kubectl exec -it nginx-59c9f8dff-v7dvg -- /bin/bash
**error: unable to upgrade connection: pod does not exist**
The 10.0.2.15
IP address is the default for virtualbox
NAT
If you deploy a VM
using a vagrantfile
, your eth0
adapter will use the 10.0.2.15
IP address and the eth1
adapter will be assigned an other IP address.
K8s
uses the eth0
adapter to route packets between pods.
I had the same issue running a cluster with Vagrant
and Virtualbox
the first time.
Adding KUBELET_EXTRA_ARGS=--node-ip=x.x.x.x
where x.x.x.x
is your VM's IP in /etc/default/kubelet
(this can be part of the provisioning script for example) and then restarting kubelet (systemctl restart kubelet
) fixes the issues.
This is the recommended way to add extra runtime arguments to kubelet
as you can see in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
. Alternatively you can also edit the kubelet
config file under /etc/kubernetes/kubelet.conf
I use below command to get into a pod.
kubectl exec -i -t <pod-name> -- /bin/bash
Note -i
and -t
flag have a space on the command..
If you have multi-container pod you should pass container name with -c flag or it will by default connect to first container in POD.
ubuntu@cluster-master:~$ kubectl exec -i -t nginx -- /bin/bash
root@nginx:/# whoami
root
root@nginx:/# date
Tue Jan 7 14:12:29 UTC 2020
root@nginx:/#
Refer help section of command kubectl exec --help