All Projects → ContainerSolutions → terraform-nomad

ContainerSolutions / terraform-nomad

Licence: other
Terraform scripts for creating a Nomad cluster on Google Cloud.

Programming Languages

HCL
1544 projects
shell
77523 projects

Container Solutions Terraform Nomad

How to set up a Nomad cluster on the Google Cloud using Terraform

Install Terraform

Get your Google Cloud JSON Key

Get Google Cloud SDK

Add your SSH key to the Project Metadata

  • Back in the Developer Console, go to Compute - Compute Engine - Metadata and click the SSH Keys tab. Add your public SSH key there.
  • Use the path to the private key and the username in the next step as gce_ssh_user and gce_ssh_private_key_file

Prepare variables.tf

Copy thevariables.tf.example file to varables.tf and adjust to your situation

Create Terraform plan

Create the plan and save it to a file.

terraform plan -out my.plan

Create the cluster

Once you are satisfied with the plan, apply it.

terraform apply my.plan

Start nomad on every node

Log in to every node. There is a default server.hcl there, copied from the resources dir, that you can use to start the node. Start the agent, specifying the address of eth0 to bind to.

sudo nomad agent -config server.hcl -bind=10.11.12.4

Execute this on every node, the agent needs to be running on all of them.

Join the nodes

From one of the nodes, connect to the others.

nomad server-join -address http://$OTHER_SERVER:4646 $MYADDRESS

You should see the node joining in the logs. Repeat this step for all nodes in the cluster.

Set environment variable

To be able to reach the agent, export the NOMAD_ADDR variable.

export NOMAD_ADDR="http://nomad1:4646"

Destroy the cluster

When you're done, clean up the cluster with

terraform destroy

To do

  • Automate starting of nomad daemon
  • Discover other nodes
  • Automating joining of other nodes
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].