This project contains Terraform templates to help you deploy Lattice on DigitalOcean.
- A DigitalOcean account
- A DigitalOcean API Token
- A DigitalOcean Password-less SSH Key
- A DigitalOcean Region supporting private networking (all regions except
sfo1
)
Here are some step-by-step instructions for configuring a Lattice cluster via Terraform:
- Visit the Lattice GitHub Releases page
- Select the Lattice version you wish to deploy and download the Terraform example file for your target platform. The filename will be
lattice.digitalocean.tf
- Create an empty folder and place the
lattice.digitalocean.tf
file in that folder. - Update the
lattice.digitalocean.tf
by filling in the values for the variables. Details for the values of those variables are below.
The available variables that can be configured are:
do_token
: Digital Ocean API tokendo_ssh_public_key_id
: SSH public key id. Key ID of your uploaded SSH key.do_ssh_private_key_file
: Path to the SSH private key filedo_region
: The DO region to operate under (defaultnyc2
)do_image
: The droplet image ID or slug to base the launched instances (defaultubuntu-14-04-x64
)do_size_brain
: The DO size to use for the Lattice Brain instance (default512mb
)do_size_cell
: The DO size to use for the Lattice Cell instances (default2gb
)num_cells
: The number of Lattice Cells to launch (default3
)lattice_username
: Lattice username (defaultuser
)lattice_password
: Lattice password (defaultpass
)
Refer to the Terraform DigitalOcean (DO) provider documentation for more details about how to configure the proper credentials.
You can get the key ID by executing an API call against the Digital Ocean API. More info can found on the DigitalOcean API Reference. The token needed for the Authorization: Bearer
header is the same as the DigitalOcean API Token referenced in the Prerequisites.
Here are some step-by-step instructions for deploying a Lattice cluster via Terraform:
- Run the following commands in the folder containing the
lattice.digitalocean.tf
file
terraform get -update
terraform apply
This will deploy the cluster.
Upon success, terraform will print the Lattice target:
Outputs:
lattice_target = x.x.x.x.xip.io
lattice_username = xxxxxxxx
lattice_password = xxxxxxxx
which you can use with the Lattice CLI to ltc target x.x.x.x.xip.io
.
Terraform will generate a terraform.tfstate
file. This file describes the cluster that was built - keep it around in order to modify/tear down the cluster.
Refer to the Lattice CLI documentation.
Destroy the cluster:
terraform destroy
When working with Digital Ocean, terraform sometimes gets into an inconsistent state. It is common for the "terraform apply" command to time out while provisioning the VMs, and subsequent terraform commands will then error out. In some cases, a droplet will get stuck in the "New" status (not getting to "Active"), and all Digital Ocean API commands will return:
* Error deleting droplet: Error destroying droplet: API Error: unprocessable_entity: Droplet already has a pending event.
In the event this happens, the recommended avenue is to use the Digital Ocean console to tear down all the droplets, remove the terraform.tfstate file from the current directory, and then run "terraform apply" again to provision from scratch.
The provided examples (i.e., lattice.digitalocean.tf
) are pinned to a specific Bump commit or release tag in order to maintain compatibility between the Lattice build (lattice.tgz
) and the Terraform definitions. Currently, Terraform does not automatically update to newer revisions of Lattice.
If you want to update to the latest version of Lattice:
- Update the
ref
in thesource
directive of yourlattice.digitalocean.tf
tomaster
. - Run
terraform get -update
to update the modules under the.terraform/
folder.
If you want to update to a specific version of Lattice:
- Choose a version from either the Bump commits or Releases.
- Update the
ref
in thesource
directive of yourlattice.digitalocean.tf
to that version. - Run
terraform get -update
to update the modules under the.terraform/
folder.
See LICENSE for details. Copyright (c) 2015 Pivotal Software, Inc.