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 init.sh
script. The key pair will be generated with do-key
and
do-key.pub
names in the current directory.
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
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
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