Docker Community Forums

Share and learn in the Docker community.

Multiple clusters - single docker-cloud.yaml

(Daniel Lauzon) #1

I am automating provisioning an entire app environment
(cluster/node/stack + external AWS resources).
I need to bring up multiple such environments
but I’d like to have a single docker-cloud.yaml file for them all.

I’d rather not maintain:
-docker-cloud-prod.yaml (deployed a different AWS account)

How can I use the same stack definition docker-cloud.yaml, and perhaps dynamically add tags to it to match the cluster node tags?

Another solution might be something similar to the docker-compose extend?
Any ideas welcome

(Daniel Lauzon) #2

Answering my own question:
The following commands constrain each service (service1,service2 in this example) in stackname to run on the specific cluster.

docker-cloud tag add -t nodecluster-name=CLUSTERNAME service1.stackname
docker-cloud tag add -t nodecluster-name=CLUSTERNAME service2.stackname

It would be nice if I could add the tag directly to the stack, but from the docker-cloud cli at least that does not seem to be possible.
Even better if we could add/set tags with the
docker-cloud stack create|update commands

(LRubin) #3

Hi Daniel,
I’m a little confused by your use-case here. Can you tell me why you’d want to include tags in the stackfile?

Tags (or more properly “Labels” or “placement constraints”) can only go on nodes, node clusters, and services, so I’m not sure what the workflow/use case for specifying them in the stackfile is.

(Daniel Lauzon) #4

Hey @sanscontext,
We exchanged earlier today on “Load balancing the load balancer”, … small world.

The context is this:
I am automating the creation of multiple identical environments:
- bring up a node cluster (nodes get automatic nodecluster-name=CLUSTERNAME)
- provision some external stuff (AWS RDS,…)
- create/update some services using a docker-cloud.yml stack
- add constraint tag nodecluster-name=CLUSTERNAME to each service
- deploy/redeploy
- do some more external things (assigning DNS to the lb service.)

The placement constraints (tags) are needed to constrain the stack to the newly created nodecluster.

The placement constraints (tags) need to be applied to each service in the stack.
The placement constraints (tags) are not in the docker-cloud.yml stack file because I need to bring up many such cluster/stacks: (CLUSTERNAME in {prod,stage,dev,dan,…}), and want to have a single docker-cloud.yml

So I was just saying it would be convenient to apply the tags to the stack,
making them propagate to all services
(as I believe tags set on nodeclusters propagate to all nodes.)