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

Sidecar injection by instance name not documented #214

Closed
seanhoughton opened this issue Feb 27, 2021 · 5 comments · Fixed by #217
Closed

Sidecar injection by instance name not documented #214

seanhoughton opened this issue Feb 27, 2021 · 5 comments · Fixed by #217
Assignees
Labels
bug Something isn't working

Comments

@seanhoughton
Copy link

I've been looking through source code and issues to try to understand how to use the sidecar injection. It looks like the annotation can be either "true" or an OpenTelemetryCollector instance name. I haven't been able to get it working yet, but I'm not sure if that's because the operator is misconfigured or my annotations are incorrect.

Here's what I've gathered from the source code and the CRD yaml

Annotations

sidecar.opentelemetry.io/inject can be one of true, false, or an instance name. I take this to mean that it can refer to a specific instance of an OpenTelemetryCollector.

Collector configuration

spec.mode can be one of

  • daemonset
  • deployment
  • sidecar

If set to sidecar mode it will only create an instance if it's referenced by an annotation on a Deployment.

In my case I want a custom configuration for a specific Deployment so it appears I have to create an instance of an OpelTelemetryCollector and reference it by name in the Deployment's sidecar.opentelemetry.io/inject` annotation. However, no sidecars are injected and I don't see anything interesting in the logs for the opentelemetry controller manager.

Should the following work?

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: my-custom-collector
spec:
  mode: sidecar
  config: |
    receivers:
      otlp:
        protocols:
          grpc:
            endpoint: 0.0.0.0:4317
    exporters:
      otlp:
        endpoint: upstream:4317
        insecure: true
    service:
      pipelines:
        traces:
          receivers: [otlp]
          exporters: [otlp]
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    app: my-app
  annotations:
    "sidecar.opentelemetry.io/inject": "my-custom-collector"
spec:
  selector:
    matchLabels:
      app: my-app
  replicas: 1
  template:
    metadata:
      labels:
        app: m-app
    spec:
      containers:
# etc
@jpkrohling
Copy link
Member

Yes, it should indeed work. I'll take a look and see if anything recently broke this.

@jpkrohling jpkrohling self-assigned this Mar 1, 2021
@jpkrohling jpkrohling added the bug Something isn't working label Mar 1, 2021
@jpkrohling
Copy link
Member

I found the problem with your example: the annotation should be part of the PodTemplate, not the Deployment. I opened a PR adding some doc about the sidecars, along with an e2e test for it.

@seanhoughton
Copy link
Author

That was indeed the problem and now my actual service is working. Thanks for the operator, it's going to make things much easier and cleaner to manage!

@jpkrohling
Copy link
Member

@seanhoughton would you mind reviewing the linked PR, to see if the readme has now enough information to prevent such misunderstandings?

@seanhoughton
Copy link
Author

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants