Skip to content
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

Rename test cluster to green cluster #300

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions jobs/http.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ variable "test" {
default = false
}

variable "test_nomad_public_ip" {
type = string
default = ""
}

locals {
main = !var.test
}
Expand Down Expand Up @@ -96,9 +91,8 @@ job "http" {
dynamic "env" {
for_each = var.test ? [{}] : []
content {
CADDYPATH = "/etc/caddycerts"
FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000"
TEST_NOMAD_PUBLIC_IP = var.test_nomad_public_ip
CADDYPATH = "/etc/caddycerts"
FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000"
}
}

Expand Down
13 changes: 6 additions & 7 deletions terraform/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ variable "nomad_token" {
sensitive = true
}

variable "test_nomad_token" {
variable "nomad_green_token" {
type = string
sensitive = true
}

variable "test_consul_token" {
variable "consul_green_token" {
type = string
sensitive = true
}
Expand Down Expand Up @@ -50,9 +50,8 @@ provider "nomad" {
}

provider "nomad" {
alias = "test"
address = "http://${data.terraform_remote_state.aws.outputs.test_nomad_public_ip}:4646"
secret_id = var.test_nomad_token
consul_token = var.test_consul_token
region = "global"
alias = "green"
address = "http://${data.terraform_remote_state.aws.outputs.nomad_green_public_ip}:4646"
secret_id = var.nomad_green_token
region = "global"
}
18 changes: 8 additions & 10 deletions terraform/mediawiki.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ resource "nomad_job" "memcached" {
}
}

resource "nomad_job" "test_memcached" {
provider = nomad.test
resource "nomad_job" "memcached_green" {
provider = nomad.green
jobspec = file("../jobs/memcached.nomad")
detach = false

Expand All @@ -48,8 +48,8 @@ resource "nomad_job" "fastcgi" {
}
}

resource "nomad_job" "test_fastcgi" {
provider = nomad.test
resource "nomad_job" "fastcgi_green" {
provider = nomad.green
depends_on = [
nomad_job.memcached,
]
Expand All @@ -63,7 +63,7 @@ resource "nomad_job" "test_fastcgi" {
test = true
main_nomad_private_ip = data.terraform_remote_state.aws.outputs.nomad_private_ip
mysql_password_mediawiki = var.mysql_password_mediawiki
test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip
test_nomad_public_ip = data.terraform_remote_state.aws.outputs.nomad_green_public_ip
test_include_mysql = false
}
}
Expand All @@ -83,11 +83,10 @@ resource "nomad_job" "http" {
}
}

resource "nomad_job" "test_http" {
provider = nomad.test
resource "nomad_job" "http_green" {
provider = nomad.green
# TODO Replace EBS CSI with S3 CSI or something
depends_on = [
data.nomad_plugin.ebs_green,
nomad_csi_volume_registration.caddycerts_green,
]

Expand All @@ -97,8 +96,7 @@ resource "nomad_job" "test_http" {
hcl2 {
allow_fs = true
vars = {
test = true
test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip
test = true
}
}
}
13 changes: 3 additions & 10 deletions terraform/volumes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "nomad_job" "plugin-ebs-nodes" {
}

resource "nomad_job" "plugin_ebs_controller_green" {
provider = nomad.test
provider = nomad.green
jobspec = file("../jobs/plugin-ebs-controller.nomad")

hcl2 {
Expand All @@ -24,7 +24,7 @@ resource "nomad_job" "plugin_ebs_controller_green" {
}

resource "nomad_job" "plugin_ebs_nodes_green" {
provider = nomad.test
provider = nomad.green
jobspec = file("../jobs/plugin-ebs-nodes.nomad")

hcl2 {
Expand All @@ -37,12 +37,6 @@ data "nomad_plugin" "ebs" {
wait_for_healthy = true
}

data "nomad_plugin" "ebs_green" {
provider = nomad.test
plugin_id = "aws-ebs0"
wait_for_healthy = true
}

import {
id = "mysql@default"
to = nomad_csi_volume_registration.mysql
Expand Down Expand Up @@ -78,8 +72,7 @@ resource "nomad_csi_volume_registration" "caddycerts" {
}

resource "nomad_csi_volume_registration" "caddycerts_green" {
provider = nomad.test
depends_on = [data.nomad_plugin.ebs_green]
provider = nomad.green
plugin_id = "aws-ebs0"
volume_id = "caddycerts_green"
name = "caddycerts_green"
Expand Down