Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same instance label value for network policies #1509

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

khewonc
Copy link
Contributor

@khewonc khewonc commented Nov 4, 2024

What does this PR do?

When creating the agent components, we set the instance label as <dda-name>-<component-suffix>. We need to use that as the pod selector when creating network policies or else they won't be targeting the correct pods.

Motivation

#1490

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: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

  • Create a DDA with network policies enabled:
spec:
  global:
    networkPolicy:
      create: true
      flavor: kubernetes
  • Check that the network policy pod selector uses the same instance label value that's on the corresponding pod. Example:
$ kubectl get networkpolicy
datadog-agent-agent                   app.kubernetes.io/instance=datadog-agent-agent,app.kubernetes.io/part-of=default-datadog--agent                   7h56m

The label key and value app.kubernetes.io/instance=datadog-agent-agent from the network policy should match the agent pod's instance label key and value. Double check that the part of labels match as well:

$ kubectl describe pod <agent-pod>
Labels:           agent.datadoghq.com/component=agent
                  [...]
                  app.kubernetes.io/instance=datadog-agent-agent
                  [...]
                  app.kubernetes.io/part-of=default-datadog--agent

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

@khewonc khewonc added the bug Something isn't working label Nov 4, 2024
@khewonc khewonc added this to the v1.11.0 milestone Nov 4, 2024
@khewonc khewonc requested a review from a team as a code owner November 4, 2024 22:20
@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 48.62%. Comparing base (b70d772) to head (2c4570e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ntroller/datadogagent/component/objects/network.go 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1509      +/-   ##
==========================================
- Coverage   48.63%   48.62%   -0.02%     
==========================================
  Files         227      227              
  Lines       20223    20219       -4     
==========================================
- Hits         9836     9832       -4     
  Misses       9871     9871              
  Partials      516      516              
Flag Coverage Δ
unittests 48.62% <50.00%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
...ntroller/datadogagent/component/objects/network.go 2.63% <50.00%> (-0.68%) ⬇️

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 b70d772...2c4570e. Read the comment docs.

---- 🚨 Try these New Features:

@khewonc khewonc merged commit 9d37612 into main Nov 22, 2024
20 checks passed
@khewonc khewonc deleted the khewonc/network-labels branch November 22, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants