Skip to content

Commit 0a482be

Browse files
committed
Revive production-3
Sync up the configuration with prod-1 and prod-2 so we can create an identical environment. Small fixes to revive production-3: * Fix DNS entry for individual NAT * Add `project` argument where needed * Only create a single NAT per zone (static IP quota on prod-3)
1 parent cd135ef commit 0a482be

File tree

7 files changed

+54
-19
lines changed

7 files changed

+54
-19
lines changed

dns-production-0/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ data "dns_a_record_set" "gce_production_2_nat" {
5454
host = "nat-production-2.gce-us-central1.travisci.net"
5555
}
5656

57+
data "dns_a_record_set" "gce_production_3_nat" {
58+
host = "nat-production-3.gce-us-central1.travisci.net"
59+
}
60+
5761
data "dns_a_record_set" "gce_production_1_build_cache" {
5862
host = "production-1-build-cache.gce-us-central1.travisci.net"
5963
}
@@ -71,6 +75,7 @@ resource "aws_route53_record" "gce_nat" {
7175
records = [
7276
"${data.dns_a_record_set.gce_production_1_nat.addrs}",
7377
"${data.dns_a_record_set.gce_production_2_nat.addrs}",
78+
"${data.dns_a_record_set.gce_production_3_nat.addrs}",
7479
]
7580
}
7681

@@ -83,6 +88,7 @@ resource "aws_route53_record" "linux_containers_nat" {
8388
records = [
8489
"${data.dns_a_record_set.gce_production_1_nat.addrs}",
8590
"${data.dns_a_record_set.gce_production_2_nat.addrs}",
91+
"${data.dns_a_record_set.gce_production_3_nat.addrs}",
8692
]
8793
}
8894

@@ -104,6 +110,7 @@ resource "aws_route53_record" "nat" {
104110
records = [
105111
"${data.dns_a_record_set.gce_production_1_nat.addrs}",
106112
"${data.dns_a_record_set.gce_production_2_nat.addrs}",
113+
"${data.dns_a_record_set.gce_production_3_nat.addrs}",
107114
"${var.macstadium_production_nat_addrs}",
108115
]
109116
}
@@ -139,6 +146,8 @@ resource "heroku_app" "whereami" {
139146
join(",", data.dns_a_record_set.gce_production_1_nat.addrs)
140147
},${
141148
join(",", data.dns_a_record_set.gce_production_2_nat.addrs)
149+
},${
150+
join(",", data.dns_a_record_set.gce_production_3_nat.addrs)
142151
}"
143152

144153
WHEREAMI_INFRA_MACSTADIUM_IPS = "${

gce-production-1/service_accounts.tf

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ data "terraform_remote_state" "production_2" {
2020
}
2121
}
2222

23+
data "terraform_remote_state" "production_3" {
24+
backend = "s3"
25+
26+
config {
27+
bucket = "travis-terraform-state"
28+
key = "terraform-config/gce-production-3.tfstate"
29+
region = "us-east-1"
30+
dynamodb_table = "travis-terraform-state"
31+
}
32+
}
33+
2334
resource "google_project_iam_member" "staging_1_workers" {
2435
count = "${length(data.terraform_remote_state.staging_1.workers_service_account_emails)}"
2536
project = "${var.project}"
@@ -33,3 +44,10 @@ resource "google_project_iam_member" "production_2_workers" {
3344
role = "roles/compute.imageUser"
3445
member = "serviceAccount:${element(data.terraform_remote_state.production_2.workers_service_account_emails, count.index)}"
3546
}
47+
48+
resource "google_project_iam_member" "production_3_workers" {
49+
count = "${length(data.terraform_remote_state.production_3.workers_service_account_emails)}"
50+
project = "${var.project}"
51+
role = "roles/compute.imageUser"
52+
member = "serviceAccount:${element(data.terraform_remote_state.production_3.workers_service_account_emails, count.index)}"
53+
}

gce-production-3/Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
AMQP_URL_COM_VARNAME := CLOUDAMQP_URL
22
AMQP_URL_ORG_VARNAME := CLOUDAMQP_GRAY_URL
3+
GCE_PROJECT := travis-ci-prod-3
4+
GKE_CLUSTER_NAME := gce-production-3
5+
GKE_CLUSTER_ZONE := us-central1
36

47
include $(shell git rev-parse --show-toplevel)/gce.mk
5-
6-
plan:
7-
@echo DISABLED OK
8-
9-
apply:
10-
@echo NO REALLY DONT DO THIS

gce-production-3/main.tf

+13-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ variable "env" {
33
}
44

55
variable "gce_heroku_org" {}
6-
76
variable "github_users" {}
87

98
variable "index" {
@@ -82,16 +81,13 @@ module "gce_worker_group" {
8281
syslog_address_com = "${var.syslog_address_com}"
8382
syslog_address_org = "${var.syslog_address_org}"
8483
travisci_net_external_zone_id = "${var.travisci_net_external_zone_id}"
85-
worker_subnetwork = "${data.terraform_remote_state.vpc.gce_subnetwork_workers}"
84+
85+
worker_subnetwork = "${data.terraform_remote_state.vpc.gce_subnetwork_workers}"
8686

8787
worker_managed_instance_count_com = "${var.worker_managed_instance_count_com}"
8888
worker_managed_instance_count_com_free = "${var.worker_managed_instance_count_com_free}"
8989
worker_managed_instance_count_org = "${var.worker_managed_instance_count_org}"
9090

91-
worker_service_accounts_count_com = "${var.worker_managed_instance_count_com / 4}"
92-
worker_service_accounts_count_com_free = "${var.worker_managed_instance_count_com_free / 4}"
93-
worker_service_accounts_count_org = "${var.worker_managed_instance_count_org / 4}"
94-
9591
worker_config_com = <<EOF
9692
### worker.env
9793
${file("${path.module}/worker.env")}
@@ -140,6 +136,17 @@ export AWS_SECRET_ACCESS_KEY=${module.aws_iam_user_s3_org.secret}
140136
EOF
141137
}
142138

139+
module "gke_cluster_1" {
140+
source = "../modules/gke_cluster"
141+
name = "gce-production-3"
142+
gke_network = "${data.terraform_remote_state.vpc.gce_network_main}"
143+
gke_subnetwork = "${data.terraform_remote_state.vpc.gce_subnetwork_gke_cluster}"
144+
}
145+
143146
output "workers_service_account_emails" {
144147
value = ["${module.gce_worker_group.workers_service_account_emails}"]
145148
}
149+
150+
output "gcloud_cleanup_account_json" {
151+
value = "${module.gce_worker_group.gcloud_cleanup_account_json}"
152+
}

gce-production-net-3/Makefile

-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@ AMQP_URL_ORG_VARNAME := CLOUDAMQP_GRAY_URL
33
ENV_SHORT := production
44

55
include $(shell git rev-parse --show-toplevel)/gce.mk
6-
7-
plan:
8-
@echo DISABLED OK
9-
10-
apply:
11-
@echo NO REALLY DONT DO THIS

gce-production-net-3/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ module "gce_net" {
8888
workers_subnet_cidr_range = "10.10.16.0/22"
8989
}
9090

91+
output "gce_network_main" {
92+
value = "${module.gce_net.gce_network_main}"
93+
}
94+
9195
output "gce_subnetwork_workers" {
9296
value = "${module.gce_net.gce_subnetwork_workers}"
9397
}
98+
99+
output "gce_subnetwork_gke_cluster" {
100+
value = "${module.gce_net.gce_subnetwork_gke_cluster}"
101+
}

modules/gce_net/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ resource "google_compute_firewall" "allow_main_ssh" {
176176
network = "${google_compute_network.main.name}"
177177
source_ranges = ["${var.rigaer_strasse_8_ipv4}"]
178178
priority = 1000
179+
project = "${var.project}"
179180

180181
allow {
181182
protocol = "tcp"
@@ -273,7 +274,7 @@ resource "google_compute_address" "nat" {
273274
resource "aws_route53_record" "nat" {
274275
count = "${length(var.nat_zones) * var.nat_count_per_zone}"
275276
zone_id = "${var.travisci_net_external_zone_id}"
276-
name = "${element(var.nat_names, count.index)}.gce-${var.env}-${var.region}-${element(var.nat_zones, count.index / var.nat_count_per_zone)}.travisci.net"
277+
name = "${element(var.nat_names, count.index)}.gce-${var.env}-${var.index}-${var.region}-${element(var.nat_zones, count.index / var.nat_count_per_zone)}.travisci.net"
277278
type = "A"
278279
ttl = 5
279280

@@ -390,6 +391,7 @@ resource "google_compute_http_health_check" "nat" {
390391
check_interval_sec = 30
391392
healthy_threshold = 1
392393
unhealthy_threshold = 5
394+
project = "${var.project}"
393395
}
394396

395397
resource "google_compute_firewall" "allow_nat_health_check" {

0 commit comments

Comments
 (0)