2017-08-09 2 views
10

kubeadmを使用して5台のVM(1台のマスターと1台のマスターと4台のスレーブ、Ubuntu 16.04.3 LTSを実行する)私はflannelを使ってクラスタ内のネットワークをセットアップしました。私はアプリケーションを正常にデプロイできました。その後、NodePortサービスを介して公開しました。ここから私にとっては事が複雑になった。K8s NodePortサービスは、クラスタ内の2/4スレーブでのみ「IPに到達できません」

私が開始する前に、マスターとノードでデフォルトのfirewalldサービスを無効にしました。

K8s Services docからわかるように、NodePortタイプは、クラスタ内のすべてのノードでサービスを公開します。しかし、私が作成したとき、サービスはクラスタ内の4つのノードのうち2つにしか公開されませんでした。私はそれらの2「故障した」ノード上で、これらのサービスではなかったことに気づき、いくつかの工夫の後

[email protected]:~# kubectl get nodes 
NAME    STATUS AGE  VERSION 
vm-deepejai-00b Ready  5m  v1.7.3 
vm-plashkar-006 Ready  4d  v1.7.3 
vm-rosnthom-00f Ready  4d  v1.7.3 
vm-vivekse-003 Ready  4d  v1.7.3 //the master 
vm-vivekse-004 Ready  16h  v1.7.3 

[email protected]:~# kubectl get pods -o wide -n playground 
NAME          READY  STATUS RESTARTS AGE  IP   NODE 
kubernetes-bootcamp-2457653786-9qk80  1/1  Running 0   2d  10.244.3.6 vm-rosnthom-00f 
springboot-helloworld-2842952983-rw0gc 1/1  Running 0   1d  10.244.3.7 vm-rosnthom-00f 

[email protected]:~# kubectl get svc -o wide -n playground 
NAME  CLUSTER-IP  EXTERNAL-IP PORT(S)   AGE  SELECTOR 
sb-hw-svc 10.101.180.19 <nodes>  9000:30847/TCP 5h  run=springboot-helloworld 

[email protected]:~# kubectl describe svc sb-hw-svc -n playground 
Name:    sb-hw-svc 
Namespace:   playground 
Labels:    <none> 
Annotations:  <none> 
Selector:   run=springboot-helloworld 
Type:    NodePort 
IP:     10.101.180.19 
Port:    <unset> 9000/TCP 
NodePort:   <unset> 30847/TCP 
Endpoints:   10.244.3.7:9000 
Session Affinity: None 
Events:    <none> 

[email protected]:~# kubectl get endpoints sb-hw-svc -n playground -o yaml 
apiVersion: v1 
kind: Endpoints 
metadata: 
    creationTimestamp: 2017-08-09T06:28:06Z 
    name: sb-hw-svc 
    namespace: playground 
    resourceVersion: "588958" 
    selfLink: /api/v1/namespaces/playground/endpoints/sb-hw-svc 
    uid: e76d9cc1-7ccb-11e7-bc6a-fa163efaba6b 
subsets: 
- addresses: 
    - ip: 10.244.3.7 
    nodeName: vm-rosnthom-00f 
    targetRef: 
     kind: Pod 
     name: springboot-helloworld-2842952983-rw0gc 
     namespace: playground 
     resourceVersion: "473859" 
     uid: 16d9db68-7c1a-11e7-bc6a-fa163efaba6b 
    ports: 
    - port: 9000 
    protocol: TCP 

:私は(?右)トラブルシューティングのための

、ここでいくつかのリソース仕様であることが予想される動作ではありません推測していますこれらのホスト自体から利用可能です。

Node01(作業):

[email protected]:~# curl 127.0.0.1:30847  //<localhost>:<nodeport> 
Hello Docker World!! 
[email protected]:~# curl 10.101.180.19:9000 //<cluster-ip>:<port> 
Hello Docker World!! 
[email protected]:~# curl 10.244.3.7:9000  //<pod-ip>:<port> 
Hello Docker World!! 

とnode02(作業):

[email protected]:~# curl 127.0.0.1:30847 
Hello Docker World!! 
[email protected]:~# curl 10.101.180.19:9000 
Hello Docker World!! 
[email protected]:~# curl 10.244.3.7:9000 
Hello Docker World!! 

node03の(動作しない):

