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

[CONTP-519] Support k8s admin events in operator #1575

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

gabedos
Copy link
Contributor

@gabedos gabedos commented Dec 17, 2024

What does this PR do?

Adds support for the Kubernetes Admission Events configuration in the Operator.

Motivation

Allow customers to enabled the feature using the Operator

Additional Notes

N/A

Minimum Agent Versions

  • Cluster Agent: v7.62+

Describe your test plan

Load up the operator and apply the following agent configuration k apply -f datadog-agent.yaml

apiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
  name: datadog
  namespace: system
spec:
  global:
    kubelet:
      tlsVerify: false
    credentials:
      apiSecret:
        secretName: datadog-secret
        keyName: api-key
      appSecret:
        secretName: datadog-secret
        keyName: app-key
  features:
    admissionController:
      kubernetesAdmissionEvents:
        enabled: true

Note: depending on when you test this you may need to either get a custom cluster agent image build, one of the nightly image build tags, the release candidate image tag (late Dec), or utilize the officially published 7.62.0 image in late Jan. Eg.

  override:
    clusterAgent:
      image:
        name: cluster-agent
        tag: 7.62.0-rc.1

Then connect to the cluster agent and check for the status of the kubernetesAdmissionEvents webhook.

k exec -it datadog-cluster-agent-5f4f9f48c7-zdn75  -n system -- agent status | grep -A 8 "ValidatingWebhook"
      ValidatingWebhookConfigurations name: datadog-webhook
      Created at: 2024-12-17 20:22:06 +0000 UTC
      ---------
        Name: datadog.webhook.kubernetes.admission.events
        CA bundle digest: ff3c27c367a36ce2
        Object selector: &LabelSelector{MatchLabels:map[string]string{},MatchExpressions:[]LabelSelectorRequirement{LabelSelectorRequirement{Key:admission.datadoghq.com/enabled,Operator:NotIn,Values:[false],},},}
        Rule 1: Operations: [*] - APIGroups: [apps] - APIVersions: [v1] - Resources: [deployments]
        Service: system/datadog-admission-controller - Port: 443 - Path: /kubernetes-admission-events

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

@gabedos gabedos added the enhancement New feature or request label Dec 17, 2024
@gabedos gabedos added this to the v1.11.0 milestone Dec 17, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 35.71429% with 9 lines in your changes missing coverage. Please review.

Project coverage is 48.65%. Comparing base (756ed08) to head (d0c213b).

Files with missing lines Patch % Lines
...atadogagent/feature/admissioncontroller/feature.go 0.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1575      +/-   ##
==========================================
- Coverage   48.66%   48.65%   -0.01%     
==========================================
  Files         226      226              
  Lines       20370    20385      +15     
==========================================
+ Hits         9913     9919       +6     
- Misses       9940     9947       +7     
- Partials      517      519       +2     
Flag Coverage Δ
unittests 48.65% <35.71%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
api/datadoghq/v2alpha1/datadogagent_default.go 90.95% <100.00%> (+0.15%) ⬆️
api/datadoghq/v2alpha1/datadogagent_types.go 100.00% <ø> (ø)
...atadogagent/feature/admissioncontroller/feature.go 66.26% <0.00%> (-1.83%) ⬇️

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 756ed08...d0c213b. Read the comment docs.

@gabedos gabedos force-pushed the gabedos/operator-k8s-admin-events branch from 43fbc46 to d0c213b Compare December 17, 2024 21:48
@@ -69,6 +71,10 @@ type AgentSidecarInjectionConfig struct {
profiles []*v2alpha1.Profile
}

type KubernetesAdmissionEventConfig struct {
enabled bool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created struct for k8s admin event config bc there is potential future use case for users to customize the feature such as having more control in which events are recorded

@gabedos gabedos marked this pull request as ready for review December 17, 2024 21:58
@gabedos gabedos requested review from a team as code owners December 17, 2024 21:58
@levan-m levan-m modified the milestones: v1.11.0, v1.12.0 Dec 17, 2024
@gabedos gabedos merged commit 6f3a79f into main Dec 18, 2024
21 checks passed
@gabedos gabedos deleted the gabedos/operator-k8s-admin-events branch December 18, 2024 19:21
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.

6 participants