Skip to content

[datadog-operator] Expose DCA Agent Sidecar TLS Config#2700

Merged
levan-m merged 5 commits intomainfrom
gabedos/dca-ca-cert-perms
Apr 7, 2026
Merged

[datadog-operator] Expose DCA Agent Sidecar TLS Config#2700
levan-m merged 5 commits intomainfrom
gabedos/dca-ca-cert-perms

Conversation

@gabedos
Copy link
Copy Markdown
Contributor

@gabedos gabedos commented Mar 4, 2026

What does this PR do?

Expose config option + creates RBACs for creating and mounting the cluster agent's certificate onto agent sidecar container it creates in application namespaces.

Motivation

Expose config option for new Agent feature for TLS communication on agent sidecar in admission controller

Minimum Agent Versions

This feature works only with newer Agent versions. However, the configmap rbac is fine to be applied everywhere.

  • Agent: v7.78.0+
  • Cluster Agent: v7.78.0+

Describe your test plan

Apply the following agent crd config

apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog-test-tls
  namespace: system
spec:
  global:
    credentials:
      apiSecret:
        secretName: datadog-secret
        keyName: api-key
      appSecret:
        secretName: datadog-secret
        keyName: app-key
  features:
    admissionController:
      enabled: true
      agentSidecarInjection:
        enabled: true
        provider: fargate
        clusterAgentTlsVerification:
          enabled: true
          copyCaConfigMap: true

Check that the configmaps rbacs are present on the dca role

kubectl get clusterrole datadog-test-tls-cluster-agent -o yaml | grep -A 5 "configmaps"
  - configmaps
  verbs:
  - create
  - get
  - list
  - update

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

@gabedos gabedos changed the title Gabedos/dca ca cert perms [datadog-operator] Expose DCA Agent Sidecar TLS Config Mar 4, 2026
@gabedos gabedos added the enhancement New feature or request label Mar 4, 2026
@gabedos gabedos added this to the v1.25.0 milestone Mar 4, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 72.97297% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.70%. Comparing base (f662670) to head (4125b4a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/testutils/builder.go 0.00% 8 Missing ⚠️
...atadogagent/feature/admissioncontroller/feature.go 93.75% 0 Missing and 1 partial ⚠️
...r/datadogagent/feature/admissioncontroller/rbac.go 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2700      +/-   ##
==========================================
+ Coverage   39.23%   39.70%   +0.47%     
==========================================
  Files         314      314              
  Lines       27296    27698     +402     
==========================================
+ Hits        10709    10998     +289     
- Misses      15798    15899     +101     
- Partials      789      801      +12     
Flag Coverage Δ
unittests 39.70% <72.97%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...atadogagent/feature/admissioncontroller/feature.go 70.34% <93.75%> (+1.47%) ⬆️
...r/datadogagent/feature/admissioncontroller/rbac.go 90.80% <92.30%> (+1.19%) ⬆️
pkg/testutils/builder.go 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f662670...4125b4a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gabedos gabedos marked this pull request as ready for review March 4, 2026 13:36
@gabedos gabedos requested a review from a team March 4, 2026 13:36
@gabedos gabedos requested review from a team as code owners March 4, 2026 13:36
@cswatt
Copy link
Copy Markdown
Contributor

cswatt commented Mar 4, 2026

For documentation styleguide reasons, can we capitalize Cluster Agent and Agent?

@cswatt cswatt self-assigned this Mar 4, 2026
Copy link
Copy Markdown
Contributor

@cswatt cswatt left a comment

Choose a reason for hiding this comment

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

thank you!

@gabedos gabedos modified the milestones: v1.25.0, v1.26.0 Mar 19, 2026
f.agentSidecarConfig.tlsVerificationEnabled = apiutils.BoolValue(sidecarConfig.ClusterAgentTLSVerification.Enabled)
}
if sidecarConfig.ClusterAgentTLSVerification.CopyCaConfigMap != nil {
f.agentSidecarConfig.tlsVerificationCopyCaConfigMap = apiutils.BoolValue(sidecarConfig.ClusterAgentTLSVerification.CopyCaConfigMap)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we set this (and pass env var to DCA) even if ClusterAgentTLSVerification.Enabled == false?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would be nice to have unit test confirming expected behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add a unit test for this to confirm that the values are being set properly.

But I think it should be fine to pass the envvar to DCA even if it's explicitly set to false on the Operator. Generally, I think this should be good to do because Agent defaults can change and I'd want a manually defined false by the Operator user to still apply.

levan-m and others added 2 commits April 3, 2026 16:14
Previously the sidecar TLS verification env vars were only set when
enabled=true. This changes the fields to *bool so the env vars are
always passed to DCA when explicitly configured, even when false,
preventing Agent default changes from overriding user intent.

Adds unit tests for both enabled and explicitly disabled cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gabedos gabedos force-pushed the gabedos/dca-ca-cert-perms branch from c90240e to 4125b4a Compare April 4, 2026 12:50
@levan-m levan-m merged commit 52ba052 into main Apr 7, 2026
37 checks passed
@levan-m levan-m deleted the gabedos/dca-ca-cert-perms branch April 7, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants