-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add external workers This adds a new input `enable_external_workers` that replaces the old `create_compute_address_for_mqtt` that was incomplete. If this flag is enabled, we create two additional IPs and a DNS zone to be able to resolve the same mqtt endpoint address from both inside and outside of the cluster. It also create a new artifact repo and enable public read access on it. We use the public repo as the exported launcher image variable. I moved subnetwork in network module. * fixup! feat: add external workers * fixup! feat: add external workers
- Loading branch information
1 parent
8941848
commit ac18ce9
Showing
18 changed files
with
287 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
locals { | ||
repository_domain = "${google_artifact_registry_repository.spacelift.location}-docker.pkg.dev" | ||
repository_url = "${local.repository_domain}/${google_artifact_registry_repository.spacelift.project}/${google_artifact_registry_repository.spacelift.repository_id}" | ||
public_repository_url = var.enable_external_workers ? "${local.repository_domain}/${google_artifact_registry_repository.spacelift-public[0].project}/${google_artifact_registry_repository.spacelift-public[0].repository_id}" : local.repository_url | ||
} | ||
|
||
output "repository_domain" { | ||
value = "${google_artifact_registry_repository.spacelift.location}-docker.pkg.dev/" | ||
value = local.repository_domain | ||
description = "The domain of the Docker repository" | ||
} | ||
|
||
output "repository_url" { | ||
value = "${google_artifact_registry_repository.spacelift.location}-docker.pkg.dev/${google_artifact_registry_repository.spacelift.project}/${google_artifact_registry_repository.spacelift.repository_id}" | ||
value = local.repository_url | ||
description = "The URL of the Docker repository" | ||
} | ||
|
||
output "launcher_repository_url" { | ||
value = local.public_repository_url | ||
description = "The URL of the public Docker repository" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
variable "seed" { | ||
type = string | ||
} | ||
|
||
variable "enable_external_workers" { | ||
type = bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
locals { | ||
dns_name = join(".", slice(split(".", var.website_domain), length(split(".", var.website_domain))-2, length(split(".", var.website_domain)))) | ||
count = var.enable_external_workers ? 1 : 0 | ||
} | ||
|
||
resource "google_dns_managed_zone" "main" { | ||
count = local.count | ||
name = "${replace(local.dns_name, ".", "-")}-${var.seed}" | ||
dns_name = "${local.dns_name}." | ||
|
||
visibility = "private" | ||
|
||
private_visibility_config { | ||
networks { | ||
network_url = var.compute_network_id | ||
} | ||
} | ||
} | ||
|
||
resource "google_dns_record_set" "CNAME_mqtt" { | ||
count = local.count | ||
managed_zone = google_dns_managed_zone.main[0].name | ||
|
||
name = "${var.mqtt_subdomain}.${var.website_domain}." | ||
type = "CNAME" | ||
ttl = 300 | ||
|
||
rrdatas = [var.mqtt_service_alias] | ||
} | ||
|
||
resource "google_dns_record_set" "A_website_domain" { | ||
count = local.count | ||
managed_zone = google_dns_managed_zone.main[0].name | ||
|
||
name = "${var.website_domain}." | ||
type = "A" | ||
ttl = 300 | ||
|
||
rrdatas = [var.gke_public_v4_address] | ||
} | ||
|
||
resource "google_dns_record_set" "AAAA_website_domain" { | ||
count = local.count | ||
managed_zone = google_dns_managed_zone.main[0].name | ||
|
||
name = "${var.website_domain}." | ||
type = "AAAA" | ||
ttl = 300 | ||
|
||
rrdatas = [var.gke_public_v6_address] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "mqtt_endpoint" { | ||
value = var.enable_external_workers ? trimsuffix(google_dns_record_set.CNAME_mqtt[0].name, ".") : var.mqtt_service_alias | ||
description = "Address of the MQTT endpoint." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
variable "seed" { | ||
type = string | ||
} | ||
|
||
variable "enable_external_workers" { | ||
type = bool | ||
} | ||
|
||
variable "website_domain" { | ||
type = string | ||
description = "Domain name for the Spacelift frontend without protocol (e.g. spacelift.mycompany.com)." | ||
} | ||
|
||
variable "compute_network_id" { | ||
type = string | ||
description = "The ID of the network to create the GKE cluster in" | ||
} | ||
|
||
variable "gke_public_v4_address" { | ||
type = string | ||
} | ||
|
||
variable "gke_public_v6_address" { | ||
type = string | ||
} | ||
|
||
variable "mqtt_subdomain" { | ||
type = string | ||
default = "mqtt" | ||
} | ||
|
||
variable "mqtt_service_alias" { | ||
type = string | ||
default = "spacelift-mqtt.spacelift.svc.cluster.local." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,4 @@ | ||
output "gke_subnetwork_id" { | ||
value = google_compute_subnetwork.default.id | ||
description = "The ID of the subnetwork that the GKE cluster was created in" | ||
} | ||
|
||
output "gke_subnetwork_name" { | ||
value = google_compute_subnetwork.default.name | ||
description = "The name of the subnetwork that the GKE cluster was created in" | ||
} | ||
|
||
output "gke_cluster_name" { | ||
value = google_container_cluster.spacelift.name | ||
description = "The name of the GKE cluster" | ||
} | ||
|
||
output "mqtt_ipv4_address" { | ||
value = var.create_compute_address_for_mqtt ? google_compute_address.gke-mqtt-v4[0].address : null | ||
description = "The IPv4 address of the MQTT service" | ||
} | ||
|
||
output "mqtt_ipv6_address" { | ||
value = var.create_compute_address_for_mqtt ? google_compute_address.gke-mqtt-v6[0].address : null | ||
description = "The IPv6 address of the MQTT service" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.