2018-10-28 22:17:12 +01:00
|
|
|
# Static IPv4 address for Ingress Load Balancing
|
2018-05-07 08:21:53 +02:00
|
|
|
resource "google_compute_global_address" "ingress-ipv4" {
|
2018-10-28 22:17:12 +01:00
|
|
|
name = "${var.cluster_name}-ingress-ipv4"
|
2018-05-07 08:21:53 +02:00
|
|
|
ip_version = "IPV4"
|
|
|
|
}
|
|
|
|
|
2018-10-28 22:17:12 +01:00
|
|
|
# Static IPv6 address for Ingress Load Balancing
|
|
|
|
resource "google_compute_global_address" "ingress-ipv6" {
|
|
|
|
name = "${var.cluster_name}-ingress-ipv6"
|
|
|
|
ip_version = "IPV6"
|
|
|
|
}
|
|
|
|
|
2018-05-07 08:21:53 +02:00
|
|
|
# Forward IPv4 TCP traffic to the HTTP proxy load balancer
|
|
|
|
# Google Cloud does not allow TCP proxies for port 80. Must use HTTP proxy.
|
2018-10-28 22:17:12 +01:00
|
|
|
resource "google_compute_global_forwarding_rule" "ingress-http-ipv4" {
|
|
|
|
name = "${var.cluster_name}-ingress-http-ipv4"
|
2019-05-28 06:14:25 +02:00
|
|
|
ip_address = google_compute_global_address.ingress-ipv4.address
|
2018-05-07 08:21:53 +02:00
|
|
|
ip_protocol = "TCP"
|
|
|
|
port_range = "80"
|
2019-05-28 06:14:25 +02:00
|
|
|
target = google_compute_target_http_proxy.ingress-http.self_link
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Forward IPv4 TCP traffic to the TCP proxy load balancer
|
2018-10-28 22:17:12 +01:00
|
|
|
resource "google_compute_global_forwarding_rule" "ingress-https-ipv4" {
|
|
|
|
name = "${var.cluster_name}-ingress-https-ipv4"
|
2019-05-28 06:14:25 +02:00
|
|
|
ip_address = google_compute_global_address.ingress-ipv4.address
|
2018-05-07 08:21:53 +02:00
|
|
|
ip_protocol = "TCP"
|
|
|
|
port_range = "443"
|
2019-05-28 06:14:25 +02:00
|
|
|
target = google_compute_target_tcp_proxy.ingress-https.self_link
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
2018-10-28 22:17:12 +01:00
|
|
|
# Forward IPv6 TCP traffic to the HTTP proxy load balancer
|
|
|
|
# Google Cloud does not allow TCP proxies for port 80. Must use HTTP proxy.
|
|
|
|
resource "google_compute_global_forwarding_rule" "ingress-http-ipv6" {
|
|
|
|
name = "${var.cluster_name}-ingress-http-ipv6"
|
2019-05-28 06:14:25 +02:00
|
|
|
ip_address = google_compute_global_address.ingress-ipv6.address
|
2018-10-28 22:17:12 +01:00
|
|
|
ip_protocol = "TCP"
|
|
|
|
port_range = "80"
|
2019-05-28 06:14:25 +02:00
|
|
|
target = google_compute_target_http_proxy.ingress-http.self_link
|
2018-10-28 22:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Forward IPv6 TCP traffic to the TCP proxy load balancer
|
|
|
|
resource "google_compute_global_forwarding_rule" "ingress-https-ipv6" {
|
|
|
|
name = "${var.cluster_name}-ingress-https-ipv6"
|
2019-05-28 06:14:25 +02:00
|
|
|
ip_address = google_compute_global_address.ingress-ipv6.address
|
2018-10-28 22:17:12 +01:00
|
|
|
ip_protocol = "TCP"
|
|
|
|
port_range = "443"
|
2019-05-28 06:14:25 +02:00
|
|
|
target = google_compute_target_tcp_proxy.ingress-https.self_link
|
2018-10-28 22:17:12 +01:00
|
|
|
}
|
|
|
|
|
2018-05-07 08:21:53 +02:00
|
|
|
# HTTP proxy load balancer for ingress controllers
|
|
|
|
resource "google_compute_target_http_proxy" "ingress-http" {
|
2018-08-22 06:59:55 +02:00
|
|
|
name = "${var.cluster_name}-ingress-http"
|
2018-05-07 08:21:53 +02:00
|
|
|
description = "Distribute HTTP load across ${var.cluster_name} workers"
|
2019-05-28 06:14:25 +02:00
|
|
|
url_map = google_compute_url_map.ingress-http.self_link
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# TCP proxy load balancer for ingress controllers
|
|
|
|
resource "google_compute_target_tcp_proxy" "ingress-https" {
|
2018-08-22 06:59:55 +02:00
|
|
|
name = "${var.cluster_name}-ingress-https"
|
|
|
|
description = "Distribute HTTPS load across ${var.cluster_name} workers"
|
2019-05-28 06:14:25 +02:00
|
|
|
backend_service = google_compute_backend_service.ingress-https.self_link
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# HTTP URL Map (required)
|
|
|
|
resource "google_compute_url_map" "ingress-http" {
|
|
|
|
name = "${var.cluster_name}-ingress-http"
|
2018-08-22 06:59:55 +02:00
|
|
|
|
2018-05-07 08:21:53 +02:00
|
|
|
# Do not add host/path rules for applications here. Use Ingress resources.
|
2019-05-28 06:14:25 +02:00
|
|
|
default_service = google_compute_backend_service.ingress-http.self_link
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Backend service backed by managed instance group of workers
|
|
|
|
resource "google_compute_backend_service" "ingress-http" {
|
|
|
|
name = "${var.cluster_name}-ingress-http"
|
|
|
|
description = "${var.cluster_name} ingress service"
|
|
|
|
|
|
|
|
protocol = "HTTP"
|
|
|
|
port_name = "http"
|
|
|
|
session_affinity = "NONE"
|
|
|
|
timeout_sec = "60"
|
|
|
|
|
|
|
|
backend {
|
2019-05-28 06:14:25 +02:00
|
|
|
group = module.workers.instance_group
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 06:14:25 +02:00
|
|
|
health_checks = [google_compute_health_check.ingress.self_link]
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Backend service backed by managed instance group of workers
|
|
|
|
resource "google_compute_backend_service" "ingress-https" {
|
|
|
|
name = "${var.cluster_name}-ingress-https"
|
|
|
|
description = "${var.cluster_name} ingress service"
|
|
|
|
|
|
|
|
protocol = "TCP"
|
|
|
|
port_name = "https"
|
|
|
|
session_affinity = "NONE"
|
|
|
|
timeout_sec = "60"
|
|
|
|
|
|
|
|
backend {
|
2019-05-28 06:14:25 +02:00
|
|
|
group = module.workers.instance_group
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 06:14:25 +02:00
|
|
|
health_checks = [google_compute_health_check.ingress.self_link]
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Ingress HTTP Health Check
|
|
|
|
resource "google_compute_health_check" "ingress" {
|
|
|
|
name = "${var.cluster_name}-ingress-health"
|
|
|
|
description = "Health check for Ingress controller"
|
|
|
|
|
|
|
|
timeout_sec = 5
|
|
|
|
check_interval_sec = 5
|
|
|
|
|
|
|
|
healthy_threshold = 2
|
|
|
|
unhealthy_threshold = 4
|
|
|
|
|
|
|
|
http_health_check {
|
2018-08-22 06:59:55 +02:00
|
|
|
port = 10254
|
2018-05-07 08:21:53 +02:00
|
|
|
request_path = "/healthz"
|
|
|
|
}
|
|
|
|
}
|
2019-05-28 06:14:25 +02:00
|
|
|
|