Work in progress - still experimental.
The goal is to create a Digital Ocean Docker Swarm.
Generate a Digital Ocean API key and expose it as a TF_VAR_do_token
environment variable.
Generate a SSH key pair - your can use the do-key.sh
script. The key pair will be generated with do-key
and
do-key.pub
names in the current directory.
At the time of writing, Digital Ocean does not provide yet a ready-to-go image for Docker 1.13, only for Docker 1.12.
See the appendixes below to build your custom image with Packer.
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.
In the local directory, just run:
terraform apply
Export your Digital Ocean token:
export DIGITALOCEAN_API_TOKEN=[...]
and run:
packer build -machine-readable \
packer-ubuntu-docker.json \
| tee packer-ubuntu-docker.log
The region to create the image into is set to fra1
by default, but you
can change it by adding the following command line option:
-var 'do_region=...'
The packer-ubuntu-docker.log
file contains the snapshot ID at the end, for
example:
1485200429,,ui,say,--> digitalocean: A snapshot was created: 'docker-13' (ID: 22364942) in region 'fra1'
Export it using:
export TF_VAR_do_image=[...]
Run the ./do-swarm.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