-
Notifications
You must be signed in to change notification settings - Fork 901
chore: add terraform for spinning up load test cluster #7504
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 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
29016dc
Port over initial version of v1 loadtest infra tf code
johnstcn 8759e23
Fix VPC peering for CloudSQL
johnstcn bef9887
create clusters in vpc native networking mode
johnstcn ea42b44
gitignore tfstate
johnstcn 9875f84
create pg database and user, fix db url
johnstcn 8fb3511
ensure db is destroyed properly with terraform destroy
johnstcn 13ca9e4
enable prometheus, add podmonitor spec
johnstcn 3a3509b
add inline kubernetes template
johnstcn 41ab251
add script to init coder instance and import template
johnstcn 0bbf206
modify tls cert def
johnstcn d4b1fe6
fixup template
johnstcn 2b5a15b
multiple fixes
johnstcn dbcfc64
rebuild docker image with certs
johnstcn 69bdfd1
remove self-signed https for now
johnstcn 99c0f3c
move monitoring manifest out of helm chart
johnstcn ccda05d
move generated files into .coderv2, create shim script
johnstcn 6ace619
adjust template limits
johnstcn 01c6d39
make fmt
johnstcn 9f7c165
make lint
johnstcn 660959c
make gen
johnstcn 34f8b02
update README
johnstcn 75d1746
fixup! update README
johnstcn 5a3c801
update cluster monitoriong and workload identity
johnstcn caa04d4
fix coder depoyment node affinity
johnstcn 9419701
address PR comments
johnstcn 435e74d
make fmt
johnstcn 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
multiple fixes
- Loading branch information
commit 2b5a15b64277b4b90788cfdddb68cebbfdb0cf30
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ locals { | |
coder_helm_chart = "coder" | ||
coder_release_name = "coder-${var.name}" | ||
coder_namespace = "coder-${var.name}" | ||
coder_admin_email = "admin@coder.com" | ||
coder_admin_user = "coder" | ||
} | ||
|
||
provider "kubernetes" { | ||
|
@@ -45,7 +47,7 @@ resource "kubernetes_secret" "coder-db" { | |
namespace = kubernetes_namespace.coder_namespace.metadata.0.name | ||
} | ||
data = { | ||
url = "postgres://coder:${urlencode(random_password.coder-postgres-password.result)}@${google_sql_database_instance.db.private_ip_address}/${google_sql_database.coder.name}?sslmode=disable" | ||
url = "postgres://${google_sql_user.coder.name}:${urlencode(random_password.coder-postgres-password.result)}@${google_sql_database_instance.db.private_ip_address}/${google_sql_database.coder.name}?sslmode=disable" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine for now, but I think TLS would be better here & more realistic |
||
} | ||
} | ||
|
||
|
@@ -71,6 +73,10 @@ resource "tls_self_signed_cert" "coder" { | |
"${local.coder_release_name}.${local.coder_namespace}", | ||
"${local.coder_release_name}", | ||
] | ||
|
||
ip_addresses = [ | ||
google_compute_address.coder.address | ||
] | ||
} | ||
|
||
resource "kubernetes_secret" "coder-tls" { | ||
|
@@ -108,9 +114,29 @@ resource "helm_release" "coder-chart" { | |
] | ||
values = [<<EOF | ||
coder: | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: "cloud.google.com/gke-nodepool" | ||
operator: "In" | ||
values: ["${google_container_node_pool.workspaces.name}"] | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
podAffinityTerm: | ||
topologyKey: "kubernetes.io/hostname" | ||
labelSelector: | ||
matchExpressions: | ||
- key: "app.kubernetes.io/instance" | ||
operator: "In" | ||
values: ["${local.coder_release_name}"] | ||
env: | ||
- name: "CODER_CACHE_DIRECTORY" | ||
value: "/tmp/coder" | ||
- name: "CODER_ENABLE_TELEMETRY" | ||
value: "false" | ||
- name: "CODER_LOGGING_HUMAN" | ||
value: "/dev/null" | ||
- name: "CODER_LOGGING_STACKDRIVER" | ||
|
@@ -122,6 +148,8 @@ coder: | |
key: url | ||
- name: "CODER_PROMETHEUS_ENABLE" | ||
value: "true" | ||
- name: "CODER_TLS_REDIRECT_HTTP_TO_HTTPS" | ||
value: "true" | ||
- name: "CODER_VERBOSE" | ||
value: "true" | ||
image: | ||
|
@@ -139,6 +167,7 @@ coder: | |
readOnlyRootFilesystem: true | ||
service: | ||
enable: true | ||
loadBalancerIP: "${google_compute_address.coder.address}" | ||
tls: | ||
secretNames: | ||
- "${kubernetes_secret.coder-tls.metadata.0.name}" | ||
|
@@ -169,6 +198,11 @@ EOF | |
] | ||
} | ||
|
||
resource "local_file" "url" { | ||
filename = "${path.module}/coder_url" | ||
content = "https://${google_compute_address.coder.address}" | ||
} | ||
|
||
resource "local_file" "kubernetes_template" { | ||
filename = "${path.module}/.coderv2/templates/kubernetes/main.tf" | ||
content = <<EOF | ||
|
@@ -242,10 +276,10 @@ resource "local_file" "kubernetes_template" { | |
affinity { | ||
node_affinity { | ||
required_during_scheduling_ignored_during_execution { | ||
node_selector_terms { | ||
node_selector_term { | ||
match_expressions { | ||
key = "cloud.google.com/gke-nodepool" | ||
operator = "in" | ||
operator = "In" | ||
values = ["${google_container_node_pool.workspaces.name}"] | ||
} | ||
} | ||
|
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the value of including
var.name
in the Google resources, since there is a search you can do, but here I think it just makes things more wordy --- the idea is to have only one Coder instance per load-balancing cluster.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, and the namespace also includes
var.name
.