Skip to content

Commit

Permalink
Add an availability monitor (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed May 21, 2024
1 parent 362ef8d commit 99fa2fe
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
env:
TF_VAR_project: ${{ secrets.GCLOUD_PROJECT }}
jobs:
terraform:
name: Create test CR
test:
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down
32 changes: 32 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,35 @@ module "lb" {
"crayfits" = module.crayfits.backend
}
}

resource "google_monitoring_uptime_check_config" "availability" {
for_each = toset([
"crayfits",
"homarus",
"houdini",
"hypercube"
])
display_name = "${each.value}-availability"
timeout = "10s"
period = "60s"
project = var.project
selected_regions = [
"USA_OREGON",
"USA_VIRGINIA",
"USA_IOWA"
]
http_check {
path = "/${each.value}/healthcheck"
port = "443"
use_ssl = true
validate_ssl = true
}

monitored_resource {
type = "uptime_url"
labels = {
project_id = var.project
host = "microservices.libops.site"
}
}
}
12 changes: 12 additions & 0 deletions modules/lb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ resource "google_compute_url_map" "default" {
service = path_rule.value
}
}
dynamic "path_rule" {
for_each = var.backends
content {
paths = ["/${path_rule.key}/healthcheck"]
service = path_rule.value
route_action {
url_rewrite {
path_prefix_rewrite = "/healthcheck"
}
}
}
}
}
}

Expand Down

0 comments on commit 99fa2fe

Please sign in to comment.