Skip to content

Operator provisions services in spec.mode: sidecar which do not make sense #4934

@michaelalang

Description

@michaelalang

Component(s)

collector

What happened?

Description

When using the opertator to deploy a collector in sidecar mode, it still populates services for the configuration which doesn't make sense.

kubectl exec -ti deploy/http -- curl sidecar-collector.reproducer.svc.cluster.local:4318/v1/metrics -H "content-type: application/json" -d '{}'
curl: (7) Failed to connect to sidecar-collector.reproducer.svc.cluster.local port 4318: Connection refused

Steps to Reproduce

cat <<'EOF' | kubectl create -f-
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
  name: sidecar
spec:
  config:
    exporters:
      debug: {}
    receivers:
      otlp:
        protocols:
          grpc:
            endpoint: 0.0.0.0:4317
          http:
            endpoint: 0.0.0.0:4318
    service:
      pipelines:
        traces:
          exporters:
            - debug
          receivers:
            - otlp
      telemetry:
        metrics:
          readers:
            - pull:
                exporter:
                  prometheus:
                    host: 0.0.0.0
                    port: 8888
  configVersions: 3
  daemonSetUpdateStrategy: {}
  deploymentUpdateStrategy: {}
  ingress:
    route: {}
  ipFamilyPolicy: SingleStack
  managementState: managed
  mode: sidecar
  networkPolicy:
    enabled: true
  observability:
    metrics: {}
  podDnsConfig: {}
  replicas: 1
  resources: {}
  upgradeStrategy: automatic

Operator creates the services: -collector, -collector-headless, -collector-monitoring
like

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: opentelemetry-collector
    app.kubernetes.io/managed-by: opentelemetry-operator
    app.kubernetes.io/name: sidecar-collector
    app.kubernetes.io/part-of: opentelemetry
    app.kubernetes.io/version: latest
    operator.opentelemetry.io/collector-service-type: base
  name: sidecar-collector
spec:
  internalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  ports:
    - appProtocol: grpc
      name: otlp-grpc
      port: 4317
      protocol: TCP
      targetPort: 4317
    - appProtocol: http
      name: otlp-http
      port: 4318
      protocol: TCP
      targetPort: 4318
  selector:
    app.kubernetes.io/component: opentelemetry-collector
    app.kubernetes.io/instance: reproducer.sidecar
    app.kubernetes.io/managed-by: opentelemetry-operator
    app.kubernetes.io/part-of: opentelemetry
  sessionAffinity: None
  type: ClusterIP

those are not accessible in sidecar as the pod does not expose the initContainer ports accordingly.

Expected Result

No services populated when using spec.mode: sidecar

Actual Result

Services without any use poluting the namespace and the kubernetes API

Kubernetes Version

1.30+

Operator version

0.144.0

Collector version

0.144.0

Environment information

Environment

OS: OpenShift 4.18+
Compiler(if manually compiled): (e.g., "go 14.2")

Log output

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:collectorIssues for deploying collectorbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions