From 43fbc46f0c341a34e6dbc83183f78a8f52f739e0 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Santos Date: Tue, 17 Dec 2024 16:42:50 -0500 Subject: [PATCH] Typo fix on expected envvar --- .../feature/admissioncontroller/envvar.go | 45 ++++++++++--------- .../feature/admissioncontroller/feature.go | 17 +++++++ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/internal/controller/datadogagent/feature/admissioncontroller/envvar.go b/internal/controller/datadogagent/feature/admissioncontroller/envvar.go index 69739f5dd8..da94b900bf 100644 --- a/internal/controller/datadogagent/feature/admissioncontroller/envvar.go +++ b/internal/controller/datadogagent/feature/admissioncontroller/envvar.go @@ -6,26 +6,27 @@ package admissioncontroller const ( - DDAdmissionControllerAgentSidecarEnabled = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_ENABLED" - DDAdmissionControllerAgentSidecarClusterAgentEnabled = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_CLUSTER_AGENT_ENABLED" - DDAdmissionControllerAgentSidecarProvider = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_PROVIDER" - DDAdmissionControllerAgentSidecarRegistry = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_CONTAINER_REGISTRY" - DDAdmissionControllerAgentSidecarImageName = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_IMAGE_NAME" - DDAdmissionControllerAgentSidecarImageTag = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_IMAGE_TAG" - DDAdmissionControllerAgentSidecarSelectors = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_SELECTORS" - DDAdmissionControllerAgentSidecarProfiles = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_PROFILES" - DDAdmissionControllerEnabled = "DD_ADMISSION_CONTROLLER_ENABLED" - DDAdmissionControllerValidationEnabled = "DD_ADMISSION_CONTROLLER_VALIDATION_ENABLED" - DDAdmissionControllerMutationEnabled = "DD_ADMISSION_CONTROLLER_MUTATION_ENABLED" - DDAdmissionControllerInjectConfig = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_ENABLED" - DDAdmissionControllerInjectConfigMode = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_MODE" - DDAdmissionControllerInjectTags = "DD_ADMISSION_CONTROLLER_INJECT_TAGS_ENABLED" - DDAdmissionControllerLocalServiceName = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_LOCAL_SERVICE_NAME" - DDAdmissionControllerMutateUnlabelled = "DD_ADMISSION_CONTROLLER_MUTATE_UNLABELLED" - DDAdmissionControllerServiceName = "DD_ADMISSION_CONTROLLER_SERVICE_NAME" - DDAdmissionControllerFailurePolicy = "DD_ADMISSION_CONTROLLER_FAILURE_POLICY" - DDAdmissionControllerWebhookName = "DD_ADMISSION_CONTROLLER_WEBHOOK_NAME" - DDAdmissionControllerRegistryName = "DD_ADMISSION_CONTROLLER_CONTAINER_REGISTRY" - DDAdmissionControllerCWSInstrumentationEnabled = "DD_ADMISSION_CONTROLLER_CWS_INSTRUMENTATION_ENABLED" - DDAdmissionControllerCWSInstrumentationMode = "DD_ADMISSION_CONTROLLER_CWS_INSTRUMENTATION_MODE" + DDAdmissionControllerAgentSidecarEnabled = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_ENABLED" + DDAdmissionControllerAgentSidecarClusterAgentEnabled = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_CLUSTER_AGENT_ENABLED" + DDAdmissionControllerAgentSidecarProvider = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_PROVIDER" + DDAdmissionControllerAgentSidecarRegistry = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_CONTAINER_REGISTRY" + DDAdmissionControllerAgentSidecarImageName = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_IMAGE_NAME" + DDAdmissionControllerAgentSidecarImageTag = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_IMAGE_TAG" + DDAdmissionControllerAgentSidecarSelectors = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_SELECTORS" + DDAdmissionControllerAgentSidecarProfiles = "DD_ADMISSION_CONTROLLER_AGENT_SIDECAR_PROFILES" + DDAdmissionControllerEnabled = "DD_ADMISSION_CONTROLLER_ENABLED" + DDAdmissionControllerValidationEnabled = "DD_ADMISSION_CONTROLLER_VALIDATION_ENABLED" + DDAdmissionControllerMutationEnabled = "DD_ADMISSION_CONTROLLER_MUTATION_ENABLED" + DDAdmissionControllerInjectConfig = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_ENABLED" + DDAdmissionControllerInjectConfigMode = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_MODE" + DDAdmissionControllerInjectTags = "DD_ADMISSION_CONTROLLER_INJECT_TAGS_ENABLED" + DDAdmissionControllerLocalServiceName = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_LOCAL_SERVICE_NAME" + DDAdmissionControllerMutateUnlabelled = "DD_ADMISSION_CONTROLLER_MUTATE_UNLABELLED" + DDAdmissionControllerServiceName = "DD_ADMISSION_CONTROLLER_SERVICE_NAME" + DDAdmissionControllerFailurePolicy = "DD_ADMISSION_CONTROLLER_FAILURE_POLICY" + DDAdmissionControllerWebhookName = "DD_ADMISSION_CONTROLLER_WEBHOOK_NAME" + DDAdmissionControllerRegistryName = "DD_ADMISSION_CONTROLLER_CONTAINER_REGISTRY" + DDAdmissionControllerCWSInstrumentationEnabled = "DD_ADMISSION_CONTROLLER_CWS_INSTRUMENTATION_ENABLED" + DDAdmissionControllerCWSInstrumentationMode = "DD_ADMISSION_CONTROLLER_CWS_INSTRUMENTATION_MODE" + DDAdmissionControllerKubernetesAdmissionEventsEnabled = "DD_ADMISSION_CONTROLLER_KUBERNETES_ADMISSION_EVENTS_ENABLED" ) diff --git a/internal/controller/datadogagent/feature/admissioncontroller/feature.go b/internal/controller/datadogagent/feature/admissioncontroller/feature.go index 62ddc2bd41..ae48bf057f 100644 --- a/internal/controller/datadogagent/feature/admissioncontroller/feature.go +++ b/internal/controller/datadogagent/feature/admissioncontroller/feature.go @@ -48,6 +48,8 @@ type admissionControllerFeature struct { cwsInstrumentationEnabled bool cwsInstrumentationMode string + + kubernetesAdmissionEvents *K8sAdmissionEventConfig } type ValidationConfig struct { @@ -69,6 +71,10 @@ type AgentSidecarInjectionConfig struct { profiles []*v2alpha1.Profile } +type K8sAdmissionEventConfig struct { + enabled bool +} + func buildAdmissionControllerFeature(options *feature.Options) feature.Feature { return &admissionControllerFeature{} } @@ -140,6 +146,10 @@ func (f *admissionControllerFeature) Configure(dda *v2alpha1.DatadogAgent) (reqC f.cwsInstrumentationMode = apiutils.StringValue(ac.CWSInstrumentation.Mode) } + if ac.KubernetesAdmissionEvents != nil && apiutils.BoolValue(ac.KubernetesAdmissionEvents.Enabled) { + f.kubernetesAdmissionEvents = &K8sAdmissionEventConfig{enabled: true} + } + _, f.networkPolicy = v2alpha1.IsNetworkPolicyEnabled(dda) sidecarConfig := dda.Spec.Features.AdmissionController.AgentSidecarInjection @@ -357,6 +367,13 @@ func (f *admissionControllerFeature) ManageClusterAgent(managers feature.PodTemp }) } + if f.kubernetesAdmissionEvents != nil { + managers.EnvVar().AddEnvVarToContainer(apicommon.ClusterAgentContainerName, &corev1.EnvVar{ + Name: DDAdmissionControllerKubernetesAdmissionEventsEnabled, + Value: apiutils.BoolToString(&f.kubernetesAdmissionEvents.enabled), + }) + } + if f.agentCommunicationMode != "" { managers.EnvVar().AddEnvVarToContainer(apicommon.ClusterAgentContainerName, &corev1.EnvVar{ Name: DDAdmissionControllerInjectConfigMode,