-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 20ee715 Merge: 2466a7e a6320bd Author: Jeff Raubitschek <[email protected]> Date: Thu Sep 12 10:52:46 2024 -0700 Merge remote-tracking branch 'origin/main' into jhr/add-clickhouse-1 commit 2466a7e Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Wed Sep 11 21:53:59 2024 +0000 terraform-docs: automated action commit 8c84c7f Author: Jeff Raubitschek <[email protected]> Date: Wed Sep 11 14:52:03 2024 -0700 allow clickhouse subnet to be configured and use class c commit 13d0f4a Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Wed Sep 11 17:20:37 2024 +0000 terraform-docs: automated action commit 2a7cc59 Author: Jeff Raubitschek <[email protected]> Date: Wed Sep 11 10:19:08 2024 -0700 feat: add clickhouse private service connect
- Loading branch information
Showing
8 changed files
with
135 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
resource "google_compute_subnetwork" "psc_network" { | ||
name = "${var.namespace}-subnet-clickhouse" | ||
|
||
region = var.clickhouse_region | ||
ip_cidr_range = var.clickhouse_reserved_ip_range | ||
private_ip_google_access = true | ||
network = var.network | ||
} | ||
|
||
resource "google_compute_address" "psc_endpoint_ip" { | ||
name = "${var.namespace}-clickhouse-psc-ip" | ||
address_type = "INTERNAL" | ||
purpose = "GCE_ENDPOINT" | ||
subnetwork = google_compute_subnetwork.psc_network.self_link | ||
region = var.clickhouse_region | ||
} | ||
|
||
resource "google_compute_forwarding_rule" "psc_forward_rule" { | ||
name = "${var.namespace}-clickhouse-psc-forward" | ||
ip_address = google_compute_address.psc_endpoint_ip.self_link | ||
network = var.network | ||
region = var.clickhouse_region | ||
load_balancing_scheme = "" | ||
allow_psc_global_access = true | ||
|
||
target = "https://www.googleapis.com/compute/v1/${var.clickhouse_private_endpoint_service_name}" | ||
} | ||
|
||
resource "google_dns_managed_zone" "psc_dns_zone" { | ||
name = "${var.namespace}-clickhouse-dns-zone" | ||
description = "Private DNS zone for accessing ClickHouse Cloud using Private Service Connect" | ||
dns_name = "${var.clickhouse_region}.p.gcp.clickhouse.cloud." | ||
force_destroy = true | ||
visibility = "private" | ||
|
||
// associate private DNS zone with network | ||
private_visibility_config { | ||
networks { | ||
network_url = var.network | ||
} | ||
} | ||
} | ||
|
||
resource "google_dns_record_set" "psc_dns_record" { | ||
name = "*.${var.clickhouse_region}.p.gcp.clickhouse.cloud." | ||
managed_zone = google_dns_managed_zone.psc_dns_zone.name | ||
type = "A" | ||
rrdatas = [ google_compute_address.psc_endpoint_ip.address ] | ||
ttl = 3600 | ||
} |
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 "psc_connection_id" { | ||
value = google_compute_forwarding_rule.psc_forward_rule.psc_connection_id | ||
description = "Add GCP PSC Connection ID to ClickHouse allow list." | ||
} |
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,37 @@ | ||
variable "namespace" { | ||
type = string | ||
description = "The name prefix for all resources created." | ||
} | ||
|
||
variable "network" { | ||
type = string | ||
description = "Google Compute Engine network to which the cluster is connected." | ||
} | ||
|
||
variable "clickhouse_reserved_ip_range" { | ||
type = string | ||
description = "Reserved IP range for ClickHouse private link" | ||
default = "10.50.0.0/24" | ||
} | ||
|
||
variable "clickhouse_private_endpoint_service_name" { | ||
type = string | ||
description = "ClickHouse private endpoint 'Service name' (ends in -clickhouse-cloud)." | ||
default = "" | ||
|
||
validation { | ||
condition = can(regex("-clickhouse-cloud$", var.clickhouse_private_endpoint_service_name)) | ||
error_message = "ClickHouse Service name must end in '-clickhouse-cloud'." | ||
} | ||
} | ||
|
||
variable "clickhouse_region" { | ||
type = string | ||
description = "ClickHouse region (us-east1, us-central1, etc)." | ||
default = "" | ||
|
||
validation { | ||
condition = length(var.clickhouse_region) > 0 | ||
error_message = "Clickhouse Region should always be set if the private endpoint service name is specified." | ||
} | ||
} |
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