-
Notifications
You must be signed in to change notification settings - Fork 987
refactor(scaletest/terraform): break up infra creation and k8s resource provisioning #9824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
5 changes: 0 additions & 5 deletions
5
scaletest/terraform/gcp_project.tf → scaletest/terraform/infra/gcp_project.tf
This file contains hidden or 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,8 +1,3 @@ | ||
provider "google" { | ||
region = var.region | ||
project = var.project_id | ||
} | ||
|
||
locals { | ||
project_apis = [ | ||
"cloudtrace", | ||
|
File renamed without changes.
This file contains hidden or 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,20 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.36" | ||
} | ||
|
||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.5" | ||
} | ||
} | ||
|
||
required_version = "~> 1.5.0" | ||
} | ||
|
||
provider "google" { | ||
region = var.region | ||
project = var.project_id | ||
} |
This file contains hidden or 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,73 @@ | ||
output "coder_db_url" { | ||
description = "URL of the database for Coder." | ||
value = local.coder_db_url | ||
sensitive = true | ||
} | ||
|
||
output "coder_address" { | ||
description = "IP address to use for the Coder service." | ||
value = google_compute_address.coder.address | ||
} | ||
|
||
output "kubernetes_kubeconfig_path" { | ||
description = "Kubeconfig path." | ||
value = local.cluster_kubeconfig_path | ||
} | ||
|
||
output "kubernetes_nodepool_coder" { | ||
description = "Name of the nodepool on which to run Coder." | ||
value = google_container_node_pool.coder.name | ||
} | ||
|
||
output "kubernetes_nodepool_misc" { | ||
description = "Name of the nodepool on which to run everything else." | ||
value = google_container_node_pool.misc.name | ||
} | ||
|
||
output "kubernetes_nodepool_workspaces" { | ||
description = "Name of the nodepool on which to run workspaces." | ||
value = google_container_node_pool.workspaces.name | ||
} | ||
|
||
output "prometheus_external_label_cluster" { | ||
description = "Value for the Prometheus external label named cluster." | ||
value = google_container_cluster.primary.name | ||
} | ||
|
||
output "prometheus_postgres_dbname" { | ||
description = "Name of the database for Prometheus to monitor." | ||
value = google_sql_database.coder.name | ||
} | ||
|
||
output "prometheus_postgres_host" { | ||
description = "Hostname of the database for Prometheus to connect to." | ||
value = google_sql_database_instance.db.private_ip_address | ||
} | ||
|
||
output "prometheus_postgres_password" { | ||
description = "Postgres password for Prometheus." | ||
value = random_password.prometheus-postgres-password.result | ||
sensitive = true | ||
} | ||
|
||
output "prometheus_postgres_user" { | ||
description = "Postgres username for Prometheus." | ||
value = google_sql_user.prometheus.name | ||
} | ||
|
||
resource "local_file" "outputs" { | ||
filename = "${path.module}/../../.coderv2/infra_outputs.tfvars" | ||
content = <<EOF | ||
coder_db_url = "${local.coder_db_url}" | ||
coder_address = "${google_compute_address.coder.address}" | ||
kubernetes_kubeconfig_path = "${local.cluster_kubeconfig_path}" | ||
kubernetes_nodepool_coder = "${google_container_node_pool.coder.name}" | ||
kubernetes_nodepool_misc = "${google_container_node_pool.misc.name}" | ||
kubernetes_nodepool_workspaces = "${google_container_node_pool.workspaces.name}" | ||
prometheus_external_label_cluster = "${google_container_cluster.primary.name}" | ||
prometheus_postgres_dbname = "${google_sql_database.coder.name}" | ||
prometheus_postgres_host = "${google_sql_database_instance.db.private_ip_address}" | ||
prometheus_postgres_password = "${random_password.prometheus-postgres-password.result}" | ||
prometheus_postgres_user = "${google_sql_user.prometheus.name}" | ||
EOF | ||
} |
This file contains hidden or 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,102 @@ | ||
variable "state" { | ||
description = "The state of the cluster. Valid values are 'started', and 'stopped'." | ||
validation { | ||
condition = contains(["started", "stopped"], var.state) | ||
error_message = "value must be one of 'started' or 'stopped'" | ||
} | ||
default = "started" | ||
} | ||
|
||
variable "project_id" { | ||
description = "The project in which to provision resources" | ||
} | ||
|
||
variable "name" { | ||
description = "Adds a prefix to resources." | ||
} | ||
|
||
variable "region" { | ||
description = "GCP region in which to provision resources." | ||
default = "us-east1" | ||
} | ||
|
||
variable "zone" { | ||
description = "GCP zone in which to provision resources." | ||
default = "us-east1-c" | ||
} | ||
|
||
variable "k8s_version" { | ||
description = "Kubernetes vversion to provision." | ||
johnstcn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default = "1.24" | ||
} | ||
|
||
variable "node_disk_size_gb" { | ||
description = "Size of the root disk for cluster nodes." | ||
default = 100 | ||
} | ||
|
||
variable "node_image_type" { | ||
description = "Image type to use for cluster nodes." | ||
default = "cos_containerd" | ||
} | ||
|
||
// Preemptible nodes are way cheaper, but can be pulled out | ||
// from under you at any time. Caveat emptor. | ||
variable "node_preemptible" { | ||
description = "Use preemptible nodes." | ||
default = false | ||
} | ||
|
||
// We create three nodepools: | ||
// - One for the Coder control plane | ||
// - One for workspaces | ||
// - One for everything else (for example, load generation) | ||
|
||
// These variables control the node pool dedicated to Coder. | ||
variable "nodepool_machine_type_coder" { | ||
description = "Machine type to use for Coder control plane nodepool." | ||
default = "t2d-standard-4" | ||
} | ||
|
||
variable "nodepool_size_coder" { | ||
description = "Number of cluster nodes for the Coder control plane nodepool." | ||
default = 1 | ||
} | ||
|
||
// These variables control the node pool dedicated to workspaces. | ||
variable "nodepool_machine_type_workspaces" { | ||
description = "Machine type to use for the workspaces nodepool." | ||
default = "t2d-standard-4" | ||
} | ||
|
||
variable "nodepool_size_workspaces" { | ||
description = "Number of cluster nodes for the workspaces nodepool." | ||
default = 1 | ||
} | ||
|
||
// These variables control the node pool for everything else. | ||
variable "nodepool_machine_type_misc" { | ||
description = "Machine type to use for the misc nodepool." | ||
default = "t2d-standard-4" | ||
} | ||
|
||
variable "nodepool_size_misc" { | ||
description = "Number of cluster nodes for the misc nodepool." | ||
default = 1 | ||
} | ||
|
||
// These variables control the size of the database to be used by Coder. | ||
variable "cloudsql_version" { | ||
description = "CloudSQL version to provision" | ||
default = "POSTGRES_14" | ||
} | ||
|
||
variable "cloudsql_tier" { | ||
description = "CloudSQL database tier." | ||
default = "db-f1-micro" | ||
} | ||
|
||
variable "cloudsql_max_connections" { | ||
description = "CloudSQL database max_connections" | ||
default = 500 | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.