Commit 45280a12 authored by Daniele Valeriani's avatar Daniele Valeriani Committed by John Jarvis

Google lbs

parent f83c21c2
resource "google_compute_forwarding_rule" "fe_forwarding_rule_http" {
name = "gitlab-frontend-http"
project = "${var.project}"
region = "${var.region}"
target = "${google_compute_target_pool.fe_lb_http_pool.self_link}"
load_balancing_scheme = "EXTERNAL"
ports = ["80"]
ip_address = "${google_compute_address.fe_external_ip.address}"
}
resource "google_compute_target_pool" "fe_lb_http_pool" {
project = "${var.project}"
name = "gitlab-frontend-http-pool"
region = "${var.region}"
session_affinity = "NONE"
instances = ["${var.fe_http_instances}"]
health_checks = [
"${google_compute_http_health_check.fe_lb_http_health_check.name}",
]
}
resource "google_compute_http_health_check" "fe_lb_http_health_check" {
project = "${var.project}"
name = "fe_lb_http_health_check"
host = "gitlab.com"
port = "80"
request_path = "/help"
timeout_sec = 2
check_interval_sec = 2
healthy_threshold = 2
unhealthy_threshold = 2
}
resource "google_compute_forwarding_rule" "fe_forwarding_rule_https" {
name = "gitlab-frontend-https"
project = "${var.project}"
region = "${var.region}"
target = "${google_compute_target_pool.fe_lb_https_pool.self_link}"
load_balancing_scheme = "EXTERNAL"
ports = ["443"]
ip_address = "${google_compute_address.fe_external_ip.address}"
}
resource "google_compute_target_pool" "fe_lb_https_pool" {
project = "${var.project}"
name = "gitlab-frontend-https-pool"
region = "${var.region}"
session_affinity = "NONE"
instances = ["${var.fe_https_instances}"]
health_checks = [
"${google_compute_https_health_check.fe_lb_https_health_check.name}",
]
}
resource "google_compute_https_health_check" "fe_lb_https_health_check" {
project = "${var.project}"
name = "fe_lb_https_health_check"
host = "gitlab.com"
port = "443"
request_path = "/help"
timeout_sec = 2
check_interval_sec = 2
healthy_threshold = 2
unhealthy_threshold = 2
}
resource "google_compute_forwarding_rule" "fe_forwarding_rule_ssh" {
name = "gitlab-frontend-ssh"
project = "${var.project}"
region = "${var.region}"
target = "${google_compute_target_pool.fe_lb_ssh_pool.self_link}"
load_balancing_scheme = "EXTERNAL"
ports = ["22"]
ip_address = "${google_compute_address.fe_external_ip.address}"
}
resource "google_compute_target_pool" "fe_lb_ssh_pool" {
project = "${var.project}"
name = "gitlab-frontend-ssh-pool"
region = "${var.region}"
session_affinity = "NONE"
instances = ["${var.fe_ssh_instances}"]
health_checks = [
"${google_compute_health_check.fe_lb_ssh_health_check.name}",
]
}
resource "google_compute_health_check" "fe_lb_ssh_health_check" {
project = "${var.project}"
name = "fe_lb_ssh_health_check"
timeout_sec = 2
check_interval_sec = 2
healthy_threshold = 2
unhealthy_threshold = 2
tcp_health_check {
port = "22"
}
}
resource "google_compute_address" "fe_external_ip" {
name = "http"
project = "${var.project}"
region = "${var.region}"
address_type = "EXTERNAL"
# subnetwork = "${var.subnetwork}"
}
variable "fe_http_instances" {
type = "list"
description = "The list of instances to add to the http backend pool"
}
variable "fe_https_instances" {
type = "list"
description = "The list of instances to add to the https backend pool"
}
variable "fe_ssh_instances" {
type = "list"
description = "The list of instances to add to the ssh backend pool"
}
variable "region" {
type = "string"
description = "The target region"
}
variable "project" {
type = "string"
description = "The target project"
}
# variable "subnetwork" {
# type = "string"
# description = "The target subnetwork"
# }
......@@ -435,6 +435,15 @@ module "external-lb" {
vpc = "${module.network.self_link}"
}
module "google_load_balancers" {
source = "./load-balancers"
project = "${var.project}"
region = "${var.region}"
fe_http_instances = "${module.external-lb.instances_self_link}"
fe_https_instances = "${module.external-lb.instances_self_link}"
fe_ssh_instances = "${module.external-lb.instances_self_link}"
}
##################################
#
# VPN connection to Azure
......
output "instances_self_link" {
# value = "${length(google_compute_instance.instance_without_attached_disk.*.self_link) > 0 ? google_compute_instance.instance_without_attached_disk.*.self_link : google_compute_instance.instance_with_attached_disk.*.self_link}"
value = "${google_compute_instance.instance_without_attached_disk.*.self_link}"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment