[profiles] Override node agent env vars with profiles
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
agentcontainer should have env varTEST: 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
agentcontainer for a profile-created node agent had env varTEST:testbut the node agent container that wasn't created by the profile still hadTEST:foo. The profile-created node agent should also have bothTEST_VALUE_FROMandANOTHER_VALUE_FROMset to the node'sstatus.hostIP. The trace agent should haveTRACE_TEST:trace_testand 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/ordependencies - [x] PR has a milestone or the
qa/skip-qalabel
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 55.01%. Comparing base (
979aa8e) to head (4519c95). Report is 363 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1256 +/- ##
=======================================
Coverage 55.01% 55.01%
=======================================
Files 243 243
Lines 28002 28003 +1
=======================================
+ Hits 15404 15405 +1
Misses 11729 11729
Partials 869 869
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 55.01% <100.00%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...is/datadoghq/v1alpha1/datadogagentprofile_types.go | 100.00% <ø> (ø) |
|
| pkg/agentprofile/agent_profile.go | 63.32% <100.00%> (+0.14%) |
:arrow_up: |
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 979aa8e...4519c95. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.