So in Docker swarm mode (1.12) I have the ability to create a service, even one with 1 replica, and through the DNS Service Discovery mechanism built into swarm mode I can point to any host in the swarm and it is all routed to the container without added effort. I’m not seeing where this is possible in Rancher; what I’ve done as a workaround is to create a stack, then use a load-balancer to provide the service discovery mechanism but I like the cleanliness of swarm mode so can that be done in Rancher?
This is how Rancher has worked since long before Swarm existed… Every service in every stack on managed networking gets a DNS entry which resolves to all the IPs of healthy containers for that service. https://docs.rancher.com/rancher/v1.1/en/cattle/internal-dns-service/
So then something is seriously foobared because if I run a service, say redis, with the port-mapping of 6379:6379 and have only one instance of it in my 6 node swarm that’s running on say node 4, if I try to connect to any host other than node 4 I get connection refused. I setup the load balancer and violla, no issues.
I do the same with docker service create and no issues. So is there something I’m missing in my stack/service config? Including them below for reference
docker-compose.yml
redis-mq:
ports:
- 6379:6379/tcp
image: lab/redis:latest
utils-5-5:
log_driver: syslog
labels:
io.rancher.scheduler.affinity:host_label: location=1
tty: true
command: - /root/redisQueueWatcher.sh
- -q
- lab
log_opt:
syslog-address: udp://172.0.0.1:514
tag: viperl55
image: lab/utils-vip5.5:latest
pid: host
privileged: true
volumes: - /usr/local/gs3-virt-scripts:/usr/local/scripts
- /opt/utils:/opt/utils
- /var/log/central:/var/log/central
- /data/DataFiles:/data/DataFiles
working_dir: /root
stdin_open: true
rancher-compose.yml
redis-mq:
scale: 1
utils-5-5:
scale: 10
retain_ip: true
Maybe I misread your message…
You can resolve redis-mq[.stackname.rancher.internal]
on any host and it will resolve to the 10.42.x.y IP(s) assigned to the container(s) of that services. Connecting to those IPs will go over the IPSec overlay network and get you to that container regardless of what host the client and service are on.
The actual host port 6379 is only published on hosts that are running the actual containers. So you cannot go to $any_public_host_ip_in_the_environment:6379. That would mean only one service could use that port in the entire environment.
Yep, after digging in more and playing around it does look like the mesh routing of Docker swarm mode isn’t in Rancher, but using the load balancer provides similar functionality. I think a lot of it was around my own expectations of having an environment in Rancher set as Swarm made it just talk to the docker-engine running in swarm mode but that isn’t the case; it seems it’s more of the traditional Swarm configuration pre-1.12.
Internally though I should be able to resolve redis-mq.utils.rancher.internal where utils is the stack name so that may meet the needs without issue.
I think you’ve answered my question by setting my expectations around this topic; thank you very much for that! It’s one thing to check off the list.