No description, website, or topics provided.
HCL Shell
Switch branches/tags
Nothing to show
Clone or download
Latest commit acfe188 Nov 12, 2016
Permalink
Failed to load latest commit information.
.gitignore Ignoring local env file Nov 9, 2016
README.md Preparation for blog Nov 11, 2016
connect.sh Using coreos Nov 10, 2016
output.tf Using coreos Nov 10, 2016
providers.tf Node creation Oct 23, 2016
run.sh Run script Nov 11, 2016
swarm.tf Preparation for blog Nov 11, 2016
variables.tf Preparation for blog Nov 11, 2016

README.md

do-swarm

Work in progress - still experimental.

The goal is to create a Digital Ocean Docker Swarm.

Prerequisites

Generate a Digital Ocean API token and expose it as a TF_VAR_do_token environment variable:

export TF_VAR_do_token="yourtoken"

Generate a SSH key pair:

ssh-keygen -t rsa -f ./do-key -N ""

The key pair will be generated with do-key and do-key.pub names in the current directory.

Configuration

All configuration items are exposed as Terraform variables in the variables.tf file. Read their description to get their meaning. Most of them have default values.

Creating the swarm

In the local directory, just run:

terraform apply

Using the swarm

To run a command against the Docker Swarm, run, for example:

./connect.sh docker service ls

To run a script file against the Docker Swarm, run, for example:

./run.sh infra.sh

where infra.sh contains for example:

#!/usr/bin/env bash
docker service create \
  --name=visualizer \
  --publish=8081:8080/tcp \
  --constraint=node.role==manager \
  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
  manomarks/visualizer

Appendixes

SSH to the Docker swarm

Run the ./connect.sh script to open a SSH session on the Docker Swarm master.

You can also append some commands to run them directy. For example:

./connect.sh docker service ls