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

Support changing pod collector annotations #451

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

indrekj
Copy link
Contributor

@indrekj indrekj commented Oct 5, 2021

This allows setting podAnnotations, e.g:

---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: opentelemetry
  annotations:
    foo: "this won't be applied to pods"
spec:
  mode: deployment
  podAnnotations:
    ad.datadoghq.com/otc-container.check_names: '["openmetrics"]'
    ad.datadoghq.com/otc-container.init_configs: '[{}]'
    ad.datadoghq.com/otc-container.instances: |-
      [
        {
          "prometheus_url": "http://%%host%%:8888/metrics",
          "namespace": "opentelemetry.collector",
          "metrics": [
            {"otelcol_exporter_queue_size": "exporter.queue_size"},
            {"otelcol_exporter_send_failed_spans": "exporter.send_failed_spans"},
            {"otelcol_exporter_sent_spans": "exporter.sent_spans"},
          ]
        }
      ]
  # ...

Fixes #426

@indrekj indrekj marked this pull request as ready for review October 5, 2021 12:20
@indrekj indrekj requested review from a team and dmitryax October 5, 2021 12:20
api/v1alpha1/opentelemetrycollector_types.go Outdated Show resolved Hide resolved
@@ -46,7 +46,7 @@ func DaemonSet(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Annotations: otelcol.Annotations,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add an entry to the changelog (perhaps after this is merged?) about this? This can be considered a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like a separate PR after this? I can do that. I could also add it to changelog right now under (unreleased) version if that's ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be fine as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@jpkrohling
Copy link
Member

Looks good to me. It would be even better if you could add a new e2e test, which serves as an example as well. Like this: https://github.com/open-telemetry/opentelemetry-operator/tree/main/tests/e2e/smoke-statefulset

This allows setting podAnnotations, e.g:
```
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: opentelemetry
  annotations:
    foo: "this won't be applied to pods"
spec:
  mode: deployment
  podAnnotations:
    ad.datadoghq.com/otc-container.check_names: '["openmetrics"]'
    ad.datadoghq.com/otc-container.init_configs: '[{}]'
    ad.datadoghq.com/otc-container.instances: |-
      [
        {
          "prometheus_url": "http://%%host%%:8888/metrics",
          "namespace": "opentelemetry.collector",
          "metrics": [
            {"otelcol_exporter_queue_size": "exporter.queue_size"},
            {"otelcol_exporter_send_failed_spans": "exporter.send_failed_spans"},
            {"otelcol_exporter_sent_spans": "exporter.sent_spans"},
          ]
        }
      ]
  # ...
```

Fixes open-telemetry#426
@indrekj
Copy link
Contributor Author

indrekj commented Oct 5, 2021

@jpkrohling Added e2e test as well.

@jpkrohling jpkrohling enabled auto-merge (squash) October 6, 2021 10:32
@jpkrohling
Copy link
Member

Looks great, thanks!

@jpkrohling jpkrohling merged commit a3e5026 into open-telemetry:main Oct 6, 2021
@indrekj indrekj deleted the pod-annotations branch October 6, 2021 10:46
shree007 pushed a commit to shree007/opentelemetry-operator that referenced this pull request Dec 12, 2021
This allows setting podAnnotations, e.g:
```
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: opentelemetry
  annotations:
    foo: "this won't be applied to pods"
spec:
  mode: deployment
  podAnnotations:
    ad.datadoghq.com/otc-container.check_names: '["openmetrics"]'
    ad.datadoghq.com/otc-container.init_configs: '[{}]'
    ad.datadoghq.com/otc-container.instances: |-
      [
        {
          "prometheus_url": "http://%%host%%:8888/metrics",
          "namespace": "opentelemetry.collector",
          "metrics": [
            {"otelcol_exporter_queue_size": "exporter.queue_size"},
            {"otelcol_exporter_send_failed_spans": "exporter.send_failed_spans"},
            {"otelcol_exporter_sent_spans": "exporter.sent_spans"},
          ]
        }
      ]
  # ...
```

Fixes open-telemetry#426
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
This allows setting podAnnotations, e.g:
```
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: opentelemetry
  annotations:
    foo: "this won't be applied to pods"
spec:
  mode: deployment
  podAnnotations:
    ad.datadoghq.com/otc-container.check_names: '["openmetrics"]'
    ad.datadoghq.com/otc-container.init_configs: '[{}]'
    ad.datadoghq.com/otc-container.instances: |-
      [
        {
          "prometheus_url": "http://%%host%%:8888/metrics",
          "namespace": "opentelemetry.collector",
          "metrics": [
            {"otelcol_exporter_queue_size": "exporter.queue_size"},
            {"otelcol_exporter_send_failed_spans": "exporter.send_failed_spans"},
            {"otelcol_exporter_sent_spans": "exporter.sent_spans"},
          ]
        }
      ]
  # ...
```

Fixes open-telemetry#426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to add annotations to Pods
2 participants