Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 1edb07a

Browse files
committed
Add root example README. Fix colocated cluster example.
1 parent 39cb278 commit 1edb07a

9 files changed

+47
-9
lines changed

_docs/architecture-colocated.png

455 KB
Loading
485 KB
Loading

_docs/architecture.png

444 KB
Loading

examples/nomad-consul-separate-cluster/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-c
3232
1. Make sure your local environment is authenticated to Google Cloud.
3333
1. Open `variables.tf` and fill in any variables that don't have a default, including putting your Goolge Image ID into
3434
the `vault_source_image` and `consul_server_source_image` variables.
35-
1. Run `terraform get`.
35+
1. Run `terraform init`.
3636
1. Run `terraform plan`.
3737
1. If the plan looks good, run `terraform apply`.
38-
1. Run the [nomad-examples-helper.sh script](
38+
1. From the same directoy where you ran `terraform apply`, run the [nomad-examples-helper.sh script](
3939
https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-examples-helper/nomad-examples-helper.sh)
4040
to print out the IP addresses of the Nomad servers and some example commands you can run to interact with the cluster:
4141
`../nomad-examples-helper/nomad-examples-helper.sh`.

examples/root-example/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Nomad and Consul Co-located Cluster Example
2+
3+
This folder shows an example of Terraform code to deploy a [Nomad](https://www.nomadproject.io/) cluster co-located
4+
with a [Consul](https://www.consul.io/) cluster in [Google Cloud](https://cloud.google.com/) (if you want to run Nomad
5+
and Consul on separate clusters, see the [nomad-consul-separate-cluster example](
6+
https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-consul-separate-cluster) instead). The
7+
cluster consists of two Manged Instance Groups: one with a small number of Nomad and Consul server nodes, which are
8+
responsible for being part of the [consensus protocol](https://www.nomadproject.io/docs/internals/consensus.html), and
9+
one with an arbitrary number of Nomad and Consul client nodes, which are used to run jobs:
10+
11+
![Nomad architecture](https://github.com/hashicorp/terraform-google-nomad/master/_docs/architecture-nomad-consul-colocated.png?raw=true)
12+
13+
You will need to create a [Google Image](https://cloud.google.com/compute/docs/images) that has Nomad and Consul
14+
installed, which you can do using the [nomad-consul-image example](
15+
https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-consul-image)).
16+
17+
For more info on how the Nomad cluster works, check out the [nomad-cluster](
18+
https://github.com/hashicorp/terraform-google-nomad/tree/master/modules/nomad-cluster) documentation.
19+
20+
## Quick start
21+
22+
To deploy a Nomad Cluster:
23+
24+
1. `git clone` this repo to your computer.
25+
1. Build a Nomad and Consul Image. See the [nomad-consul-image example](
26+
https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-consul-image) documentation for
27+
instructions. Make sure to note down the name of the Image.
28+
1. Install [Terraform](https://www.terraform.io/).
29+
1. Make sure your local environment is authenticated to Google Cloud.
30+
1. Open `variables.tf` and fill in any variables that don't have a default, including putting your Goolge Image ID into
31+
the `vault_source_image` and `consul_server_source_image` variables.
32+
1. Run `terraform init`.
33+
1. Run `terraform plan`.
34+
1. If the plan looks good, run `terraform apply`.
35+
1. From the same directoy where you ran `terraform apply`, run the [nomad-examples-helper.sh script](
36+
https://github.com/hashicorp/terraform-google-nomad/tree/master/examples/nomad-examples-helper/nomad-examples-helper.sh)
37+
to print out the IP addresses of the Nomad servers and some example commands you can run to interact with the cluster:
38+
`../nomad-examples-helper/nomad-examples-helper.sh`.

examples/root-example/startup-script-nomad-client.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ set -e
1010
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
1111

1212
# These variables are passed in via Terraform template interplation
13-
/opt/consul/bin/run-consul --client --cluster-tag-key "${cluster_tag_key}" --cluster-tag-value "${cluster_tag_value}"
13+
/opt/consul/bin/run-consul --client --cluster-tag-name "${consul_server_cluster_tag_name}"
1414
/opt/nomad/bin/run-nomad --client

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module "nomad_and_consul_servers" {
3838
cluster_tag_name = "${var.nomad_consul_server_cluster_name}"
3939
machine_type = "${var.nomad_consul_server_cluster_machine_type}"
4040

41-
source_image = "${var.nomad_server_source_image}"
41+
source_image = "${var.nomad_consul_server_source_image}"
4242
startup_script = "${data.template_file.startup_script_nomad_consul_server.rendered}"
4343

4444
# WARNING!

outputs.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ output "gcp_zone" {
66
value = "${var.gcp_zone}"
77
}
88

9-
output "nomad_consul_server_cluster_size" {
9+
output "nomad_server_cluster_size" {
1010
value = "${var.nomad_consul_server_cluster_size}"
1111
}
1212

1313
output "nomad_client_cluster_size" {
1414
value = "${var.nomad_client_cluster_size}"
1515
}
1616

17-
output "nomad_consul_server_cluster_tag_name" {
17+
output "nomad_server_cluster_tag_name" {
1818
value = "${var.nomad_consul_server_cluster_name}"
1919
}
2020

2121
output "nomad_client_cluster_tag_name" {
2222
value = "${var.nomad_client_cluster_name}"
2323
}
2424

25-
output "nomad_consul_server_instance_group_id" {
25+
output "nomad_server_instance_group_id" {
2626
value = "${module.nomad_and_consul_servers.instance_group_name}"
2727
}
2828

variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ variable "nomad_consul_server_cluster_name" {
2121
description = "The name of the Nomad/Consul Server cluster. All resources will be namespaced by this value. E.g. nomad-server-prod"
2222
}
2323

24-
variable "nomad_server_source_image" {
24+
variable "nomad_consul_server_source_image" {
2525
description = "The Google Image used to launch each node in the Nomad/Consul Server cluster."
2626
}
2727

@@ -56,7 +56,7 @@ variable "nomad_consul_server_cluster_machine_type" {
5656

5757
variable "nomad_client_cluster_size" {
5858
description = "The number of nodes to have in the Nomad client cluster. This number is arbitrary."
59-
default = 2
59+
default = 3
6060
}
6161

6262
variable "nomad_client_machine_type" {

0 commit comments

Comments
 (0)