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.
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
Download template into desired project repository:
git clone https://github.com/Storidge/terraform-do-swarm-cio.git
Initiate terraform:
terraform init
Add credentials file terraform.tfvars
:
cd terraform-do-swarm-cio
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:
terraform plan
If there are no errors, run the following command to build infrastructure:
terraform apply
Use the ssh key defined in terraform.tfvars
to access the cluster.
Check current infrastructure state:
terraform show terraform.tfstate
If the infrastructure has been changed outside terraform, update the state information:
terraform refresh
Download and set up here
List all droplets:
doctl compute droplet list
List all images:
doctl compute image list
Locate master node public IP and ssh to it:
ssh root@public_IP
Under variables.tf
, change the default
value under variable "swarm_worker_count"
(minimum 2):
variable "swarm_worker_count" {
default = "4"
}
Apply terraform changes:
terraform init
...
terraform plan
...
terraform apply
To terminate the cluster run:
terraform destroy