diff --git a/README.md b/README.md index 47796b0..782a5ce 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ module "thanos" { name_postfix = var.name_postfix + thanos_public_endpoints = false + // needed for paas_prometheus_exporter environment = { USERNAME = var.cf_username @@ -74,12 +76,17 @@ module "thanos" { | thanos\_image | Image to use for Thanos app | `string` | `"philipslabs/cf-thanos:latest"` | no | | thanos\_query\_image | Image to use for Thanos query | `string` | `"philipslabs/cf-thanos:latest"` | no | | thanos\_store\_image | Image to use for Thanos store | `string` | `"philipslabs/cf-thanos:latest"` | no | +| thanos\_public\_endpoints | Make Thanos endpoints private(false) or public (true) | `bool` | `true` | no | ## Outputs | Name | Description | |------|-------------| | cluster\_id | Cluster ID of Tasy POC | +| thanos\_space\_id| CF space Id where Thanos deployed| +| thanos\_app\_id| CF app Id of deployed Thanos | +| thanos\_query\_app\_id| CF app Id of deployed Thanos | +| grafana\_app\_id| CF app Id of deployed Grafana | | grafana\_endpoint | URL of Grafana deployment (optional) | | thanos\_query\_endpoint | URL of Thanos deployment | diff --git a/docker/Dockerfile b/docker/Dockerfile index 196d8a4..3357d0c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG prometheus_version=2.22.0 +ARG prometheus_version=2.22.2 ARG thanos_version=0.15.0 FROM alpine:latest AS prometheus diff --git a/docker/Dockerfile_with_exporter b/docker/Dockerfile_with_exporter index c31f78e..d5914df 100644 --- a/docker/Dockerfile_with_exporter +++ b/docker/Dockerfile_with_exporter @@ -1,4 +1,4 @@ -ARG prometheus_version=2.22.0 +ARG prometheus_version=2.22.2 ARG thanos_version=0.15.0 FROM golang:alpine as exporter diff --git a/docker/prometheus.conf b/docker/prometheus.conf index 56c9f37..ff79204 100644 --- a/docker/prometheus.conf +++ b/docker/prometheus.conf @@ -1,5 +1,5 @@ [program:prometheus] -command = /sidecars/bin/prometheus_targets.sh --config.file=/sidecars/etc/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention=2d --storage.tsdb.min-block-duration=30m --storage.tsdb.max-block-duration=30m --web.enable-lifecycle +command = sh /sidecars/bin/prometheus_targets.sh --config.file=/sidecars/etc/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention=2d --storage.tsdb.min-block-duration=30m --storage.tsdb.max-block-duration=30m --web.enable-lifecycle autostart = true autorestart = true startsecs = 5 diff --git a/grafana.tf b/grafana.tf index df58882..0aa2349 100644 --- a/grafana.tf +++ b/grafana.tf @@ -1,6 +1,6 @@ module "grafana" { source = "philips-labs/grafana/cloudfoundry" - version = ">= 0.3.0" + version = ">= 0.5.0" count = var.enable_grafana ? 1 : 0 enable_postgres = var.enable_grafana_postgres diff --git a/outputs.tf b/outputs.tf index 72d0243..b42bcfe 100644 --- a/outputs.tf +++ b/outputs.tf @@ -5,7 +5,7 @@ output "cluster_id" { output "thanos_query_endpoint" { description = "URL of Thanos deployment" - value = cloudfoundry_route.thanos_query.endpoint + value = var.thanos_public_endpoints ? cloudfoundry_route.thanos_query.endpoint : "${cloudfoundry_route.thanos_query_internal.endpoint}:9090" } output "grafana_endpoint" { @@ -21,4 +21,14 @@ output "thanos_space_id" { output "thanos_app_id" { description = "App id for Thanos" value = cloudfoundry_app.thanos.id +} + +output "grafana_app_id" { + description = "App id for Grafana" + value = join("", module.grafana.*.grafana_id) +} + +output "thanos_query_app_id" { + description = "App id for Thanos Query" + value = cloudfoundry_app.thanos_query.id } \ No newline at end of file diff --git a/thanos.tf b/thanos.tf index 407bbf6..fc40a45 100644 --- a/thanos.tf +++ b/thanos.tf @@ -1,3 +1,7 @@ +locals { + thanos_routes = var.thanos_public_endpoints ? [cloudfoundry_route.thanos.id, cloudfoundry_route.thanos_internal.id] : [cloudfoundry_route.thanos_internal.id] +} + resource "cloudfoundry_app" "thanos" { name = "thanos" space = cloudfoundry_space.space.id @@ -10,16 +14,15 @@ resource "cloudfoundry_app" "thanos" { } environment = var.environment - routes { - route = cloudfoundry_route.thanos.id - } - routes { - route = cloudfoundry_route.thanos_internal.id + dynamic "routes" { + for_each = local.thanos_routes + content { + route = routes.value + } } service_binding { service_instance = cloudfoundry_service_instance.s3.id } - } resource "cloudfoundry_route" "thanos" { diff --git a/thanos_query.tf b/thanos_query.tf index 38a52aa..7e69863 100644 --- a/thanos_query.tf +++ b/thanos_query.tf @@ -1,3 +1,7 @@ +locals { + thanos_query_routes = var.thanos_public_endpoints ? [cloudfoundry_route.thanos_query.id, cloudfoundry_route.thanos_query_internal.id] : [cloudfoundry_route.thanos_query_internal.id] +} + resource "cloudfoundry_app" "thanos_query" { name = "thanos-query" space = cloudfoundry_space.space.id @@ -10,11 +14,12 @@ resource "cloudfoundry_app" "thanos_query" { } environment = var.environment command = "/sidecars/bin/thanos query --grpc-address=0.0.0.0:10901 --http-address=0.0.0.0:9090 --store=${cloudfoundry_route.thanos_internal.endpoint}:19090 --store=${cloudfoundry_route.thanos_store_internal.endpoint}:19090" - routes { - route = cloudfoundry_route.thanos_query.id - } - routes { - route = cloudfoundry_route.thanos_query_internal.id + + dynamic "routes" { + for_each = local.thanos_query_routes + content { + route = routes.value + } } } diff --git a/variables.tf b/variables.tf index de33b12..65d9b25 100644 --- a/variables.tf +++ b/variables.tf @@ -38,6 +38,11 @@ variable "thanos_store_image" { type = string } +variable "thanos_public_endpoints" { + description = "Make Thanos public endpoint" + type = bool + default = true +} variable "enable_grafana" { description = "Adds a Grafana deployment when enabled"