-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.hcl
138 lines (114 loc) · 2.56 KB
/
cluster.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Network
network "cloud" {
subnet = "10.5.0.0/16"
}
# Variables
variable "client_nodes" {
default = 0
description = "Nomad agent will run in both client and server mode"
}
variable "nomad_version" {
default = "1.4.0"
description = "Nomad docker image version"
}
# All templates
template "consul_client_config" {
source = <<-EOS
datacenter = "dc1"
retry_join = ["consul.container.shipyard.run"]
EOS
destination = "${data("consul-config")}/client.hcl"
}
template "consul_server_config" {
source = <<-EOS
data_dir = "/tmp/"
log_level = "DEBUG"
datacenter = "dc1"
primary_datacenter = "dc1"
server = true
bootstrap_expect = 1
ui = true
bind_addr = "0.0.0.0"
client_addr = "0.0.0.0"
ports {
grpc = 8502
}
connect {
enabled = true
}
EOS
destination = "${data("consul-config")}/server.hcl"
}
template "nomad_client_config" {
source = <<-EOS
plugin "docker" {
config {
allow_privileged = true
}
}
EOS
destination = "${data("nomad-config")}/client.hcl"
}
container "consul" {
image {
name = "consul:1.14.7"
}
command = ["consul", "agent", "-config-file=/config/config.hcl"]
volume {
source = "${data("consul-config")}/server.hcl"
destination = "/config/config.hcl"
}
network {
name = "network.cloud"
}
}
# Consul ingress
container_ingress "consul-http" {
target = "container.consul"
port {
local = 8500
remote = 8500
host = 18500
}
network {
name = "network.cloud"
}
}
# Nomad Cluster
nomad_cluster "dev" {
client_nodes = "${var.client_nodes}"
version = "${var.nomad_version}"
network {
name = "network.cloud"
}
image {
name = "consul:1.14.7"
}
client_config = "${data("nomad-config")}/client.hcl"
consul_config = "${data("consul-config")}/client.hcl"
volume {
source = "${data("nomad-config")}/etc/nomad.d/data"
destination = "/etc/nomad.d/data"
bind_propagation = "shared"
}
volume {
source = "${data("nomad-config")}/var/lib/nomad"
destination = "/var/lib/nomad"
bind_propagation = "shared"
}
# Required for Kadalu CSI to use Gluster Native quota capabilities
volume {
source = "/root/.ssh/id_rsa"
destination = "/root/.ssh/id_rsa"
read_only = true
}
}
# Example nomad job to verify 'privileged' mode and 'consul' integration
nomad_job "example" {
cluster = "nomad_cluster.dev"
depends_on = ["nomad_cluster.dev"]
paths = ["./example.nomad"]
}
output "NOMAD_ADDR" {
value = "${cluster_api("nomad_cluster.dev")}"
}