Welcome to the Linux Foundation Forum!

Any correction to allow kubectl execute on pods running on worker node?

Options

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

  • chrispokorni
    chrispokorni Posts: 2,190
    Answer ✓
    Options

    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,
    -Chris

  • chrispokorni
    chrispokorni Posts: 2,190
    Answer ✓
    Options

    Hi @caishaoping,

    You can easily remove the worker node from the cluster with the kubectl delete node node-name command, build a new worker VM with a new IP address and then recreate the join command with kubeadm token create --print-join-command, and run the newly generated join command on the new VM.

    Regards,
    -Chris

  • chrispokorni
    chrispokorni Posts: 2,190
    Answer ✓
    Options

    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,
    -Chris

Answers

  • caishaoping
    Options

    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.9

  • caishaoping
    Options

    Here again, somehow, I did pretty much following and got it working, though still need time to digest:

    1. modifying /etc/systemd/system/kubelet.service.d/10-kubeadm.conf with adding KUBELET_EXTRA_ARGS=--node-ip %NEW_IP_ADDRESS%.
    2. sudo systemctl daemon-reload since config file was changed
    3. 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 -- sh

    pwd

    /

    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 worker

  • chrispokorni
    Options

    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,
    -Chris

  • caishaoping
    Options

    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 cp

    Simply 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 forever

  • caishaoping
    Options

    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!
    Shao

Categories

Upcoming Training