Scripts to create and manage a Docker Swarm cluster on Google Cloud Platform.
- Make sure you create a Google Cloud Project
- You need to enable Google Cloud Deployment Manager V2 API using this link.
- Also add server-to-server credentials json file in the keys folder with project name as json file name
example:
project name = projectxyz-app
credentials file should be saved like this
keys/projectxyz-app.json
Login:
$ gcloud init
./swarm-up.sh
Choose the project
By default, this will create a cluster with one manager and two workers. You can edit this and more options in the options.yaml file.
./swarm-down.sh
Choose the project
./swarm-resize.sh <NUM_WORKERS>
Choose the project
Edit the options.yaml file to specify your options.
- Cluster Configuration Options
prefix
= All nodes in the Swarm will start with this Prefix. This allows you to have multiple Swarms in the same project.zone
= Google Cloud Zone for the nodes - default: us-central1-f
- Manager Options
manager_machine_type
= Google Cloud Machine Type for the Manager nodes - default: n1-standard-1manager_disk
= Disk size in GB for the Manager nodes - default: 100
- Worker Options
num
= Number of Workers for the Cluster - default: 2worker_machine_type
= Google Cloud Machine Type for the Worker nodes - default: n1-standard-1worker_disk
= Disk size in GB for the Worker nodes - default: 100
These scripts are simple wrappers around a set of Deployment Manager templates.
It launches a VM for the Swarm Manager, and a Managed Instance Group for the workers.
This allows you to dynamically scale the number of workers as well as easily create Network Load Balancers that target the worker nodes.
Docker-Machine is used to connect to the Manager node over a secure TLS connection
- This is not an official Google product
- This is not an official Docker product
- Only tested on OSX
#!/usr/bin/env bash
for i in $(docker node ls --format {{.Hostname}} -f role=worker);
do
docker node promote ${i};
done
- More control