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

Unable to expose health_check port from the container #1418

Open
perry-mitchell opened this issue Nov 18, 2024 · 3 comments
Open

Unable to expose health_check port from the container #1418

perry-mitchell opened this issue Nov 18, 2024 · 3 comments
Labels
chart:collector Issue related to opentelemetry-collector helm chart question Further information is requested

Comments

@perry-mitchell
Copy link

perry-mitchell commented Nov 18, 2024

I can't seem to get the healthcheck port exposed for some reason. I'm creating the release in terraform:

locals {
  collector_version = "0.104.0"
}

resource "helm_release" "opentelemetry-collector" {
  name       = "opentelemetry-collector"
  repository = "https://open-telemetry.github.io/opentelemetry-helm-charts"
  chart      = "opentelemetry-collector"
  version    = local.collector_version
  namespace  = var.namespace
  timeout    = 180
  wait       = true

  values = [yamlencode({
    mode = "deployment"

    replicaCount = 1

    image = {
      repository = "otel/opentelemetry-collector-contrib"
    }

    command = {
      extraArgs = [
        "--feature-gates=-component.UseLocalHostAsDefaultHost"
      ]
    }

    livenessProbe = {
      httpGet = {
        port = 13133
        path = "/health"
      }
    }

    readinessProbe = {
      httpGet = {
        port = 13133
        path = "/health"
      }
    }

    service = {
      enabled = true
    }

    serviceAccount = {
      create = true
      annotations = {
        "eks.amazonaws.com/role-arn" = aws_iam_role.otel_collector.arn
      }
    }

    presets = {}

    config = local.otel_config
  })]
}

Current config:

        health_check         = {
          endpoint = "$${env:MY_POD_IP}:13133"
          path = "/health"
          response_body = {
            healthy = "OK"
          }
        }

(Though I've tried it with no options as well).

Yet it won't expose port 13133:

Controlled By:  ReplicaSet/opentelemetry-collector-57bbcb5fc8
Containers:
  opentelemetry-collector:
    Container ID:  containerd://9307ee70b33a5f1a4d3a5d96b99df99b870edc1c59d196d3e95a5375da9a3ae0
    Image:         otel/opentelemetry-collector-contrib:0.108.0
    Image ID:      docker.io/otel/opentelemetry-collector-contrib@sha256:923eb1cfae32fe09676cfd74762b2b237349f2273888529594f6c6ffe1fb3d7e
    Ports:         6831/UDP, 14250/TCP, 14268/TCP, 4317/TCP, 4318/TCP, 9411/TCP
    Host Ports:    0/UDP, 0/TCP, 0/TCP, 0/TCP, 0/TCP, 0/TCP
    Args:
      --config=/conf/relay.yaml
      --feature-gates=-component.UseLocalHostAsDefaultHost
    State:          Running
      Started:      Mon, 18 Nov 2024 15:31:34 +0200

Looking at the ports configuration in the chart values, there doesn't even seem to be an entry for the healthcheck.

Additionally, the created service for the collector, when enabled, does not expose such a port either.

@TylerHelmuth TylerHelmuth added bug Something isn't working chart:collector Issue related to opentelemetry-collector helm chart question Further information is requested and removed bug Something isn't working labels Nov 21, 2024
@TylerHelmuth
Copy link
Member

@perry-mitchell by default the chart doesn't not expose the port on the container. You can see a simple example here: https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/examples/daemonset-only/rendered/daemonset.yaml.

If you need to add a port to the container you can use .Values.ports:

@perry-mitchell
Copy link
Author

by default the chart doesn't not expose the port on the container.

Wouldn't it make sense to expose it, even by default, so it could be used as a healthcheck downstream?

.Values.ports

This doesn't work, and the helm chart throws an exception when I add a new port name that isn't listed there. I don't have the error on-hand anymore, unfortunately.

@TylerHelmuth
Copy link
Member

This configuration worked for me:

ports:
  healthcheck:
    enabled: true
    containerPort: 13133
    servicePort: 13133
    protocol: TCP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart:collector Issue related to opentelemetry-collector helm chart question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants