-
Notifications
You must be signed in to change notification settings - Fork 4
/
health_check.tf
118 lines (110 loc) · 4.55 KB
/
health_check.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
# health check
resource "google_compute_region_health_check" "health_check" {
name = "${var.prefix}-${var.cluster_name}-health-check"
region = var.region
timeout_sec = 1
check_interval_sec = 1
healthy_threshold = 4
unhealthy_threshold = 5
http_health_check {
port = "14000"
request_path = "/api/v2/healthcheck"
}
}
# backend service
resource "google_compute_region_backend_service" "backend_service" {
name = "${var.prefix}-${var.cluster_name}-lb-backend"
region = var.region
protocol = "TCP"
load_balancing_scheme = "INTERNAL"
health_checks = [google_compute_region_health_check.health_check.id]
network = data.google_compute_network.this[0].self_link
backend {
group = google_compute_instance_group.this.self_link
balancing_mode = "CONNECTION"
}
depends_on = [module.network, module.shared_vpc_peering, google_compute_instance_group.this]
}
# forwarding rule
resource "google_compute_forwarding_rule" "google_compute_forwarding_rule" {
name = "${var.prefix}-${var.cluster_name}-forwarding-rule"
backend_service = google_compute_region_backend_service.backend_service.id
region = var.region
load_balancing_scheme = "INTERNAL"
all_ports = true
allow_global_access = var.lb_allow_global_access
network = data.google_compute_network.this[0].self_link
subnetwork = data.google_compute_subnetwork.this[0].self_link
labels = {
goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh"
}
lifecycle {
ignore_changes = [network, subnetwork]
}
depends_on = [module.network, module.shared_vpc_peering, data.google_compute_network.this]
}
resource "google_dns_record_set" "record_a" {
name = "${var.cluster_name}.${local.private_dns_name}"
project = local.dns_zone_project_id
managed_zone = local.private_zone_name
type = "A"
ttl = 120
rrdatas = [google_compute_forwarding_rule.google_compute_forwarding_rule.ip_address]
depends_on = [google_compute_region_backend_service.backend_service, google_compute_forwarding_rule.google_compute_forwarding_rule]
}
# =================== ui lb ===============================
# health check
resource "google_compute_region_health_check" "ui_check" {
name = "${var.prefix}-${var.cluster_name}-ui-check"
region = var.region
timeout_sec = 1
check_interval_sec = 1
healthy_threshold = 4
unhealthy_threshold = 5
http_health_check {
port = "14000"
request_path = "/api/v2/ui/healthcheck"
}
depends_on = [module.network]
}
# backend service
resource "google_compute_region_backend_service" "ui_backend_service" {
name = "${var.prefix}-${var.cluster_name}-ui-lb-backend"
region = var.region
protocol = "TCP"
load_balancing_scheme = "INTERNAL"
health_checks = [google_compute_region_health_check.ui_check.id]
network = data.google_compute_network.this[0].self_link
backend {
group = google_compute_instance_group.this.self_link
balancing_mode = "CONNECTION"
}
depends_on = [module.network, module.shared_vpc_peering, google_compute_instance_group.this]
}
# forwarding rule
resource "google_compute_forwarding_rule" "ui_forwarding_rule" {
name = "${var.prefix}-${var.cluster_name}-ui-forwarding-rule"
backend_service = google_compute_region_backend_service.ui_backend_service.id
region = var.region
load_balancing_scheme = "INTERNAL"
all_ports = true
allow_global_access = var.lb_allow_global_access
network = data.google_compute_network.this[0].self_link
subnetwork = data.google_compute_subnetwork.this[0].self_link
labels = {
goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh"
}
lifecycle {
ignore_changes = [network, subnetwork]
}
depends_on = [module.network, module.shared_vpc_peering]
}
resource "google_dns_record_set" "ui_record_a" {
name = "ui-${var.cluster_name}.${local.private_dns_name}"
project = local.dns_zone_project_id
managed_zone = local.private_zone_name
type = "A"
ttl = 120
rrdatas = [google_compute_forwarding_rule.ui_forwarding_rule.ip_address]
depends_on = [google_compute_region_backend_service.ui_backend_service, google_compute_forwarding_rule.ui_forwarding_rule]
}