You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.2 KiB

A Docker swarm cluster with Heat

These Heat templates will deploy an N-node swarm cluster, where N is the value of the number_of_nodes parameter you specify when creating the stack.



These templates will work with the Juno version of Heat.

Guest image

These templates will work with either CentOS Atomic Host or Fedora 21 Atomic.

Creating the stack

First, you must create a swarm token, which is used to uniquely identify the cluster to the global discovery service. This can be done by issuing a create call to the swarm CLI. Alternatively, if you have access to Docker you can use the dockerswarm/swarm image.

$ swarm create

$ docker run dockerswarm/swarm create

Creating an environment file local.yaml with parameters specific to your environment:

  ssh_key_name: testkey
  external_network: 028d70dd-67b8-4901-8bdd-0c62b06cce2d
  server_image: fedora-atomic-latest
  discovery_url: token://d8cdfe5128af6e1075b34aa06ff1cc2c

And then create the stack, referencing that environment file:

heat stack-create -f swarm.yaml -e local.yaml my-swarm-cluster

You must provide values for:

  • ssh_key_name
  • external_network
  • server_image
  • discovery_url

Interacting with Swarm

The Docker CLI interacts with the cluster through the swarm master listening on port 2376.

You can get the ip address of the swarm master using the heat output-show command:

$ heat output-show my-swarm-cluster swarm_master

Provide the Docker CLI with the address for the swarm master.

$ docker -H tcp:// info
Containers: 4
Nodes: 3


You can test the swarm cluster with the Docker CLI by running a container. In the example below, a container is spawned in the cluster to ping

$ docker -H tcp:// run -i cirros /bin/ping -c 4
PING ( 56 data bytes
64 bytes from seq=0 ttl=127 time=40.749 ms
64 bytes from seq=1 ttl=127 time=46.264 ms
64 bytes from seq=2 ttl=127 time=42.808 ms
64 bytes from seq=3 ttl=127 time=42.270 ms

--- ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 40.749/43.022/46.264 ms


Copyright 2014 Lars Kellogg-Stedman Copyright 2015 Rackspace Hosting

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.