service discovery: Add operator support
What does this PR do?
Adds service-discovery check to the operator.
Motivation
Allow to control service-discovery from the operator.
Additional Notes
Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
- Agent: v7.58.0
- Cluster Agent: N/A
Describe your test plan
- Create
kindcluster - Follow instructions installations instructions https://github.com/DataDog/datadog-operator/blob/main/docs/how-to-contribute.md#testing-the-operator-for-development
- Use the following configuration
apiVersion: datadoghq.com/v2alpha1 kind: DatadogAgent metadata: name: datadog spec: global: env: - name: DD_HOSTNAME value: "example-kind" clusterName: my-example-cluster credentials: apiSecret: secretName: datadog-secret keyName: api-key appSecret: secretName: datadog-secret keyName: app-key features: serviceDiscovery: enabled: true override: nodeAgent: image: tag: 7.58.0-rc.10-linux-jmx - Use
api keyto ddstaging - Wait 5m and check you have entries in https://ddstaging.datadoghq.com/ddsql/editor?q=SELECT%20%0A%20%20%20%20a.%2A%0AFROM%20%0A%20%20%20%20discovered_service%20AS%20a%0Awhere%20a.host_name%20%3D%20%27host-kind%27%0AORDER%20BY%20%0A%20%20%20%20a.start_time&query_timeframe_end=1728826119007&query_timeframe_mode=sliding&query_timeframe_start=1728822519007
Checklist
- [x] PR has at least one valid label:
bug,enhancement,refactoring,documentation,tooling, and/ordependencies - [x] PR has a milestone or the
qa/skip-qalabel
Codecov Report
Attention: Patch coverage is 73.33333% with 20 lines in your changes missing coverage. Please review.
Project coverage is 48.95%. Comparing base (
009f82d) to head (9757d42).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...r/datadogagent/feature/servicediscovery/feature.go | 83.33% | 9 Missing and 1 partial :warning: |
| internal/controller/testutils/agent.go | 0.00% | 10 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1449 +/- ##
==========================================
+ Coverage 48.86% 48.95% +0.09%
==========================================
Files 225 226 +1
Lines 19959 20034 +75
==========================================
+ Hits 9753 9808 +55
- Misses 9695 9714 +19
- Partials 511 512 +1
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 48.95% <73.33%> (+0.09%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| api/datadoghq/v2alpha1/datadogagent_default.go | 89.88% <100.00%> (+0.14%) |
:arrow_up: |
| api/datadoghq/v2alpha1/datadogagent_types.go | 100.00% <ø> (ø) |
|
| internal/controller/datadogagent/controller.go | 55.17% <ø> (ø) |
|
| ...r/datadogagent/feature/servicediscovery/feature.go | 83.33% <83.33%> (ø) |
|
| internal/controller/testutils/agent.go | 0.00% <0.00%> (ø) |
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 009f82d...9757d42. Read the comment docs.
Test case didn't work for me, the query doesn't give me any results, is this expected?
Which hostname did you use? Did you verify the api key belongs with ddstaging?
Otherwise, change looks good. Confirmed trace-agent container and DD_SERVICE_DISCOVERY are added correctly.
The change does not affect trace-agent, but system-probe and agent
I'm not sure what happened but today I can see data populated in the table. I tried both example-levan and example-kind.
Regarding system-probe, sorry for confusion I misread the container name added after enabling the feature.