1. 程式人生 > >kubernetes之基本使用2

kubernetes之基本使用2

k8s

連接

通過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: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> 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