2017-12-02 61 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代理它。 –

相关问题