forked from dm-academy/node-svc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
59 lines (48 loc) · 1.46 KB
/
main.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
# per https://www.terraform.io/docs/providers/google/r/container_cluster.html,
# logging service "Defaults to logging.googleapis.com/kubernetes"
# monitoring service "Defaults to monitoring.googleapis.com/kubernetes"
# which is why we see fluentd, prometheus, etc pods
resource "google_container_cluster" "primary" {
name = "node-svc-k8s"
location = "us-central1-c"
initial_node_count = 3
master_auth {
username = ""
password = ""
client_certificate_config {
issue_client_certificate = false
}
}
# configure kubectl to talk to the cluster
provisioner "local-exec" {
command = "gcloud container clusters get-credentials ${var.cluster_name} --zone ${var.zone} --project ${var.project_id}"
}
node_config {
preemptible = true
machine_type = "e2-micro"
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
metadata = {
disable-legacy-endpoints = "true"
}
tags = ["node-svc-k8s"]
}
timeouts {
create = "30m"
update = "40m"
}
}
# create firewall rule to allow access to application
resource "google_compute_firewall" "nodeports" {
name = "node-port-range"
network = "default"
allow {
protocol = "tcp"
ports = ["30000-32767"]
}
source_ranges = ["0.0.0.0/0"]
}