I have a redis cluster deployed using docker-compose.yml. It has 3 masters and 1 replica for each master. I also have services client
and storage
, where storage
works with my redis cluster. All of my services are connected via a network
with the following configuration:
networks:
my-network:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
the example of my redis-node:
redis-node:
image: redis
networks:
my-network:
ipv4_address: 172.28.x.y
ports:
- 7000:7000
- 17000: 17000
I'd like to be able to replicate a crash scenario where the network is gone and my storage
appears in a network where only one redis-master node is available and all the other ones are isolated.
My first solution was to create a different network used for isolation but then I can't configure the ports the right way.
Is there any way to resolve the problem? Does docker-compose have this kind of feature?
I'm not aware of such method, however, you could use an iptables to achieve the same goal.
To block the client, try the following:
#!/bin/bash
iptables -I INPUT -s IP -j DROP
To unblock:
#!/bin/bash
iptables -D INPUT -s IP -j DROP