[email protected]:~# curl 127.0.0.1:30847 
curl: (7) Failed to connect to 127.0.0.1 port 30847: Connection timed out 
[email protected]:~# curl 10.101.180.19:9000 
curl: (7) Failed to connect to 10.101.180.19 port 9000: Connection timed out 
[email protected]:~# curl 10.244.3.7:9000 
curl: (7) Failed to connect to 10.244.3.7 port 9000: Connection timed out 

Node04(動作しない):

[email protected]:/# curl 127.0.0.1:30847 
curl: (7) Failed to connect to 127.0.0.1 port 30847: Connection timed out 
[email protected]:/# curl 10.101.180.19:9000 
curl: (7) Failed to connect to 10.101.180.19 port 9000: Connection timed out 
[email protected]:/# curl 10.244.3.7:9000 
curl: (7) Failed to connect to 10.244.3.7 port 9000: Connection timed out 

すべての4つのスレーブでnetstattelnetを試しました。出力は次のとおりです。

Node01(作業ホスト):

[email protected]:~# netstat -tulpn | grep 30847 
tcp6  0  0 :::30847    :::*     LISTEN  27808/kube-proxy 
[email protected]:~# telnet 127.0.0.1 30847 
Trying 127.0.0.1... 
Connected to 127.0.0.1. 
Escape character is '^]'. 

とnode02(作業ホスト):

[email protected]:~# netstat -tulpn | grep 30847 
tcp6  0  0 :::30847    :::*     LISTEN  11842/kube-proxy 
[email protected]:~# telnet 127.0.0.1 30847 
Trying 127.0.0.1... 
Connected to 127.0.0.1. 
Escape character is '^]'. 

node03の( - 動作していないホスト):

[email protected]:~# netstat -tulpn | grep 30847 
tcp6  0  0 :::30847    :::*     LISTEN  7791/kube-proxy 
[email protected]:~# telnet 127.0.0.1 30847 
Trying 127.0.0.1... 
telnet: Unable to connect to remote host: Connection timed out 

Node04(動作していないホスト):

[email protected]:/# netstat -tulpn | grep 30847 
tcp6  0  0 :::30847    :::*     LISTEN  689/kube-proxy 
[email protected]:/# telnet 127.0.0.1 30847 
Trying 127.0.0.1... 
telnet: Unable to connect to remote host: Connection timed out 

追加情報:

kubectl get pods出力から、私はポッドが実際にスレーブvm-rosnthom-00fに配備されていることがわかります。私はpingすべての5つのVMからこのホストになり、curl vm-rosnthom-00f:30847はすべてのVMからも機能します。

私は明らかに内部クラスタネットワークが台無しになっていることがわかりますが、解決方法は不明です。すべてのスレーブのためのiptables -Lは同一であり、すべてのスレーブに対してLocal Loopback(ifconfig lo)さえ稼動しています。私はそれを修正する方法について完全に無知です!

+0

確認のため、ドッキングできないすべてのインターフェイスのIPアドレスは、ドッキングステーション、ポッド、およびサービスとは別のIPスペースですか? 'vm-vivekse-004'に' vm-deepejai-00b'が確実にトラフィックをルーティングできるようにするには、 'root @ vm-deepejai-00b:/#curl THE_IP_OF_vm-vivekse-004:30847'とにかくそれがカバーの下で起こっていることだからです。 –

+0

また、iptables -t nat -Lだけでなく、 'iptables -L'もチェックしました(それはあなたが意味するものなのかどうかは分かりませんでした)あなたの最初のコメントについては –

+0

@MatthewLDanielは、カール作品: 'ルート@のVM-deepejai-00B:〜#カール173.36.23.4:30847 こんにちはドッカー世界を!!' 173.36.23.4は、VM-のIPである vivekse-004 –

答えて

-3

クラスタ内の任意のノードからサービスにアクセスしたい場合は、サービスタイプがClusterIPである必要があります。サービスタイプをNodePortと定義したので、サービスが実行されているノードから接続することができます。


私の上記の答えは、私たちがどのNodeIP:Nodeportから接続することができるはずの文書に基づいて、正しくありませんでした。私のクラスターでも動作しません。

https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types

NodePort:静的ポート( NodePort)で、各ノードのIP上のサービスを公開します。ノードポートサービスが ルートになるClusterIPサービスが自動的に作成されます。クラスタ外の NodePortサービスに連絡するには、 :をリクエストしてください。

私のノードのIP転送が設定されていません。 nodePort

sysctl -w net.ipv4.ip_forward=1 
関連する問題