Skip to content

Instantly share code, notes, and snippets.

@amjadafanah
Created January 18, 2016 00:06
Show Gist options
  • Save amjadafanah/bcd3d4a8d6727c21ba74 to your computer and use it in GitHub Desktop.
Save amjadafanah/bcd3d4a8d6727c21ba74 to your computer and use it in GitHub Desktop.
Docker Mongo Replica Set with support for auto-scaling. The service discovery is provided through DCHQ's plug-in framework. The service discovery framework in DCHQ provides event-driven life-cycle stages that executes custom scripts to re-configure application components. This is critical when scaling out clusters for which a load balancer may n…
mongo_rs1_srv1:
image: mongo:latest
mem_min: 400m
publish_all: true
command: --replSet rs1
environment:
# inject clustered node ips
- MONGO_RS1_SRV2_IP={{mongo_rs1_srv2|container_private_ip}}
# The above mapping will insert comma separated ip list e.g. 10.1.1.1,10.1.12
plugins:
- !plugin
# This plugin initializes the Replica Set
lifecycle: on_create
id: QX25F
- !plugin
# This plug-in re-balances the Replica Set post scale out
lifecycle: post_scale_out:mongo_rs1_srv2
id: sxKM9
- !plugin
# This plug-in re-balances the Replica Set post scale in
lifecycle: post_scale_in:mongo_rs1_srv2
id: YIALH
# Define this node as clustered
mongo_rs1_srv2:
image: mongo:latest
mem_min: 400m
cpu_shares: 1
cluster_size: 2
command: --replSet rs1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment