项目作者: Storidge

项目描述 :
Deploy Storidge cluster on DigitalOcean with Terraform - configures Swarm cluster with Portainer dashboard
高级语言: HCL
项目地址: git://github.com/Storidge/terraform-do-swarm-cio.git
创建时间: 2018-05-03T20:32:14Z
项目社区:https://github.com/Storidge/terraform-do-swarm-cio

开源协议:Apache License 2.0

下载


Terraform Template for Digital Ocean Swarm with Storidge CIO

This repo contains a Terraform project for generating and managing clusters of DO droplets with the community edition of the Storidge CIO software.

The terraform code will look for a Digital Ocean image to launch the cloud instances. This image can be easily created by following the steps in the packer-cio repo.

Configuration

Default cluster configuration (can be altered in the variables.tf, droplets.tf, and volumes.tf files):

  • 1 Swarm Master Node
    • 2GB droplet
    • 3 20GB storage drives
  • 4 Swarm Worker Nodes
    • 2 GB droplets
    • 3 20GB storage drives on each worker
  • Default cluster region: sfo2

Usage

Set-Up

Download Terraform

Download template into desired project repository:

  1. git clone https://github.com/Storidge/terraform-do-swarm-cio.git

Initiate terraform:

  1. terraform init

Add credentials file terraform.tfvars:

  1. cd terraform-do-swarm-cio
  2. cp terraform.tfvars.template terraform.tfvars

Add your DO API token and ssh key information to terraform.tfvars.

Update variables.tf with correct DO image and region.

To verify your configuration will work run:

  1. terraform plan

Deploy cluster

If there are no errors, run the following command to build infrastructure:

  1. terraform apply

Use the ssh key defined in terraform.tfvars to access the cluster.

Update state

Check current infrastructure state:

  1. terraform show terraform.tfstate

If the infrastructure has been changed outside terraform, update the state information:

  1. terraform refresh

Access droplets, images, and cluster through doctl CLI

Download and set up here

List all droplets:

  1. doctl compute droplet list

List all images:

  1. doctl compute image list

Locate master node public IP and ssh to it:

  1. ssh root@public_IP

Scale cluster up/down

Under variables.tf, change the default value under variable "swarm_worker_count" (minimum 2):

  1. variable "swarm_worker_count" {
  2. default = "4"
  3. }

Apply terraform changes:

  1. terraform init
  2. ...
  3. terraform plan
  4. ...
  5. terraform apply

Terminate cluster

To terminate the cluster run:

  1. terraform destroy