连接

通过kubectl来连接其他node上的pod中的容器

[root@m ~]# kubectl get pods -o wide
NAME                       READY     STATUS    RESTARTS   AGE       IP            NODE
busybox-3674381263-90hh9   1/1       Running   0          39m       172.30.83.2   192.168.56.202
[root@m ~]# kubectl get pods
NAME                       READY     STATUS    RESTARTS   AGE
busybox-3674381263-90hh9   1/1       Running   0          39m
[root@m ~]# kubectl get node
NAME             STATUS    AGE
192.168.56.201   Ready     2d
192.168.56.202   Ready     7d
[root@m ~]# kubectl exec -it busybox-3674381263-90hh9 sh
/ # ip a
1: lo:  mtu 65536 qdisc noqueue qlen 1
    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
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
5: eth0@if6:  mtu 1450 qdisc noqueue 
    link/ether 02:42:ac:1e:53:02 brd ff:ff:ff:ff:ff:ff
    inet 172.30.83.2/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe1e:5302/64 scope link 
       valid_lft forever preferred_lft forever

故障

开始的时候不能连接,报错如下:

[root@m ~]# kubectl exec -it busybox-3674381263-90hh9 sh
Error from server: error dialing backend: dial tcp 192.168.56.202:10250: getsockopt: connection refused

排查结果是:
kubernetes之基本使用2_第1张图片