Skip to content

Commit

Permalink
add toggle for otel sidecar for cron (#486)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
  • Loading branch information
k4leung4 authored Aug 8, 2024
1 parent a052a7d commit a48060a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions modules/cron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_base_image"></a> [base\_image](#input\_base\_image) | The base image that will be used to build the container image. | `string` | `"cgr.dev/chainguard/static:latest-glibc"` | no |
| <a name="input_cpu"></a> [cpu](#input\_cpu) | The CPU limit for the job. | `string` | `"1000m"` | no |
| <a name="input_enable_otel_sidecar"></a> [enable\_otel\_sidecar](#input\_enable\_otel\_sidecar) | Enable otel sidecar for metrics | `bool` | `false` | no |
| <a name="input_env"></a> [env](#input\_env) | A map of custom environment variables (e.g. key=value) | `map` | `{}` | no |
| <a name="input_exec"></a> [exec](#input\_exec) | Whether to execute job on modify. | `bool` | `false` | no |
| <a name="input_execution_environment"></a> [execution\_environment](#input\_execution\_environment) | The execution environment to use for the job. | `string` | `""` | no |
Expand Down
18 changes: 11 additions & 7 deletions modules/cron/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@ resource "google_cloud_run_v2_job" "job" {
}
}
}
containers {
image = var.otel_collector_image
// config via env is an option; https://pkg.go.dev/go.opentelemetry.io/collector/service#section-readme
args = ["--config=env:OTEL_CONFIG"]
env {
name = "OTEL_CONFIG"
value = file("${path.module}/otel-config/config.yaml")

dynamic "containers" {
for_each = var.enable_otel_sidecar ? [1] : []
content {
image = var.otel_collector_image
// config via env is an option; https://pkg.go.dev/go.opentelemetry.io/collector/service#section-readme
args = ["--config=env:OTEL_CONFIG"]
env {
name = "OTEL_CONFIG"
value = file("${path.module}/otel-config/config.yaml")
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/cron/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ variable "success_alert_alignment_period_seconds" {
default = 0
}

variable "enable_otel_sidecar" {
description = "Enable otel sidecar for metrics"
type = bool
default = false
}

variable "otel_collector_image" {
type = string
default = "chainguard/opentelemetry-collector-contrib:latest"
Expand Down

0 comments on commit a48060a

Please sign in to comment.