Skip to content

Exposes the ApiServerCache option in the datadog operator#3072

Merged
sehgal23 merged 5 commits into
mainfrom
arnav.sehgal/contint-5326/exposes-APIServerCache-option-operator
Jun 9, 2026
Merged

Exposes the ApiServerCache option in the datadog operator#3072
sehgal23 merged 5 commits into
mainfrom
arnav.sehgal/contint-5326/exposes-APIServerCache-option-operator

Conversation

@sehgal23

@sehgal23 sehgal23 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Exposes the KSM use_apiserver_cache config option via a DatadogAgent annotation.

Motivation

What inspired you to submit this pull request?

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

I spun up a local Kubernetes cluster using Colima and Minikube.

Built the operator image locally and loaded it into the cluster.

Updated the CRD to pick up the new useApiServerCache field.

Created the required secrets and applied a DatadogAgent resource with the agent.datadoghq.com/ksm-use-apiserver-cache annotation set to "true":

 apiVersion: datadoghq.com/v2alpha1
  kind: DatadogAgent                                                                
  metadata:
    name: datadog
    annotations:
      agent.datadoghq.com/ksm-use-apiserver-cache: "true"
  spec:                                                                             
    global:
      clusterName: minikube
      credentials:
        apiSecret:
          secretName: datadog-secret
          keyName: api-key
    features:
      kubeStateMetricsCore:
        enabled: true

Verified that the operator generated the KSM Core check ConfigMap with the expected configuration:

kubectl -n system get configmap datadog-kube-state-metrics-core-config -o yaml
image

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)

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 2, 2026

Copy link
Copy Markdown

Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 44.34% (+1.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 884dd8f | Docs | Datadog PR Page | Give us feedback!

@sehgal23 sehgal23 added the enhancement New feature or request label Jun 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd44553d05

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/controller/datadogagent/feature/kubernetesstatecore/configmap.go Outdated
@codecov-commenter

codecov-commenter commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.06%. Comparing base (b1ebe71) to head (884dd8f).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3072      +/-   ##
==========================================
+ Coverage   43.00%   44.06%   +1.05%     
==========================================
  Files         340      350      +10     
  Lines       29330    30875    +1545     
==========================================
+ Hits        12614    13604     +990     
- Misses      15892    16374     +482     
- Partials      824      897      +73     
Flag Coverage Δ
unittests 44.06% <100.00%> (+1.05%) ⬆️

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

Files with missing lines Coverage Δ
...adogagent/feature/kubernetesstatecore/configmap.go 97.29% <100.00%> (+0.07%) ⬆️
...atadogagent/feature/kubernetesstatecore/feature.go 79.71% <100.00%> (+0.45%) ⬆️
...nal/controller/datadogagent/feature/utils/utils.go 0.00% <ø> (ø)

... and 30 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

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

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

@wdhif
wdhif self-requested a review June 3, 2026 13:40

@wdhif wdhif left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @sehgal23 👋

To avoid the DatadogAgent CRD becoming bloated, we need to be sure that a specific field is needed before adding it. Given that this setting might very well become a default, I'm not sure that it make sense to support it through the RFC assuming it can be also changed through environment variables or mounted KSM configuration for specific cases?

Thanks!

@sehgal23
sehgal23 merged commit 68287b2 into main Jun 9, 2026
44 of 45 checks passed
@sehgal23
sehgal23 deleted the arnav.sehgal/contint-5326/exposes-APIServerCache-option-operator branch June 9, 2026 14:35
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.

7 participants