Master / Slave Relationships

Hey all,

Hoping for some bright ideas. I have a service i wish to deploy with a simple config file managed by confd.
One of the containers needs to be a master, and one a slave, i want to be able to scale this service but i only ever want one master.

Originally tried defining them as two services, this however this seems a little overly complicated and doesn’t work well when it comes to sending traffic to both services via the loadbalancer.

Can i somehow use the metadata service to firgure out a primary in this scenario? Bit stuck with the design on this one.

@Rucknar, yes you can use metadata to accomplish what you are looking for. To do a simple leader election you can use this: https://github.com/cloudnautique/giddyup or you can use the bash equivalent https://github.com/rancher/compose-templates/blob/master/glusterfs/containers/0.1.3/glusterfs/lowest_idx.sh. I’m moving away from the bash version in favor of giddyup, but its built on the same idea. I should be publishing a new version of Giddyup that will proxy all traffic to the leader if the service is behind a load balancer. Not sure if that will help you.

Depending on what your trying to do with confd… I’d generate a master config and a slave config… and then if you can execute the appropriate config passing the appropriate file in the services entrypoint. something like(if you use the shell script replace giddyup with the script):

giddyup leader
if [ "$?" -eq "0" ]; then
  exec service -f /etc/service/config.master
fi
exec service -f /etc/service/config

That’s perfect for our use case, thanks @cloudnautique
I’ll give it a try after the christmas break.