-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-cluster.tf
198 lines (163 loc) · 6.26 KB
/
dev-cluster.tf
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
variable "project_id" {
description = "Google Cloud project ID."
default = "pi-ostelco-dev"
}
variable "regional" {
description = "whether the cluster should be created in multiple zones or not."
default = true
}
variable "cluster_region" {
default = "europe-west1"
description = "The region where the cluster will be created."
}
variable "cluster_zones" {
default = ["europe-west1-b", "europe-west1-c" , "europe-west1-d"]
description = "The zone(s) where the cluster will be created."
}
variable "cluster_admin_password" {
description = "password for cluster admin. Must be 16 characters at least."
}
# Configure the Google Cloud provider
provider "google-beta" {
project = "${var.project_id}"
region = "${var.cluster_region}"
}
module "gke" {
source = "github.com/ostelco/ostelco-terraform-modules//terraform-google-gke-cluster"
project_id = "${var.project_id}"
cluster_password = "${var.cluster_admin_password}"
cluster_name = "pi-dev"
cluster_description = "Development cluster for Ostelco Pi."
cluster_version = "1.13.6-gke.6"
cluster_zones = "${var.cluster_zones}"
regional = "${var.regional}"
}
module "prime-nodes" {
source = "github.com/ostelco/ostelco-terraform-modules//terraform-google-gke-node-pool"
project_id = "${var.project_id}"
regional = "${var.regional}"
cluster_name = "${module.gke.cluster_name}" # creates implicit dependency
cluster_region = "${var.cluster_region}"
node_pool_name = "prime-nodes"
pool_min_node_count = "1"
initial_node_pool_size = "1"
pool_max_node_count = "3"
node_tags = ["dev", "prime"]
auto_upgrade = true
pool_node_machine_type = "n1-standard-1"
node_labels = {
"target" = "prime"
"machineType" = "n1-standard-1"
"env" = "dev"
}
# oauth_scopes define what Google API nodes in the pool have access to.
# list of APIs can be found here: https://developers.google.com/identity/protocols/googlescopes
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management",
"https://www.googleapis.com/auth/pubsub",
"https://www.googleapis.com/auth/datastore",
"https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/sqlservice.admin",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite",
"https://www.googleapis.com/auth/servicecontrol",
]
}
module "neo4j-nodes" {
source = "github.com/ostelco/ostelco-terraform-modules//terraform-google-gke-node-pool"
project_id = "${var.project_id}"
regional = "${var.regional}"
cluster_name = "${module.gke.cluster_name}" # creates implicit dependency
cluster_region = "${var.cluster_region}"
node_pool_name = "neo4j-nodes"
pool_min_node_count = "1"
initial_node_pool_size = "1"
pool_max_node_count = "3"
node_tags = ["dev", "neo4j"]
auto_upgrade = true
pool_node_machine_type = "n1-standard-2"
node_labels = {
"target" = "neo4j"
"machineType" = "n1-standard-2"
"env" = "dev"
}
# oauth_scopes define what Google API nodes in the pool have access to.
# list of APIs can be found here: https://developers.google.com/identity/protocols/googlescopes
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management",
"https://www.googleapis.com/auth/pubsub",
"https://www.googleapis.com/auth/datastore",
"https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/sqlservice.admin",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite",
"https://www.googleapis.com/auth/servicecontrol",
]
}
module "utilities-nodes" {
source = "github.com/ostelco/ostelco-terraform-modules//terraform-google-gke-node-pool"
project_id = "${var.project_id}"
regional = "${var.regional}"
cluster_name = "${module.gke.cluster_name}" # creates implicit dependency
cluster_region = "${var.cluster_region}"
node_pool_name = "utilities-nodes"
pool_min_node_count = "1"
initial_node_pool_size = "1"
pool_max_node_count = "3"
node_tags = ["dev", "utilities"]
auto_upgrade = true
pool_node_machine_type = "n1-standard-1"
node_labels = {
"target" = "utilities"
"machineType" = "n1-standard-1"
"env" = "dev"
}
# oauth_scopes define what Google API nodes in the pool have access to.
# list of APIs can be found here: https://developers.google.com/identity/protocols/googlescopes
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/service.management",
]
}
resource "google_compute_address" "static_ambassador_ip" {
provider = "google-beta"
name = "ambassador-static-ip"
description = "A static external IP for dev Ambassador LB"
}
output "dev_cluster_ambassador_ip" {
sensitive = true
value = "${google_compute_address.static_ambassador_ip.address}"
}
output "dev_cluster_endpoint" {
sensitive = true
value = "${module.gke.cluster_endpoint}"
}
output "dev_cluster_client_certificate" {
sensitive = true
value = "${module.gke.cluster_client_certificate}"
}
output "dev_cluster_client_key" {
sensitive = true
value = "${module.gke.cluster_client_key}"
}
output "dev_cluster_ca_certificate" {
sensitive = true
value = "${module.gke.cluster_ca_certificate}"
}
# the backend config for storing terraform state in GCS
# requires setting GOOGLE_CREDNETIALS to contain the path to your Google Cloud service account json key.
terraform {
backend "gcs" {
bucket = "pi-ostelco-dev-terraform-state"
prefix = "clusters/dev/state"
}
}