Skip to content

[ACTP] Use Config maps for par deploy in dca#2659

Merged
merchristK merged 4 commits intomainfrom
merchristk-ACTP-use-cm
Feb 27, 2026
Merged

[ACTP] Use Config maps for par deploy in dca#2659
merchristK merged 4 commits intomainfrom
merchristk-ACTP-use-cm

Conversation

@merchristK
Copy link
Contributor

@merchristK merchristK commented Feb 26, 2026

What does this PR do?

When deploying PAR in DCA, use configmap and volume mounts instead of adding envvar

Motivation

We want to do this because:

  • It's more scalable: anytime the config changes, we shouldn't be updating the operator to support new configs.
  • For consistency since node agent uses cm as well

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: v7.77.x
  • Cluster Agent: v7.77.x

Describe your test plan

Build and deploy the operator locally

Commands
# Build the operator image
make IMG=datadog/datadog-operator:test-par docker-build

# Install CRDs
make install

# Deploy the operator
make IMG=datadog/datadog-operator:test-par deploy

Apply the DatadogAgent object in a local k8s cluster

datadog-agent.yaml
apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog
  annotations:
    agent.datadoghq.com/private-action-runner-enabled: "true"
    agent.datadoghq.com/private-action-runner-configdata: |
      private_action_runner:
        enabled: true
        self_enroll: true
        actions_allowlist:
          - com.datadoghq.gitlab.*
          - com.datadoghq.script.*
          - com.datadoghq.kubernetes.core.*
    cluster-agent.datadoghq.com/private-action-runner-enabled: "true"
    cluster-agent.datadoghq.com/private-action-runner-configdata: |
      private_action_runner:
        enabled: true
        self_enroll: true
        actions_allowlist:
          - com.datadoghq.gitlab.*
          - com.datadoghq.script.*
          - com.datadoghq.kubernetes.core.*

spec:
  global:
    clusterName: mmklearning.docker-desktop
    site: datadoghq.com
    credentials:
      apiSecret:
        secretName: datadog-secret
        keyName: api-key
      appSecret:
        secretName: datadog-secret
        keyName: app-key
    kubelet:
      tlsVerify: false
  override:
    nodeAgent:
      image:
        # name: datadog/agent:7.76.0-rc.1
        name: some-internal-image
        pullPolicy: Always
    clusterAgent:
      replicas: 3
      image:
        # name: datadog/agent:7.76.0-rc.1
        name: some-internal-image
        pullPolicy: IfNotPresent
  features:
    logCollection:
      enabled: true
      containerCollectAll: true
    liveContainerCollection:
      enabled: true
kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - datadog-agent.yaml

secretGenerator:
  - envs:
      - .env
    name: datadog-secret
    namespace: datadog-operator

generatorOptions:
  disableNameSuffixHash: true

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)

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@merchristK merchristK added enhancement New feature or request qa/skip-qa labels Feb 26, 2026
@merchristK merchristK marked this pull request as ready for review February 26, 2026 14:23
@merchristK merchristK requested a review from a team February 26, 2026 14:23
@merchristK merchristK requested a review from a team as a code owner February 26, 2026 14:23
@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 84.14634% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.69%. Comparing base (6489f08) to head (e609c17).

Files with missing lines Patch % Lines
...atadogagent/feature/privateactionrunner/feature.go 84.05% 6 Missing and 5 partials ⚠️
...datadogagent/feature/privateactionrunner/config.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2659      +/-   ##
==========================================
+ Coverage   38.59%   38.69%   +0.10%     
==========================================
  Files         307      307              
  Lines       26471    26525      +54     
==========================================
+ Hits        10216    10265      +49     
  Misses      15494    15494              
- Partials      761      766       +5     
Flag Coverage Δ
unittests 38.69% <84.14%> (+0.10%) ⬆️

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

Files with missing lines Coverage Δ
...r/datadogagent/feature/privateactionrunner/rbac.go 100.00% <100.00%> (ø)
...datadogagent/feature/privateactionrunner/config.go 97.82% <80.00%> (-2.18%) ⬇️
...atadogagent/feature/privateactionrunner/feature.go 77.21% <84.05%> (+7.49%) ⬆️

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 6489f08...e609c17. Read the comment docs.

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

Comment on lines +214 to +225
podTemplate := managers.PodTemplateSpec()
for i, container := range podTemplate.Spec.Containers {
if container.Name == string(apicommon.ClusterAgentContainerName) {
// Set command if not already set (default is from Dockerfile)
// See https://github.com/DataDog/datadog-agent/blob/06ea6848b891e08d34753e452be7f3c9bacbf407/Dockerfiles/cluster-agent/Dockerfile#L123
if len(container.Command) == 0 {
podTemplate.Spec.Containers[i].Command = []string{"datadog-cluster-agent", "start"}
}
// Add -E flag to command
podTemplate.Spec.Containers[i].Command = append(podTemplate.Spec.Containers[i].Command, fmt.Sprintf("-E=%s", PrivateActionRunnerConfigPath))
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

feels like they should be a higher level API rather than us patching it like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum the only thing I could find in the manager that would fit was this one

type PodTemplateManagers interface {

Let me ask container-platform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems there are also examples of such usage

@merchristK merchristK added this to the v1.25.0 milestone Feb 26, 2026
Copy link
Member

@tbavelier tbavelier left a comment

Choose a reason for hiding this comment

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

nit but "breaking change" compared to previous version: with this version, the annotation does not take "priority" over the configdata, meaning a user with:

    cluster-agent.datadoghq.com/private-action-runner-enabled: "true"
    cluster-agent.datadoghq.com/private-action-runner-configdata: |
      private_action_runner:
        enabled: false
        self_enroll: true
        identity_secret_name: datadog-par-identity
        actions_allowlist:
          - com.datadoghq.http.request
          - com.datadoghq.kubernetes.core.listPod
          - com.datadoghq.traceroute

will not have PAR enabled since the enabled stays the same in the CM.

Also not in scope of this PR, but instead of having the conditional for the RBAC in rbac.go (if config == nil || !config.Enabled || !config.SelfEnroll), could we please move it to feature.go before calling managers.RBACManager().AddPolicyRules( ? That way, we avoid creating an empty role when self-enroll is false and it's clearer when we do add rbacs. Moreover, that simplifies the conditional to simply config.SelfEnroll considering in ManageDependencies, we are already in a block f.clusterConfig != nil && f.clusterConfig.Enabled:

		// Add RBAC for secret access during self-enrollment
		if f.clusterConfig.SelfEnroll {
			rbacResourcesName := getPrivateActionRunnerRbacResourcesName(f.owner)
			if err := managers.RBACManager().AddPolicyRules(
				f.owner.GetNamespace(),
				rbacResourcesName,
				f.clusterServiceAccountName,
				getClusterAgentRBACPolicyRules(f.clusterConfig),
			); err != nil {
				return err
			}
		}

@merchristK merchristK force-pushed the merchristk-ACTP-use-cm branch from 11973c7 to b8a5ea0 Compare February 27, 2026 10:14
@merchristK merchristK requested review from a team and dd-gplassard February 27, 2026 10:14
@merchristK merchristK merged commit 782748b into main Feb 27, 2026
35 checks passed
@merchristK merchristK deleted the merchristk-ACTP-use-cm branch February 27, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants