Takes a redis master/slave topology as the JSON body of an HTTP PUT, and applies that topology to the given redis instances.
It works with NATted and/or containerized redis instances, because it does not read slave addresses from the master. This was a shortcoming in redis-sentinel at the time of writing.
It does not monitor the topology and does not implement automatic fail-over. It simply applies the intended topology. A consumer of this service could use it to apply a new topology as part of automatic fail-over.
The algorithm is as follows:
rack-app.rb takes no arguments or configuration. It listens for HTTP PUT to /master. It expects the body of the request
to be a json representation of the desired redis topology (see example below).
The address of an instance may be an IPv4 address or a name. If it is a name, and an SRV record is published for that name,
the port from the SRV record will be used if port is ommitted from the JSON topology.
ruby rack-app.rb &
cat > topology.json <<EOF
{
"master": {
"address": "10.0.0.2",
"port": 6379
},
"slaves": [
{
"address": "10.0.0.3",
"port": 6379
},
{
"address": "10.0.0.4",
"port": 6379
}
]
}
EOF
curl -XPUT -d @topology.json http://127.0.0.1:8080/master
Here is an example that relies on SRV records instead:
{
"master": {
"address": "_redis._tcp.node-1.redis-1.docker"
},
"slaves": [
{
"address": "_redis._tcp.node-2.redis-1.docker"
},
{
"address": "_redis._tcp.node-3.redis-1.docker"
}
]
}
Content type
Image
Digest
sha256:18dd1c185…
Size
302.7 MB
Last updated
almost 11 years ago
docker pull sheldonh/redis-dictator