Any correction to allow kubectl execute on pods running on worker node?
Hi There,
Some how, I cannot run kubectl exec pod command on pods assigned to worker node, I am getting "unable to upgrade connection.." when running following command:
vagrant@cp:~/app1$ for name in try1-7f7c6fdc54-dqgjj try1-7f7c6fdc54-f8k5m \
try1-7f7c6fdc54-jxq57
do kubectl exec $name -- touch /tmp/healthy
done
error: unable to upgrade connection: pod does not exist
error: unable to upgrade connection: pod does not exist
error: unable to upgrade connection: pod does not exist
vagrant@cp:~/app1$
vagrant@cp:~/app1$ kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-6488f757bc-rp4wv 1/1 Running 3 (110m ago) 24h 192.168.171.93 worker
registry-d4cf9fd7d-9c52d 1/1 Running 3 (110m ago) 24h 192.168.171.92 worker
try1-7f7c6fdc54-9zh2w 1/1 Running 0 12m 192.168.242.66 cp
try1-7f7c6fdc54-dqgjj 0/1 Running 0 12m 192.168.171.108 worker
try1-7f7c6fdc54-f8k5m 0/1 Running 0 12m 192.168.171.106 worker
try1-7f7c6fdc54-h4594 1/1 Running 0 12m 192.168.242.65 cp
try1-7f7c6fdc54-jxq57 0/1 Running 0 12m 192.168.171.107 worker
try1-7f7c6fdc54-vpbsj 1/1 Running 0 12m 192.168.242.67 cp
Thanks advance.
Shao
Best Answers
-
Hi @caishaoping,
This could be the result of improper network configuration of the VMs by the hypervisor. For specific details I would recommend watching the demo videos from the introductory chapter where the infrastructure provisioning is presented on AWS and GCP, but with key VM instance networking configuration options. On a local hypervisor similar configuration options should be available for VM networking. Once configured, cross exec should work, together with other commands that may fail at this time.
Regards,
-Chris0 -
Hi @caishaoping,
You can easily remove the worker node from the cluster with the
kubectl delete node node-namecommand, build a new worker VM with a new IP address and then recreate the join command withkubeadm token create --print-join-command, and run the newly generated join command on the new VM.Regards,
-Chris0 -
Hi @caishaoping,
The eth interface with IP on the same subnet as the other node should be used (but the IP addresses of your nodes should be distinct). The tunl interface is created by the network plugin to enable cross node routing.
Regards,
-Chris0
Answers
-
Thanks @chrispokorni
Per stackoverflow, I checked my nodes and found that both nodes use the same internal IP. Let me find out how to update nodes' internal ip. Hope I don't have to kubeadm join again.
vagrant@cp:~/app1$ k get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
cp Ready control-plane 5d21h v1.24.1 10.0.2.15 Ubuntu 20.04.5 LTS 5.4.0-125-generic containerd://1.6.8
worker Ready 5d21h v1.24.1 10.0.2.15 Ubuntu 20.04.5 LTS 5.4.0-125-generic containerd://1.5.90 -
Here again, somehow, I did pretty much following and got it working, though still need time to digest:
- modifying /etc/systemd/system/kubelet.service.d/10-kubeadm.conf with adding KUBELET_EXTRA_ARGS=--node-ip %NEW_IP_ADDRESS%.
- sudo systemctl daemon-reload since config file was changed
- sudo systemctl restart kubelet.service
After the change, worker node's ip changed:
vagrant@cp:~$ k get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
cp Ready control-plane 5d22h v1.24.1 10.0.2.15 Ubuntu 20.04.5 LTS 5.4.0-125-generic containerd://1.6.8
worker Ready 5d22h v1.24.1 192.168.171.64 Ubuntu 20.04.5 LTS 5.4.0-125-generic containerd://1.5.9
vagrant@cp:~$Now, I can exec pod running on worker node:
vagrant@cp:~$ k exec -it busybox -- shpwd
/
ls -al
vagrant@cp:~$ k get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
busybox 1/1 Running 1 (51m ago) 111m 192.168.171.121 worker
nginx-6488f757bc-rp4wv 1/1 Running 5 (51m ago) 41h 192.168.171.120 worker
registry-d4cf9fd7d-9c52d 1/1 Running 5 (51m ago) 41h 192.168.171.122 worker0 -
Hi @caishaoping,
Yes, it seems that the worker displays a new IP address, however, it is an IP that overlaps the pod CIDR and eventually will cause routing issues within your cluster.
Regards,
-Chris0 -
Sorry but I think I still need to ask one more question to be clear on assigning node's internal IP address, I am using VirtualBox VMs, when I assign internal IP to cp or worker node, should I only use one of the internal IP associated to LAN interface like eth0 or eth1? or I should avoid IPs associated to tunl0@NONE or others?
I am asking this because either liveness or readiness probe check is not success for goproxy, regardless of node where the pod is running on.
try1-79f8557b4d-2w2sp 1/2 Running 0 2m51s 192.168.171.66 worker
try1-79f8557b4d-449sp 1/2 Running 0 2m50s 192.168.171.68 worker
try1-79f8557b4d-fx676 1/2 Running 0 2m51s 192.168.242.91 cp
try1-79f8557b4d-gb5pt 1/2 Running 0 2m50s 192.168.171.67 worker
try1-79f8557b4d-jck92 1/2 Running 0 2m50s 192.168.242.89 cp
try1-79f8557b4d-k4788 1/2 Running 0 2m51s 192.168.242.90 cpSimply put, which one should be good candidate for node's internal IP?
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:a2:6b:fd brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 83551sec preferred_lft 83551sec
inet6 fe80::a00:27ff:fea2:6bfd/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:13:16:91 brd ff:ff:ff:ff:ff:ff
inet 172.16.0.100/24 brd 172.16.0.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe13:1691/64 scope link
valid_lft forever preferred_lft forever
4: tunl0@NONE: <NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN group default qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
inet 192.168.242.64/32 scope global tunl0
valid_lft forever preferred_lft forever0 -
Thanks a lot @chrispokorni
Though still a lot to learn in K8s network part, for the purpose this lab, I have now got it done and understood more from doing the lab, including all the fail-and-try.
Appreciate!
Shao0
Categories
- All Categories
- 177 LFX Mentorship
- 177 LFX Mentorship: Linux Kernel
- 754 Linux Foundation IT Professional Programs
- 374 Cloud Engineer IT Professional Program
- 170 Advanced Cloud Engineer IT Professional Program
- 74 DevOps IT Professional Program - Discontinued
- 5 DevOps & GitOps IT Professional Program
- 100 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 2 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 5 Cloud & Containers Training
- 1 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 1 Networking Training
- 2 Open Source Best Practice Training
- 2 System Administration Training
- 1 System Engineering Training
- 1 Web & Application Development Training
- 794 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 89 Storage
- 769 Linux Distributions
- 81 Debian
- 68 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 112 Mobile Computing
- 20 Android
- 77 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 393 Off Topic
- 121 Introductions
- 182 Small Talk
- 29 Study Material
- 977 Programming and Development
- 310 Kernel Development
- 649 Software Development
- 990 Software
- 382 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)