https://github.com/containersolutions/terraform-nomad
Terraform scripts for creating a Nomad cluster on Google Cloud.
https://github.com/containersolutions/terraform-nomad
Last synced: about 1 year ago
JSON representation
Terraform scripts for creating a Nomad cluster on Google Cloud.
- Host: GitHub
- URL: https://github.com/containersolutions/terraform-nomad
- Owner: ContainerSolutions
- Created: 2015-10-08T08:31:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-30T13:06:28.000Z (over 10 years ago)
- Last Synced: 2025-02-15T03:29:08.585Z (over 1 year ago)
- Language: HCL
- Size: 8.79 KB
- Stars: 15
- Watchers: 7
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Container Solutions Terraform Nomad
How to set up a Nomad cluster on the Google Cloud using Terraform
### Install Terraform
* These scripts require Terraform 0.6.3 or greater
* Follow the instructions on to set up Terraform on your machine.
### Get your Google Cloud JSON Key
- Visit https://console.developers.google.com
- Navigate to APIs & Auth -> Credentials -> Service Account -> Generate new JSON key
- The file will be downloaded to your machine
### Get Google Cloud SDK
- Visit https://cloud.google.com/sdk/
- Install the SDK, login and authenticate with your Google Account.
### 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 the`variables.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