簡體   English   中英

Calico 在我的 k8s 中運行良好,但我無法在節點上 Ping clusterip

[英]Calico works well in my k8s, but I can't Ping clusterip on the node

我按照官網的步驟安裝了calico,可以正常運行,日志也沒有報錯。 但是我ping clusterip的時候,ping不通,pod日志也沒有報錯,所以找不到問題所在。

root@qhwk-k8s-master-0:/work/k8s/calico-v3.16.3# kcp -n calico-system
NAME                                       READY   STATUS    RESTARTS   AGE   IP               NODE                NOMINATED NODE   READINESS GATES
calico-kube-controllers-6bbcdcb447-kcb4k   1/1     Running   7          23m   192.168.74.193   qhwk-k8s-node-2     <none>           <none>
calico-node-5spbv                          1/1     Running   0          23m   10.58.221.192    qhwk-k8s-master-0   <none>           <none>
calico-node-f5xfn                          1/1     Running   0          23m   10.58.221.47     qhwk-k8s-master-1   <none>           <none>
calico-node-fgbsc                          1/1     Running   0          23m   10.58.221.50     qhwk-k8s-node-0     <none>           <none>
calico-node-mfxpv                          1/1     Running   0          23m   10.58.221.153    qhwk-k8s-master-2   <none>           <none>
calico-node-pnksj                          1/1     Running   0          23m   10.58.221.52     qhwk-k8s-node-2     <none>           <none>
calico-node-rhbjt                          1/1     Running   0          23m   10.58.221.132    qhwk-k8s-node-1     <none>           <none>
calico-typha-66865d84cf-629ws              1/1     Running   0          21m   10.58.221.153    qhwk-k8s-master-2   <none>           <none>
calico-typha-66865d84cf-77z2q              1/1     Running   0          23m   10.58.221.132    qhwk-k8s-node-1     <none>           <none>
calico-typha-66865d84cf-f49kw              1/1     Running   0          21m   10.58.221.52     qhwk-k8s-node-2     <none>           <none>
calico-typha-66865d84cf-jwhq5              1/1     Running   0          21m   10.58.221.50     qhwk-k8s-node-0     <none>           <none>
root@qhwk-k8s-master-0:/work/k8s/calico-v3.16.3# kc get svc
NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                      AGE
centos-service          ClusterIP   172.18.173.199   <none>        80/TCP                                       120m
default-http-backend    ClusterIP   172.18.28.240    <none>        80/TCP                                       4h42m
gateway-nginx-service   ClusterIP   172.18.190.4     <none>        80/TCP                                       5h18m
nacos-service           ClusterIP   172.18.160.214   <none>        80/TCP                                       5h42m
nginx-ingress-service   NodePort    172.18.236.7     <none>        80:30080/TCP,443:30081/TCP,18080:31648/TCP   4h42m
nginx-service           ClusterIP   172.18.89.51     <none>        80/TCP                                       135m
root@qhwk-k8s-master-0:/work/k8s/calico-v3.16.3# ping 172.18.190.4
PING 172.18.190.4 (172.18.190.4) 56(84) bytes of data.
^C
--- 172.18.190.4 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1007ms

root@qhwk-k8s-master-0:/work/k8s/calico-v3.16.3# ping 172.18.173.199
PING 172.18.173.199 (172.18.173.199) 56(84) bytes of data.
^C
--- 172.18.173.199 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms

root@qhwk-k8s-master-0:/work/k8s/calico-v3.16.3#

從下面的操作記錄可以看出,curl serviceip和curl podip都沒有在該節點上工作。 但是,如果進入pod,serviceip和podip都可以通過curl連接

