2017-12-02 160 views
0

我已經建立了3個節點的Docker Swarm。它們都配置爲羣集的一部分。主節點也是容器的主機。爲什麼Traefik無法在同一網絡上找到容器?

每個節點都有NFS掛載到NFS以存儲集中式數據。

我創建了一個全局的ElasticSearch集羣,因此它可以在所有節點上運行。這被配置爲在Cluser中使用DNS Round Robin(dnsrr)在Docker Swarm中運行。由於dnsrr不允許端口暴露我有監聽在19200請求Nginx上的代理服務器,然後將它們來代理服務elasticsearch端口9200

的Traefik,ElasticSearch代理和ElasticSearch節點都連接到相同的覆蓋網絡稱爲elastic_cluster。網絡是10.0.10.0/24

我配置了Traefik,因此它有一個指定的主機並在端口443上對elasticsearch.homenetwork.local(非真實域)做出了答案(讓我們加密配置),並且應該轉發給Nginx代理。

然而,當我試着打https://elasticsearch.homenetwork.local我在Traefik日誌中收到一個錯誤:

time="2017-12-02T22:50:37Z" level=warning msg="Error forwarding to http://10.0.10.3:19200, err: dial tcp 10.0.10.3:19200: getsockopt: no route to host" 

鑑於Traefik服務是10.0.10.0/24網絡,我不明白爲什麼我得到這個錯誤上。我使用Portainer來跟蹤服務,我可以看到Traefik服務的IP地址爲10.0.10.4

如果我運行交互式會話到Nginx代理服務器,它的IP地址爲10.0.10.7,我可以ping 10.0.10.4沒有問題。

容器都運行Ubuntu。沒有涉及iptables

有沒有人見過這樣的事情?我正在努力解決這裏有什麼問題,所以如果有人有任何建議,我會非常感謝他們。真正煩人的是,這曾經工作。我不記得有什麼改變,但顯然有一些東西。

ElasticSearch服務命令:

docker service create --name elasticsearch \ 
         --network elastic_cluster \ 
         --constraint "node.labels.app_role == "elasticsearch" \ 
         --mode global \ 
         --endpoint-mode dnsrr \ 
         docker.elastic.co/elasticsearch/elasticsearch:5.4.2 \ 
         elasticsearch 

ElasticSearch代理服務命令:

docker service create --name elasticsearch_proxy \ 
         --network elastic_cluster \ 
         --label traefik.enable=true \ 
         --label traefik.backend=elasticsearch_proxy \ 
         --label traefik.port=19200 \ 
         --label traefik.frontend.rule=Host:elasticsearch.home.turtlesystems.co.uk \ 
         --label traefik.docker.network=elastic_cluster \ 
         nginx:1.13 

nginx.conf - https://pastebin.com/Q5sXw6aw

Traefik服務命令

docker service create --name reverse_proxy \ 
         --network elastic_cluster \ 
         --network traefik-net \ 
         --constraint "node.role == manager" \ 
         --publish 80:80 \ 
         --publish 8080:8080 \ 
         --publish 443:443 \ 
         traefik 

traefik.toml - https://pastebin.com/GFPu8MYJ

回答

0

標籤所有這些事實證明,我有網絡問題的原因是因爲一個錯誤的網絡電纜後。

更換後,everythig工作正常。感謝您的所有建議。

0

我想你已經忘了提及你的服務設置

docker service create --name elasticsearch_proxy \ 
         --label traefik.docker.network=elastic_cluster 
         --label traefik.enable=true 
         --label traefik.port=19200 
         --network elastic_cluster \ 
         nginx:1.13 
+0

你是對的,我沒有忘記他們。我用我設定的標籤更新了我的問題。謝謝。 –

+0

您的nginx服務不會公開端口19200.您應該在您的命令中添加'--expose 19200' docker service create --name elasticsearch_proxy \ --network elastic_cluster \ --label traefik.enable = true \ - label traefik.backend = elasticsearch_proxy \ --label traefik.port = 19200 \ --label traefik.frontend.rule = Host:elasticsearch.home.turtlesystems.co.uk \ --label traefik.docker.network = elastic_cluster \ nginx:1.13' –

+0

我對此感到困惑。由於Traefik與NGinx服務位於同一網絡,因此我不需要公開該端口。實際上,這是我想要做的事情之一,因此我的Swarm中沒有大量暴露的端口。我錯過了什麼嗎?我對暴露端口的理解是,可以直接打到服務 - 我試圖在這裏使用Traefik代理它。 –

相關問題