Skip to content

Commit

Permalink
add region support to terraform config and populate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
callumdmay committed Oct 18, 2024
1 parent 9b25b7d commit 262dc6d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ a PR to that effect would be greatly appreciated.
recommend "<ORG_NAME>_<CLUSTER_NAME>", and the `=` character is not
allowed. However, any unique (among all other participating DSS
instances) value is acceptable.
1. `VAR_CRDB_REGION`:Region of your DSS instance. Regions are a high-level abstraction
of a geographic region, and are meant to correspond directly to the region terminology
used by cloud providers. Each region is broken into multiple zones. Regions are used
to achieve varying survival goals in the face of database failure. More info at
https://www.cockroachlabs.com/docs/stable/multiregion-overview.
1. `VAR_CRDB_NODE_IPn`: IP address (**numeric**) of nth CRDB node (add more
entries if you have more than 3 CRDB nodes). Example: `1.1.1.1`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
# Tanka defines itself the variable below. For helm, since we are using the official helm CRDB chart,
# the following variable has to be provided here.
helm_crdb_statefulset_name = "dss-cockroachdb"
locality_args = var.crdb_region != "" ? "region=${var.crdb_region},zone=${var.crdb_locality}" : "zone=${var.crdb_locality}"
}

resource "local_file" "helm_chart_values" {
Expand All @@ -17,13 +18,13 @@ resource "local_file" "helm_chart_values" {
join = var.crdb_external_nodes
cluster-name = var.crdb_cluster_name
single-node = false # Always false. Even with 1 replica, we would expect to keep the ability to pool it with another cluster.
locality = "zone=${var.crdb_locality}"
locality = locals.locality_args
}

statefulset = {
replicas = length(var.crdb_internal_nodes)
args = [
"--locality-advertise-addr=zone=${var.crdb_locality}@$(hostname -f)",
"--locality-advertise-addr=${locals.locality_args}@$(hostname -f)",
"--advertise-addr=$${HOSTNAME##*-}.${var.crdb_hostname_suffix}"
]
}
Expand Down
1 change: 1 addition & 0 deletions deploy/infrastructure/modules/terraform-aws-dss/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module "terraform-commons-dss" {
should_init = var.should_init
authorization = var.authorization
crdb_locality = var.crdb_locality
crdb_region = var.crdb_region
crdb_external_nodes = var.crdb_external_nodes
crdb_internal_nodes = module.terraform-aws-kubernetes.crdb_nodes
ip_gateway = module.terraform-aws-kubernetes.ip_gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ should_init = true
crdb_image_tag = "v24.1.3"
crdb_cluster_name = "interuss_example"
crdb_locality = "interuss_dss-aws-ew1"
crdb_region = "eu-west-1"
crdb_external_nodes = []
1 change: 1 addition & 0 deletions deploy/infrastructure/modules/terraform-google-dss/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "terraform-commons-dss" {
should_init = var.should_init
authorization = var.authorization
crdb_locality = var.crdb_locality
crdb_region = var.crdb_region
image_pull_secret = var.image_pull_secret
crdb_external_nodes = var.crdb_external_nodes
kubernetes_api_endpoint = module.terraform-google-kubernetes.kubernetes_api_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ should_init = true
crdb_image_tag = "v24.1.3"
crdb_cluster_name = "interuss_example"
crdb_locality = "interuss_dss-dev-w6a"
crdb_region = "europe-west6-a"
crdb_external_nodes = []
12 changes: 12 additions & 0 deletions deploy/infrastructure/utils/definitions/crdb_region.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
variable "crdb_region" {
type = string
description = <<-EOT
Region of your DSS instance. Regions are a high-level abstraction of a geographic region,
and are meant to correspond directly to the region terminology used by cloud providers.
Each region is broken into multiple zones. Regions are used to achieve varying survival
goals in the face of database failure. More info at
https://www.cockroachlabs.com/docs/stable/multiregion-overview.
Example: <us-east1>
EOT
}
1 change: 1 addition & 0 deletions deploy/infrastructure/utils/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"crdb_image_tag",
"crdb_cluster_name",
"crdb_locality",
"crdb_region",
"crdb_external_nodes",
"kubernetes_namespace",
]
Expand Down
1 change: 1 addition & 0 deletions deploy/operations/ci/aws-1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module "terraform-aws-dss" {
crdb_cluster_name = var.crdb_cluster_name
crdb_hostname_suffix = var.crdb_hostname_suffix
crdb_locality = var.crdb_locality
crdb_region = var.crdb_region
crdb_external_nodes = var.crdb_external_nodes
image = var.image
kubernetes_version = var.kubernetes_version
Expand Down
1 change: 1 addition & 0 deletions deploy/operations/ci/aws-1/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ should_init = true
crdb_image_tag = "v24.1.3"
crdb_cluster_name = "interuss-ci"
crdb_locality = "interuss_dss-ci-aws-ue1"
crdb_region = "us-east-1"
crdb_external_nodes = []

aws_iam_permissions_boundary = "arn:aws:iam::301042233698:policy/GithubCIPermissionBoundaries20231130225039606500000001"
Expand Down

0 comments on commit 262dc6d

Please sign in to comment.