All Projects → stefanprodan → scaleway-swarm-terraform

stefanprodan / scaleway-swarm-terraform

Licence: MIT license
Setup a Docker Swarm Cluster on Scaleway with Terraform

Programming Languages

HCL
1544 projects
shell
77523 projects
Smarty
1635 projects
Makefile
30231 projects

Projects that are alternatives of or similar to scaleway-swarm-terraform

kaabah
A Terraform solution to design, build and operate Docker Swarm infrastructures
Stars: ✭ 29 (-39.58%)
Mutual labels:  swarm, scaleway
docker-system-prune
Docker system prune automatically
Stars: ✭ 20 (-58.33%)
Mutual labels:  swarm
Fabricio
Docker deploy automation tool
Stars: ✭ 250 (+420.83%)
Mutual labels:  swarm
bee-docs
Documentation for the Swarm Bee Client. View at docs.ethswarm.org, contributions welcome!
Stars: ✭ 35 (-27.08%)
Mutual labels:  swarm
tool-db
A peer-to-peer decentralized database
Stars: ✭ 15 (-68.75%)
Mutual labels:  swarm
generator-mitosis
A micro-service infrastructure generator based on Yeoman/Chatbot, Kubernetes/Docker Swarm, Traefik, Ansible, Jenkins, Spark, Hadoop, Kafka, etc.
Stars: ✭ 78 (+62.5%)
Mutual labels:  swarm
Raspi Cluster
Notes and scripts for setting up (yet another) Raspberry Pi computing cluster
Stars: ✭ 235 (+389.58%)
Mutual labels:  swarm
research
Shared learning of decentralized development.
Stars: ✭ 26 (-45.83%)
Mutual labels:  swarm
traefik-ondemand-service
Traefik ondemand service for the traefik ondemand plugin
Stars: ✭ 35 (-27.08%)
Mutual labels:  swarm
multi uav simulator
A quadrotor swarm simulator based on ROS (Robot Operating System).
Stars: ✭ 73 (+52.08%)
Mutual labels:  swarm
microservices-with-docker
Building a microservice system with Docker (Swarm & Kubernetes)
Stars: ✭ 19 (-60.42%)
Mutual labels:  swarm
erebos
JavaScript client and CLI for Swarm
Stars: ✭ 47 (-2.08%)
Mutual labels:  swarm
dapps.earth
Source code for dapps.earth: IPFS and Swarm gateway
Stars: ✭ 12 (-75%)
Mutual labels:  swarm
docker-examples-edition2
Examples pour edition 2 Docker Dunod
Stars: ✭ 16 (-66.67%)
Mutual labels:  swarm
ansible-role-etcd
Ansible role for installing etcd cluster
Stars: ✭ 38 (-20.83%)
Mutual labels:  scaleway
Funker
Functions as Docker containers
Stars: ✭ 244 (+408.33%)
Mutual labels:  swarm
swanager
A high-level Docker Services management tool built on top of Swarm
Stars: ✭ 12 (-75%)
Mutual labels:  swarm
beekeeper
Swarm Beekeeper is an orchestrator that can manage a cluster of Bee nodes and call into their API. It allows various scenario’s to be performed on these nodes. The Swarm team uses Beekeeper internally for integration tests.
Stars: ✭ 51 (+6.25%)
Mutual labels:  swarm
microservices-demo
A Monorepo Demoing Microservices Architecture
Stars: ✭ 36 (-25%)
Mutual labels:  swarm
PainlessDocker
Painless Docker book git repository.
Stars: ✭ 17 (-64.58%)
Mutual labels:  swarm

scaleway-swarm-terraform

Automating Docker Swarm cluster operations with Terraform Scaleway provider.

Initial setup

Clone the repository and install the dependencies:

$ git clone https://github.com/stefanprodan/scaleway-swarm-terraform.git
$ cd scaleway-swarm-terraform

# requires brew
$ make init

Running make init will install Terraform and jq using Homebrew and will pull the required Terraform modules. If you are on linux, after installing Terraform and jq packages, run terraform init. Note that you'll need Terraform v0.10 or newer to run this project.

Before running the project you'll have to create an access token for Terraform to connect to the Scaleway API. Using the token and your access key, create two environment variables:

$ export SCALEWAY_ORGANIZATION="<ACCESS-KEY>"
$ export SCALEWAY_TOKEN="<ACCESS-TOKEN>" 

Usage

Create a Docker Swarm Cluster with one manager and two workers:

# create a workspace
terraform workspace new dev

# generate plan
terraform plan

# run the plan
terraform apply 

This will do the following:

  • reserves public IPs for each node
  • creates a security group for the manager node allowing SSH and HTTP/S inbound traffic
  • creates a security group for the worker nodes allowing SSH inbound traffic
  • provisions three VC1S servers with Ubuntu 16.04 LTS and Rancher boot script
  • starts the manager node and installs Docker CE using the local SSH agent
  • customizes the Docker daemon systemd config by enabling the experimental features and the metrics endpoint
  • initializes the manager node as Docker Swarm manager and extracts the join tokens
  • starts the worker nodes in parallel and setups Docker CE the same as on the manager node
  • joins the worker nodes in the cluster using the manager node private IP

The naming convention for a swarm node is in <WORKSPACE>-<ROLE>-<INDEX> format, running the project on workspace dev will create 3 nodes: dev-manager-1, dev-worker-1, dev-worker-2. If you don't create a workspace then you'll be running on the default one and your nods prefix will be default. You can have multiple workspaces, each with it's own state, so you can run in parallel different Docker Swarm clusters.

Customizing the cluster specs via terraform variables:

terraform apply \
-var docker_version=17.06.0~ce-0~ubuntu \
-var region=ams1 \
-var manager_instance_type=VC1S \
-var worker_instance_type=VC1S \
-var worker_instance_count=2

You can scale up or down the Docker Swarm Cluster by modifying the worker_instance_count. On scale up, all new nodes will join the current cluster. When you scale down the workers, Terraform will first drain the node and remove it from the swarm before destroying the resources.

After running the Terraform plan you'll see several output variables like the Swarm tokes, the private and public IPs of each node and the current workspace. You can use the manager public IP variable to connect via SSH and lunch a service within the Swarm.

$ ssh root@$(terraform output swarm_manager_public_ip)

root@dev-manager-1:~# docker service create \
    --name nginx -dp 80:80 \
    --replicas 2 \
    --constraint 'node.role == worker' nginx

$ curl $(terraform output swarm_manager_public_ip)

You could also expose the Docker engine remote API and metrics endpoint on the public IP by running:

terraform apply -var docker_api_ip="0.0.0.0"

If you chose to do so, you should allow access to the API only from your IP. You'll have to add a security group rule for ports 2375 and 9323 to the managers and workers groups.

Test your settings by calling the API and metrics endpoint:

$ curl $(terraform output swarm_manager_public_ip):2375/containers/json

$ curl $(terraform output swarm_manager_public_ip):9323/metrics

Tear down the whole infrastructure with:

terraform destroy -force

Please see my blog post for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].