datadog-operator icon indicating copy to clipboard operation
datadog-operator copied to clipboard

[profiles] Override node agent env vars with profiles

Open khewonc opened this issue 7 months ago • 1 comments

What does this PR do?

Adds the ability to override node agent env vars with profiles

Motivation

Internal request https://datadoghq.atlassian.net/browse/CECO-1225

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: n/a
  • Cluster Agent: n/a

Describe your test plan

  • Spin up the operator with profiles enabled
  • Deploy a DatadogAgent with an env var override for one of the agent containers. Example:
  override:
    nodeAgent:
      containers:
        agent:
          env:
            - name: TEST
              value: "foo"
  • Check that the override works. In the above example, the agent container should have env var TEST: foo
  • Apply a profile that:
    • overrides the DatadogAgent's env var
    • adds a new env var using value
    • adds a new env var using valueFrom
    override:
      nodeAgent:
        containers:
          agent:
            env:
            - name: TEST
              value: "test"
            - {name: TEST_VALUE_FROM, valueFrom: {fieldRef: {fieldPath: status.hostIP}}}
            - name: ANOTHER_VALUE_FROM
              valueFrom:
                fieldRef:
                  fieldPath: status.hostIP
            resources:
              limits:
                cpu: "0.25"
          trace-agent:
            env:
            - name: TRACE_TEST
              value: "trace_test"
  • Check for expected results. If using the above examples, we'd expect the agent container for a profile-created node agent had env var TEST:test but the node agent container that wasn't created by the profile still had TEST:foo. The profile-created node agent should also have both TEST_VALUE_FROM and ANOTHER_VALUE_FROM set to the node's status.hostIP. The trace agent should have TRACE_TEST:trace_test and the process agent shouldn't have any env var overrides
# profile-created node agent
# agent container
      TEST:                                                  test
      TEST_VALUE_FROM:                                        (v1:status.hostIP)
      ANOTHER_VALUE_FROM:                                     (v1:status.hostIP)
# trace agent container
      TRACE_TEST:                                trace_test

Checklist

  • [x] PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • [x] PR has a milestone or the qa/skip-qa label

khewonc avatar Jul 01 '24 21:07 khewonc