Docker Swarm Redis and Sentinel with master - slave replication IP resolution client failure
Asked Answered
S

1

7

I am running into an issue and I am not sure how to resolve this. My redis sentinel eco system is as follows:

3 sentinel cluster --> Managing 1 master and 2 slaves using docker-compose

I have created a docker overlay network for the eco system and using docker stack deploy to run the docker compose yml. The redis-cli on each node displays the correct INFO configuration. However external clients are running into an issue.

When I supply the sentinel address to the client application (in my case it's a spring redis app) I am getting the overlay network's internal IP address for the master redis. This is not recognizable to the client and it fails. How can I get an IP address that can be resolved externally? Secondly is it even possible since docker swarm manages the IP addresses on the overlay network. Is this the right approach i.e. using docker swarm? Any feedback would be greatly appreciated.

version: '3'

services:
  redis-master:
    image: redis:latest
    volumes:
      - "/docker-service-data/master:/data"
      - /redis-docker/redis.conf:/etc/redis.conf
    command: redis-server /etc/redis.conf
    ports:
      - 6379:6379
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
    networks:
       - rev_proxy
  redis-slave:
    image: redis:latest
    volumes:
      - "/docker-service-data/slave:/data"
      - /redis-docker/redis.conf:/etc/redis.conf
    command: redis-server /etc/redis.conf --slaveof redis-master 6379 
    deploy:
      mode: replicated
      replicas: 2
      placement:
        constraints: [node.role == worker]
    networks:
       - rev_proxy
  sentinel_1:
    image: <private-registry>/redis-sentinel:1
    deploy:
      mode: replicated
      replicas: 3
    ports:
      - 26379:26379
    depends_on:
      - redis-master
    networks:
      - rev_proxy
networks:
  rev_proxy:
     external:
       name: rev_proxy_net

redis.conf:

I have commented the bind statement so that the replica listens to all interfaces protected mode is no There is no authentication at this point.

sentinel.conf:

sentinel monitor master redis-master 6379 2
sentinel down-after-milliseconds master 1000
sentinel parallel-syncs master 1
sentinel failover-timeout master 1000
Strategist answered 27/8, 2017 at 5:44 Comment(4)
Post your complete configs and docker-compsoe you have usedFourteen
Let me know if you need more infoStrategist
Anyone out there who has run into this problem?Strategist
@sharman, did you have any luck with this setup?Dentilabial
M
3

You might need version: '3.3' and endpoint_mode: vip option. Refer to this link, https://docs.docker.com/compose/compose-file/#endpoint_mode

Misfortune answered 7/12, 2017 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.