Skip to content

Commit

Permalink
[terraform] Make cockroach DB cluster name configurable (#1018)
Browse files Browse the repository at this point in the history
* [terraform] add configuration variable crdb_cluster_name

[terraform] add configuration variable crdb_cluster_name

* Update documentation and variables.tf

* Propagate new environment variable

* Update example files

* Format tf

* Update text
  • Loading branch information
barroco authored Apr 12, 2024
1 parent a965f06 commit 5a93c34
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource "local_file" "helm_chart_values" {

conf = {
join = var.crdb_external_nodes
cluster-name = "dss-aws-1"
cluster-name = var.crdb_cluster_name
single-node = false
locality = "zone=${var.crdb_locality}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ variable "desired_scd_db_version" {
default = "latest"
}

variable "crdb_cluster_name" {
type = string
description = <<-EOT
A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.
At the moment, this variable is only used for helm charts deployments.
Example: interuss_us_production
EOT
}


variable "crdb_locality" {
type = string
description = <<-EOT
Expand Down
15 changes: 15 additions & 0 deletions deploy/infrastructure/modules/terraform-aws-dss/TFVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ Use `latest` to use the latest schema version.
Example: `3.1.0`


### crdb_cluster_name

*Type: `string`*

A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.

At the moment, this variable is only used for helm charts deployments.

Example: interuss_us_production


### crdb_locality

*Type: `string`*
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 @@ -20,6 +20,7 @@ module "terraform-commons-dss" {
kubernetes_namespace = var.kubernetes_namespace
kubernetes_storage_class = var.aws_kubernetes_storage_class
app_hostname = var.app_hostname
crdb_cluster_name = var.crdb_cluster_name
crdb_hostname_suffix = var.crdb_hostname_suffix
should_init = var.should_init
authorization = var.authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ image = "latest"
authorization = {
public_key_pem_path = "/test-certs/auth2.pem"
}
should_init = true
should_init = true

# CockroachDB
crdb_cluster_name = "interuss_example"
crdb_locality = "interuss_dss-aws-ew1"
crdb_external_nodes = []
16 changes: 16 additions & 0 deletions deploy/infrastructure/modules/terraform-aws-dss/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ variable "desired_scd_db_version" {
default = "latest"
}

variable "crdb_cluster_name" {
type = string
description = <<-EOT
A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.
At the moment, this variable is only used for helm charts deployments.
Example: interuss_us_production
EOT
}


variable "crdb_locality" {
type = string
description = <<-EOT
Expand Down
15 changes: 15 additions & 0 deletions deploy/infrastructure/modules/terraform-google-dss/TFVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ Use `latest` to use the latest schema version.
Example: `3.1.0`


### crdb_cluster_name

*Type: `string`*

A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.

At the moment, this variable is only used for helm charts deployments.

Example: interuss_us_production


### crdb_locality

*Type: `string`*
Expand Down
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 @@ -19,6 +19,7 @@ module "terraform-commons-dss" {
kubernetes_namespace = var.kubernetes_namespace
kubernetes_storage_class = var.google_kubernetes_storage_class
app_hostname = var.app_hostname
crdb_cluster_name = var.crdb_cluster_name
crdb_hostname_suffix = var.crdb_hostname_suffix
should_init = var.should_init
authorization = var.authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ image_pull_secret = ""
authorization = {
public_key_pem_path = "/test-certs/auth2.pem"
}
should_init = true
crdb_locality = "interuss_dss-dev-w6a"
should_init = true

# CockroachDB
crdb_cluster_name = "interuss_example"
crdb_locality = "interuss_dss-dev-w6a"
crdb_external_nodes = []
16 changes: 16 additions & 0 deletions deploy/infrastructure/modules/terraform-google-dss/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@ variable "desired_scd_db_version" {
default = "latest"
}

variable "crdb_cluster_name" {
type = string
description = <<-EOT
A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.
At the moment, this variable is only used for helm charts deployments.
Example: interuss_us_production
EOT
}


variable "crdb_locality" {
type = string
description = <<-EOT
Expand Down
14 changes: 14 additions & 0 deletions deploy/infrastructure/utils/definitions/crdb_cluster_name.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "crdb_cluster_name" {
type = string
description = <<-EOT
A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.
At the moment, this variable is only used for helm charts deployments.
Example: interuss_us_production
EOT
}
1 change: 1 addition & 0 deletions deploy/infrastructure/utils/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"should_init",
"desired_rid_db_version",
"desired_scd_db_version",
"crdb_cluster_name",
"crdb_locality",
"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 @@ -17,6 +17,7 @@ module "terraform-aws-dss" {
aws_region = var.aws_region
aws_route53_zone_id = var.aws_route53_zone_id
cluster_name = var.cluster_name
crdb_cluster_name = var.crdb_cluster_name
crdb_hostname_suffix = var.crdb_hostname_suffix
crdb_locality = var.crdb_locality
crdb_external_nodes = var.crdb_external_nodes
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 @@ -23,6 +23,7 @@ authorization = {
public_key_pem_path = "/test-certs/auth2.pem"
}
should_init = true
crdb_cluster_name = "interuss_ci"
crdb_locality = "interuss_dss-ci-aws-ue1"
crdb_external_nodes = []

Expand Down
16 changes: 16 additions & 0 deletions deploy/operations/ci/aws-1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ variable "desired_scd_db_version" {
default = "latest"
}

variable "crdb_cluster_name" {
type = string
description = <<-EOT
A string that specifies a CRDB cluster name. This is used together to ensure that all newly created
nodes join the intended cluster when you are running multiple clusters.
The CRDB cluster is automatically given a randomly-generated name if an empty string is provided.
The CRDB cluster name must be 6-20 characters in length, and can include lowercase letters, numbers,
and dashes (but no leading or trailing dashes). A cluster's name cannot be edited after it is created.
At the moment, this variable is only used for helm charts deployments.
Example: interuss_us_production
EOT
}


variable "crdb_locality" {
type = string
description = <<-EOT
Expand Down

0 comments on commit 5a93c34

Please sign in to comment.