root@qhwk-k8s-master-0:~# kc get svc -n bn-public
NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                      AGE
centos-service          ClusterIP   172.18.173.199   <none>        80/TCP                                       6h12m
default-http-backend    ClusterIP   172.18.28.240    <none>        80/TCP                                       8h
gateway-nginx-service   ClusterIP   172.18.190.4     <none>        80/TCP                                       9h
nacos-service           ClusterIP   172.18.160.214   <none>        80/TCP                                       9h
nginx-ingress-service   NodePort    172.18.236.7     <none>        80:30080/TCP,443:30081/TCP,18080:31648/TCP   8h
nginx-service           ClusterIP   172.18.89.51     <none>        80/TCP                                       6h27m
root@qhwk-k8s-master-0:~# kc get pods -o wide -n bn-public 
NAME                                        READY   STATUS             RESTARTS   AGE     IP               NODE              NOMINATED NODE   READINESS GATES
default-http-backend-84489c7cf-7cdgl        1/1     Running            0          8h      192.168.74.213   qhwk-k8s-node-2   <none>           <none>
default-http-backend-84489c7cf-8kdg6        1/1     Running            0          8h      192.168.21.206   qhwk-k8s-node-1   <none>           <none>
default-http-backend-84489c7cf-94hrk        1/1     Running            0          8h      192.168.21.207   qhwk-k8s-node-1   <none>           <none>
default-http-backend-84489c7cf-cqmv4        1/1     Running            0          8h      192.168.35.212   qhwk-k8s-node-0   <none>           <none>
gateway-nginx-deploy-7f67dc9c75-f5x56       1/2     CrashLoopBackOff   103        9h      192.168.35.210   qhwk-k8s-node-0   <none>           <none>
nacos-deploy-795df8675b-v4998               1/1     Running            0          9h      192.168.74.210   qhwk-k8s-node-2   <none>           <none>
networktool-nftnw                           1/1     Running            0          177m    192.168.21.193   qhwk-k8s-node-1   <none>           <none>
nginx-ingress-controller-77d68ddfc5-5qx5h   1/1     Running            0          8h      192.168.21.205   qhwk-k8s-node-1   <none>           <none>
nginx-ingress-controller-77d68ddfc5-dflvk   1/1     Running            0          8h      192.168.35.211   qhwk-k8s-node-0   <none>           <none>
nginx-ingress-controller-77d68ddfc5-njhmh   1/1     Running            0          8h      192.168.74.211   qhwk-k8s-node-2   <none>           <none>
nginx-ingress-controller-77d68ddfc5-pnlq9   1/1     Running            0          8h      192.168.74.212   qhwk-k8s-node-2   <none>           <none>
test-centos-864b48b597-nnnh4                1/1     Running            6          6h2m    192.168.74.214   qhwk-k8s-node-2   <none>           <none>
test-nginx-6568c89cf-4tpq6                  1/1     Running            0          6h28m   192.168.21.208   qhwk-k8s-node-1   <none>           <none>
root@qhwk-k8s-master-0:~# ping  192.168.21.208
PING 192.168.21.208 (192.168.21.208) 56(84) bytes of data.
^C
--- 192.168.21.208 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2014ms

root@qhwk-k8s-master-0:~# curl   192.168.21.208
^C
root@qhwk-k8s-master-0:~# curl  172.18.89.51
^C
root@qhwk-k8s-master-0:~# kc get ep -n bn-public |grep nginx
gateway-nginx-service   <none>                                                                    9h
nginx-ingress-service   192.168.21.205:443,192.168.35.211:443,192.168.74.211:443 + 9 more...      8h
nginx-service           192.168.21.208:80                                                         6h30m
root@qhwk-k8s-master-0:~# kc exec -it test-nginx-6568c89cf-4tpq6 sh -n bn-public
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
# curl localhost             
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
# curl nginx-service
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
#

它按設計工作 - 您無法 ping 服務的 IP,因為它是 虛擬 IP - 它沒有連接到任何網絡接口,但您可以卷曲它。 這只是一堆 iptable 規則,有助於在 pod 之間轉發流量。

但是,您可以 ping pod 的 IP。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM