Commit 59ce02dc authored by John Jarvis's avatar John Jarvis

Adds prometheus and performance.

parent f3b2f687
......@@ -467,11 +467,60 @@ module "consul" {
##################################
#
# Monitoring (prometheus)
# Monitoring
#
##################################
module "monitoring" {
resource "google_compute_subnetwork" "monitoring" {
name = "${format("monitoring-%v", var.environment)}"
network = "${module.network.self_link}"
project = "${var.project}"
region = "${var.region}"
ip_cidr_range = "${var.subnetworks["monitoring"]}"
private_ip_google_access = true
}
resource "google_compute_firewall" "monitoring" {
name = "${format("monitoring-%v", var.environment)}"
network = "${module.network.self_link}"
allow {
protocol = "tcp"
ports = ["${var.public_ports["monitoring"]}"]
}
source_ranges = ["0.0.0.0/0"]
target_tags = ["performance", "prometheus"]
}
module "performance" {
subnetwork_name = "${google_compute_subnetwork.monitoring.name}"
attach_data_disk = true
data_disk_size = 100
data_disk_type = "pd-standard"
chef_provision = "${var.chef_provision}"
chef_run_list = "${var.base_chef_run_list}"
dns_zone_name = "${var.dns_zone_name}"
environment = "${var.environment}"
machine_type = "${var.machine_types["monitoring"]}"
name = "performance"
node_count = "${var.node_count["performance"]}"
project = "${var.project}"
region = "${var.region}"
source = "../../modules/google/monitoring"
tier = "inf"
persistent_disk_path = "/opt"
bootstrap_version = 2
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
cert_link = "projects/gitlab-production/global/sslCertificates/gprd-wildcard"
service_port = "3000"
service_path = "/health"
oauth2_client_id = "${var.oauth2_client_id}"
oauth2_client_secret = "${var.oauth2_client_secret}"
}
module "prometheus" {
subnetwork_name = "${google_compute_subnetwork.monitoring.name}"
attach_data_disk = true
data_disk_size = 1000
data_disk_type = "pd-standard"
......@@ -479,20 +528,21 @@ module "monitoring" {
chef_run_list = "${var.base_chef_run_list}"
dns_zone_name = "${var.dns_zone_name}"
environment = "${var.environment}"
ip_cidr_range = "${var.subnetworks["monitoring"]}"
machine_type = "${var.machine_types["monitoring"]}"
name = "prometheus"
node_count = "${var.node_count["monitoring"]}"
node_count = "${var.node_count["prometheus"]}"
project = "${var.project}"
public_ports = "${var.public_ports["monitoring"]}"
region = "${var.region}"
source = "../../modules/google/monitoring"
tier = "inf"
vpc = "${module.network.self_link}"
persistent_disk_path = "/opt/prometheus"
bootstrap_version = 2
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
cert_link = "projects/gitlab-production/global/sslCertificates/gprd-wildcard"
service_port = "9090"
service_path = "/graph"
oauth2_client_id = "${var.oauth2_client_id}"
oauth2_client_secret = "${var.oauth2_client_secret}"
}
##################################
......
variable "oauth2_client_id" {}
variable "oauth2_client_secret" {}
variable "base_chef_run_list" {
default = "\"role[gitlab]\",\"recipe[gitlab_users::default]\",\"recipe[gitlab_sudo::default]\",\"recipe[gitlab-server::bashrc]\""
}
......@@ -88,7 +91,8 @@ variable "node_count" {
"lfs" = 1
"pages" = 1
"pgb" = 1
"monitoring" = 2
"prometheus" = 1
"performance" = 1
"redis" = 1
"redis-cache" = 1
"share" = 1
......
resource "google_compute_firewall" "public" {
count = "${length(var.public_ports) > 0 ? 1 : 0}"
name = "${format("%v-%v", var.name, var.environment)}"
network = "${var.vpc}"
allow {
protocol = "tcp"
ports = ["${var.public_ports}"]
}
source_ranges = ["0.0.0.0/0"]
target_tags = ["${var.name}"]
}
resource "google_compute_address" "static-ip-address" {
count = "${var.node_count}"
name = "${format("%v-%02d-%v-%v-static-ip", var.name, count.index + 1 + 100, var.tier, var.environment)}"
address_type = "INTERNAL"
address = "${replace(var.ip_cidr_range, "/\\d+\\/\\d+$/", count.index + 1 + 100)}"
subnetwork = "${google_compute_subnetwork.subnetwork.self_link}"
}
resource "google_compute_disk" "data_disk" {
project = "${var.project}"
count = "${(var.attach_data_disk && var.node_count > 0) ? var.node_count : 0}"
......@@ -79,8 +70,7 @@ resource "google_compute_instance" "instance_with_attached_disk" {
}
network_interface {
subnetwork = "${google_compute_subnetwork.subnetwork.name}"
address = "${google_compute_address.static-ip-address.*.address[count.index]}"
subnetwork = "${var.subnetwork_name}"
access_config = {}
}
......
......@@ -3,7 +3,7 @@ data "google_compute_lb_ip_ranges" "ranges" {}
resource "aws_route53_record" "monitoring" {
count = "${var.node_count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "${format("prometheus-%02d.%v.gitlab.com.", count.index + 1, var.environment)}"
name = "${format("%v-%02d.%v.gitlab.com.", var.name, count.index + 1, var.environment)}"
type = "A"
ttl = "300"
records = ["${google_compute_global_address.monitoring.*.address[count.index]}"]
......@@ -11,12 +11,12 @@ resource "aws_route53_record" "monitoring" {
resource "google_compute_global_address" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
}
resource "google_compute_global_forwarding_rule" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
target = "${google_compute_target_https_proxy.monitoring.*.self_link[count.index]}"
port_range = "443"
ip_address = "${google_compute_global_address.monitoring.*.address[count.index]}"
......@@ -24,7 +24,7 @@ resource "google_compute_global_forwarding_rule" "monitoring" {
resource "google_compute_target_https_proxy" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
description = "https proxy for monitoring-${count.index + 1}"
ssl_certificates = ["${var.cert_link}"]
url_map = "${google_compute_url_map.monitoring.*.self_link[count.index]}"
......@@ -32,7 +32,7 @@ resource "google_compute_target_https_proxy" "monitoring" {
resource "google_compute_url_map" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
default_service = "${google_compute_backend_service.monitoring.*.self_link[count.index]}"
host_rule {
......@@ -45,7 +45,7 @@ resource "google_compute_url_map" "monitoring" {
default_service = "${google_compute_backend_service.monitoring.*.self_link[count.index]}"
path_rule {
paths = ["/graph"]
paths = ["${var.service_path}"]
service = "${google_compute_backend_service.monitoring.*.self_link[count.index]}"
}
}
......@@ -53,13 +53,13 @@ resource "google_compute_url_map" "monitoring" {
resource "google_compute_instance_group" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
description = "Instance group for monitoring VM."
zone = "${var.zone != "" ? var.zone : data.google_compute_zones.available.names[(count.index + 1) % length(data.google_compute_zones.available.names)]}"
named_port {
name = "prometheus"
port = "9090"
name = "${var.name}-${count.index + 1}"
port = "${var.service_port}"
}
instances = ["${google_compute_instance.instance_with_attached_disk.*.self_link[count.index]}"]
......@@ -67,34 +67,39 @@ resource "google_compute_instance_group" "monitoring" {
resource "google_compute_health_check" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
http_health_check {
port = "9090"
request_path = "/graph"
port = "${var.service_port}"
request_path = "${var.service_path}"
}
}
resource "google_compute_backend_service" "monitoring" {
count = "${var.node_count}"
name = "${var.environment}-monitoring-${count.index + 1}"
name = "${format("%v-%v-%02d", var.environment, var.name, count.index + 1)}"
protocol = "HTTP"
port_name = "prometheus"
port_name = "${var.name}-${count.index + 1}"
backend {
group = "${google_compute_instance_group.monitoring.*.self_link[count.index]}"
}
health_checks = ["${google_compute_health_check.monitoring.*.self_link[count.index]}"]
iap {
oauth2_client_secret = "${var.oauth2_client_secret}"
oauth2_client_id = "${var.oauth2_client_id}"
}
}
resource "google_compute_firewall" "default" {
name = "monitoring-firewall"
name = "${format("%v-%v", var.environment, var.name)}"
network = "${var.environment}"
allow {
protocol = "tcp"
ports = ["80"]
ports = ["80", "${var.service_port}"]
}
source_ranges = ["${data.google_compute_lb_ip_ranges.ranges.network}"]
......
resource "google_compute_subnetwork" "subnetwork" {
count = "${var.node_count > 0 ? 1 : 0}"
name = "${format("%v-%v", var.name, var.environment)}"
network = "${var.vpc}"
project = "${var.project}"
region = "${var.region}"
ip_cidr_range = "${var.ip_cidr_range}"
private_ip_google_access = true
}
variable "oauth2_client_id" {
type = "string"
}
variable "oauth2_client_secret" {
type = "string"
}
variable "service_port" {
type = "string"
description = "port for the service running on the monitoring node"
}
variable "service_path" {
type = "string"
description = "path for the health check"
}
variable "subnetwork_name" {
type = "string"
description = "subnetwork name for the instances"
}
variable "cert_link" {
type = "string"
description = "resource link for the ssl certificate"
......@@ -57,11 +80,6 @@ variable "environment" {
description = "The environment name"
}
variable "ip_cidr_range" {
type = "string"
description = "The IP range"
}
variable "machine_type" {
type = "string"
description = "The machine size"
......@@ -106,12 +124,6 @@ variable "project" {
description = "The project name"
}
variable "public_ports" {
type = "list"
description = "The list of ports that should be publicly reachable"
default = []
}
variable "region" {
type = "string"
description = "The target region"
......@@ -122,11 +134,6 @@ variable "tier" {
description = "The tier for this service"
}
variable "vpc" {
type = "string"
description = "The target network"
}
variable "zone" {
type = "string"
default = ""
......
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