[英]request with single ip or dnsname to multi node docker swarm cluster
I want to make the High available service.我想提供高可用服务。 However, I don't know how to make requests to cluster services with single ip or dns name from outside the cluster.
但是,我不知道如何从集群外部使用单个 ip 或 dns 名称向集群服务发出请求。
I tried --endpoint-mode dnsrr.我试过--endpoint-mode dnsrr。 But I think this is not for the outside request balancing.
但我认为这不是为了外部请求平衡。 Must I use reverse proxy or external load balancer.
我必须使用反向代理还是外部负载均衡器。 Can I make with software and cheap.
我可以用软件制作而且便宜。 I wish help me.
我希望帮助我。 Thank you.
谢谢你。
Use --publish-add
argument of docker service update
command in order to map port of docker swarm service to host VM port.使用 docker
docker service update
命令的--publish-add
参数,以便将 docker 集群服务的 map 端口连接到主机 VM 端口。 Then access the service using the host ip and port.然后使用主机 ip 和端口访问服务。
You can also create the service with published port using --publish host_vm_port:service_port
syntax.您还可以使用
--publish host_vm_port:service_port
语法创建具有已发布端口的服务。 For example:例如:
docker service create --name my_web --replicas 3 --publish 8080:80 nginx
would create docker swarm service nginx with 3 replicas with nginx port 80 mapped to host VM 8080 port.将创建 docker 群服务 nginx 具有 3 个副本,其中 nginx 端口 80 映射到主机 VM 8080 端口。 Then you software client can access the service using [vm_ip:80/service_url] url
然后您的软件客户端可以使用 [vm_ip:80/service_url] url 访问服务
I know this is an old question, but depending on your setup you might be able to use keepalived .我知道这是一个老问题,但根据您的设置,您可能可以使用keepalived 。 It allows you to define a static, virtual IP that will always point to one of your machines as long as there is still one running.
它允许您定义一个 static、虚拟 IP,只要还有一台机器仍在运行,它就会始终指向您的一台机器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.