diff --git a/api/datadoghq/v2alpha1/datadogagent_types.go b/api/datadoghq/v2alpha1/datadogagent_types.go index 857767b44..ae6c60697 100644 --- a/api/datadoghq/v2alpha1/datadogagent_types.go +++ b/api/datadoghq/v2alpha1/datadogagent_types.go @@ -164,6 +164,10 @@ type SingleStepInstrumentation struct { // (Requires Agent 7.52.0+ and Cluster Agent 7.52.0+) // +optional LanguageDetection *LanguageDetectionConfig `json:"languageDetection,omitempty"` + + // Injector configures the APM Injector. + // +optional + Injector *InjectorConfig `json:"injector,omitempty"` } // LanguageDetectionConfig contains the config for Language Detection. @@ -175,6 +179,14 @@ type LanguageDetectionConfig struct { Enabled *bool `json:"enabled,omitempty"` } +// InjectorConfig contains the configuration for the APM Injector. +type InjectorConfig struct { + // Set the image version to use for the APM Injector. + // (Requires Cluster Agent 7.57.0+) + // +optional + ImageTag string `json:"imageTag,omitempty"` +} + // ASMFeatureConfig contains Application Security Management (ASM) configuration. // Note that this will only affect pods where the Datadog client libraries are installed or APM Single Step Instrumentation is enabled. type ASMFeatureConfig struct { diff --git a/api/datadoghq/v2alpha1/zz_generated.deepcopy.go b/api/datadoghq/v2alpha1/zz_generated.deepcopy.go index a36ac9778..19f8c6508 100644 --- a/api/datadoghq/v2alpha1/zz_generated.deepcopy.go +++ b/api/datadoghq/v2alpha1/zz_generated.deepcopy.go @@ -1800,6 +1800,21 @@ func (in *HostPortConfig) DeepCopy() *HostPortConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InjectorConfig) DeepCopyInto(out *InjectorConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InjectorConfig. +func (in *InjectorConfig) DeepCopy() *InjectorConfig { + if in == nil { + return nil + } + out := new(InjectorConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeStateMetricsCoreFeatureConfig) DeepCopyInto(out *KubeStateMetricsCoreFeatureConfig) { *out = *in @@ -2735,6 +2750,11 @@ func (in *SingleStepInstrumentation) DeepCopyInto(out *SingleStepInstrumentation *out = new(LanguageDetectionConfig) (*in).DeepCopyInto(*out) } + if in.Injector != nil { + in, out := &in.Injector, &out.Injector + *out = new(InjectorConfig) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SingleStepInstrumentation. diff --git a/config/crd/bases/v1/datadoghq.com_datadogagents.yaml b/config/crd/bases/v1/datadoghq.com_datadogagents.yaml index 679f7ce12..cb0392b52 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagents.yaml +++ b/config/crd/bases/v1/datadoghq.com_datadogagents.yaml @@ -527,6 +527,15 @@ spec: type: string type: array x-kubernetes-list-type: set + injector: + description: Injector configures the APM Injector. + properties: + imageTag: + description: |- + Set the image version to use for the APM Injector. + (Requires Cluster Agent 7.57.0+) + type: string + type: object languageDetection: description: |- LanguageDetection detects languages and adds them as annotations on Deployments, but does not use these languages for injecting libraries to workload pods. @@ -7391,6 +7400,15 @@ spec: type: string type: array x-kubernetes-list-type: set + injector: + description: Injector configures the APM Injector. + properties: + imageTag: + description: |- + Set the image version to use for the APM Injector. + (Requires Cluster Agent 7.57.0+) + type: string + type: object languageDetection: description: |- LanguageDetection detects languages and adds them as annotations on Deployments, but does not use these languages for injecting libraries to workload pods. diff --git a/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json b/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json index 02d401ef4..3f689db4f 100644 --- a/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json +++ b/config/crd/bases/v1/datadoghq.com_datadogagents_v2alpha1.json @@ -530,6 +530,17 @@ "type": "array", "x-kubernetes-list-type": "set" }, + "injector": { + "additionalProperties": false, + "description": "Injector configures the APM Injector.", + "properties": { + "imageTag": { + "description": "Set the image version to use for the APM Injector.\n(Requires Cluster Agent 7.57.0+)", + "type": "string" + } + }, + "type": "object" + }, "languageDetection": { "additionalProperties": false, "description": "LanguageDetection detects languages and adds them as annotations on Deployments, but does not use these languages for injecting libraries to workload pods.\n(Requires Agent 7.52.0+ and Cluster Agent 7.52.0+)", @@ -7336,6 +7347,17 @@ "type": "array", "x-kubernetes-list-type": "set" }, + "injector": { + "additionalProperties": false, + "description": "Injector configures the APM Injector.", + "properties": { + "imageTag": { + "description": "Set the image version to use for the APM Injector.\n(Requires Cluster Agent 7.57.0+)", + "type": "string" + } + }, + "type": "object" + }, "languageDetection": { "additionalProperties": false, "description": "LanguageDetection detects languages and adds them as annotations on Deployments, but does not use these languages for injecting libraries to workload pods.\n(Requires Agent 7.52.0+ and Cluster Agent 7.52.0+)", diff --git a/docs/configuration.v2alpha1.md b/docs/configuration.v2alpha1.md index 1e37d145c..a32c6d76d 100644 --- a/docs/configuration.v2alpha1.md +++ b/docs/configuration.v2alpha1.md @@ -62,6 +62,7 @@ spec: | features.apm.instrumentation.disabledNamespaces | DisabledNamespaces disables injecting the Datadog APM libraries into pods in specific namespaces. | | features.apm.instrumentation.enabled | Enables injecting the Datadog APM libraries into all pods in the cluster. Default: false | | features.apm.instrumentation.enabledNamespaces | EnabledNamespaces enables injecting the Datadog APM libraries into pods in specific namespaces. | +| features.apm.instrumentation.injector.imageTag | Set the image version to use for the APM Injector. (Requires Cluster Agent 7.57.0+) | | features.apm.instrumentation.languageDetection.enabled | Enables Language Detection to automatically detect languages of user workloads (beta). Requires SingleStepInstrumentation.Enabled to be true. Default: true | | features.apm.instrumentation.libVersions | LibVersions configures injection of specific tracing library versions with Single Step Instrumentation. : ex: "java": "v1.18.0" | | features.apm.unixDomainSocketConfig.enabled | Enables Unix Domain Socket. Default: true | diff --git a/internal/controller/datadogagent/defaults/datadogagent_default.go b/internal/controller/datadogagent/defaults/datadogagent_default.go index 1ebe56970..7a6315e90 100644 --- a/internal/controller/datadogagent/defaults/datadogagent_default.go +++ b/internal/controller/datadogagent/defaults/datadogagent_default.go @@ -298,6 +298,10 @@ func defaultFeaturesConfig(ddaSpec *v2alpha1.DatadogAgentSpec) { ddaSpec.Features.APM.SingleStepInstrumentation.LanguageDetection = &v2alpha1.LanguageDetectionConfig{} } + if ddaSpec.Features.APM.SingleStepInstrumentation.Injector == nil { + ddaSpec.Features.APM.SingleStepInstrumentation.Injector = &v2alpha1.InjectorConfig{} + } + apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.APM.SingleStepInstrumentation.Enabled, defaultAPMSingleStepInstrEnabled) apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.APM.SingleStepInstrumentation.LanguageDetection.Enabled, defaultLanguageDetectionEnabled) } diff --git a/internal/controller/datadogagent/defaults/datadogagent_default_test.go b/internal/controller/datadogagent/defaults/datadogagent_default_test.go index 98d61fd6b..332d973fd 100644 --- a/internal/controller/datadogagent/defaults/datadogagent_default_test.go +++ b/internal/controller/datadogagent/defaults/datadogagent_default_test.go @@ -211,6 +211,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -562,6 +563,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -709,6 +711,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -851,6 +854,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -993,6 +997,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1144,6 +1149,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1286,6 +1292,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1431,6 +1438,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1571,6 +1579,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1730,6 +1739,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -1873,6 +1883,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -2037,6 +2048,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ @@ -2182,6 +2194,7 @@ func Test_defaultFeatures(t *testing.T) { SingleStepInstrumentation: &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled), LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{}, }, }, OtelCollector: &v2alpha1.OtelCollectorFeatureConfig{ diff --git a/internal/controller/datadogagent/feature/apm/envvar.go b/internal/controller/datadogagent/feature/apm/envvar.go index 1eba11cd5..a23f8923f 100644 --- a/internal/controller/datadogagent/feature/apm/envvar.go +++ b/internal/controller/datadogagent/feature/apm/envvar.go @@ -10,6 +10,7 @@ const ( DDAPMReceiverPort = "DD_APM_RECEIVER_PORT" DDAPMReceiverSocket = "DD_APM_RECEIVER_SOCKET" DDAPMInstrumentationEnabled = "DD_APM_INSTRUMENTATION_ENABLED" + DDAPMInstrumentationInjectorImageTag = "DD_APM_INSTRUMENTATION_INJECTOR_IMAGE_TAG" DDAPMInstrumentationEnabledNamespaces = "DD_APM_INSTRUMENTATION_ENABLED_NAMESPACES" DDAPMInstrumentationDisabledNamespaces = "DD_APM_INSTRUMENTATION_DISABLED_NAMESPACES" DDAPMInstrumentationLibVersions = "DD_APM_INSTRUMENTATION_LIB_VERSIONS" diff --git a/internal/controller/datadogagent/feature/apm/feature.go b/internal/controller/datadogagent/feature/apm/feature.go index 00b74d7e5..b56e7c646 100644 --- a/internal/controller/datadogagent/feature/apm/feature.go +++ b/internal/controller/datadogagent/feature/apm/feature.go @@ -71,12 +71,17 @@ type instrumentationConfig struct { disabledNamespaces []string libVersions map[string]string languageDetection *languageDetection + injector *injector } type languageDetection struct { enabled bool } +type injector struct { + imageTag string +} + // ID returns the ID of the Feature func (f *apmFeature) ID() feature.IDType { return feature.APMIDType @@ -146,6 +151,7 @@ func (f *apmFeature) Configure(dda *v2alpha1.DatadogAgent) (reqComp feature.Requ f.singleStepInstrumentation.enabledNamespaces = apm.SingleStepInstrumentation.EnabledNamespaces f.singleStepInstrumentation.libVersions = apm.SingleStepInstrumentation.LibVersions f.singleStepInstrumentation.languageDetection = &languageDetection{enabled: apiutils.BoolValue(dda.Spec.Features.APM.SingleStepInstrumentation.LanguageDetection.Enabled)} + f.singleStepInstrumentation.injector = &injector{imageTag: apm.SingleStepInstrumentation.Injector.ImageTag} reqComp.ClusterAgent = feature.RequiredComponent{ IsRequired: apiutils.NewBoolPointer(true), Containers: []apicommon.AgentContainerName{ @@ -163,6 +169,13 @@ func (f *apmFeature) Configure(dda *v2alpha1.DatadogAgent) (reqComp feature.Requ return reqComp } +func (f *apmFeature) shouldSetCustomInjectorImage() bool { + return f.singleStepInstrumentation != nil && + f.singleStepInstrumentation.enabled && + f.singleStepInstrumentation.injector != nil && + f.singleStepInstrumentation.injector.imageTag != "" +} + func (f *apmFeature) shouldEnableLanguageDetection() bool { return f.singleStepInstrumentation != nil && f.singleStepInstrumentation.enabled && @@ -272,6 +285,13 @@ func (f *apmFeature) ManageClusterAgent(managers feature.PodTemplateManagers) er Value: apiutils.BoolToString(&f.singleStepInstrumentation.enabled), }) + if f.shouldSetCustomInjectorImage() { + managers.EnvVar().AddEnvVarToContainer(apicommon.ClusterAgentContainerName, &corev1.EnvVar{ + Name: DDAPMInstrumentationInjectorImageTag, + Value: f.singleStepInstrumentation.injector.imageTag, + }) + } + if f.shouldEnableLanguageDetection() { managers.EnvVar().AddEnvVarToContainer(apicommon.ClusterAgentContainerName, &corev1.EnvVar{ Name: DDLanguageDetectionEnabled, diff --git a/internal/controller/datadogagent/feature/apm/feature_test.go b/internal/controller/datadogagent/feature/apm/feature_test.go index a85b8629e..40de67129 100644 --- a/internal/controller/datadogagent/feature/apm/feature_test.go +++ b/internal/controller/datadogagent/feature/apm/feature_test.go @@ -232,7 +232,7 @@ func TestAPMFeature(t *testing.T) { WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). WithAdmissionControllerEnabled(true). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false, ""). WithSingleContainerStrategy(false). Build(), WantConfigure: true, @@ -250,7 +250,9 @@ func TestAPMFeature(t *testing.T) { []string{"foo", "bar"}, map[string]string{ "java": "1.2.4", - }, false). + }, + false, + ""). WithSingleContainerStrategy(false). Build(), WantConfigure: true, @@ -268,7 +270,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(false). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false, ""). WithAdmissionControllerEnabled(true). Build(), WantConfigure: false, @@ -279,7 +281,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(true). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false, ""). WithAdmissionControllerEnabled(false). WithSingleContainerStrategy(false). Build(), @@ -293,7 +295,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(true). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(false, []string{"foo", "bar"}, nil, map[string]string{"java": "1.2.4"}, false). + WithAPMSingleStepInstrumentationEnabled(false, []string{"foo", "bar"}, nil, map[string]string{"java": "1.2.4"}, false, ""). WithAdmissionControllerEnabled(true). Build(), WantConfigure: true, @@ -305,7 +307,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(true). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, true). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, true, ""). WithAdmissionControllerEnabled(true). Build(), WantConfigure: true, @@ -324,7 +326,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(true). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false, ""). WithAdmissionControllerEnabled(true). Build(), WantConfigure: true, @@ -343,7 +345,7 @@ func TestAPMFeature(t *testing.T) { WithAPMEnabled(true). WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). WithAPMUDSEnabled(true, apmSocketHostPath). - WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, true). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, true, ""). WithAdmissionControllerEnabled(true). WithComponentOverride( v2alpha1.NodeAgentComponentName, @@ -363,6 +365,18 @@ func TestAPMFeature(t *testing.T) { } }, }, + { + Name: "single step instrumentation with custom injector image", + DDA: testutils.NewDatadogAgentBuilder(). + WithAPMEnabled(true). + WithAPMHostPortEnabled(true, apiutils.NewInt32Pointer(8126)). + WithAPMUDSEnabled(true, apmSocketHostPath). + WithAPMSingleStepInstrumentationEnabled(true, nil, nil, nil, false, "0.27.0"). + WithAdmissionControllerEnabled(true). + Build(), + WantConfigure: true, + ClusterAgent: testAPMInstrumentationWithCustomInjectorImage(), + }, } tests.Run(t, buildAPMFeature) @@ -638,6 +652,31 @@ func testAPMInstrumentationWithLanguageDetectionEnabledForClusterAgent() *test.C ) } +func testAPMInstrumentationWithCustomInjectorImage() *test.ComponentTest { + return test.NewDefaultComponentTest().WithWantFunc( + func(t testing.TB, mgrInterface feature.PodTemplateManagers) { + mgr := mgrInterface.(*fake.PodTemplateManagers) + + agentEnvs := mgr.EnvVarMgr.EnvVarsByC[apicommon.ClusterAgentContainerName] + expectedAgentEnvs := []*corev1.EnvVar{ + { + Name: DDAPMInstrumentationEnabled, + Value: "true", + }, + { + Name: DDAPMInstrumentationInjectorImageTag, + Value: "0.27.0", + }, + } + assert.True( + t, + apiutils.IsEqualStruct(agentEnvs, expectedAgentEnvs), + "Cluster Agent ENVs \ndiff = %s", cmp.Diff(agentEnvs, expectedAgentEnvs), + ) + }, + ) +} + func testAPMInstrumentationWithLanguageDetectionForNodeAgent(languageDetectionEnabled bool, processChecksInCoreAgent bool) *test.ComponentTest { return test.NewDefaultComponentTest().WithWantFunc( func(t testing.TB, mgrInterface feature.PodTemplateManagers) { diff --git a/pkg/testutils/builder.go b/pkg/testutils/builder.go index 28a2f4e61..cde275e52 100644 --- a/pkg/testutils/builder.go +++ b/pkg/testutils/builder.go @@ -666,7 +666,7 @@ func (builder *DatadogAgentBuilder) WithAPMUDSEnabled(enabled bool, apmSocketHos return builder } -func (builder *DatadogAgentBuilder) WithAPMSingleStepInstrumentationEnabled(enabled bool, enabledNamespaces []string, disabledNamespaces []string, libVersion map[string]string, languageDetectionEnabled bool) *DatadogAgentBuilder { +func (builder *DatadogAgentBuilder) WithAPMSingleStepInstrumentationEnabled(enabled bool, enabledNamespaces []string, disabledNamespaces []string, libVersion map[string]string, languageDetectionEnabled bool, injectorImageTag string) *DatadogAgentBuilder { builder.initAPM() builder.datadogAgent.Spec.Features.APM.SingleStepInstrumentation = &v2alpha1.SingleStepInstrumentation{ Enabled: apiutils.NewBoolPointer(enabled), @@ -674,6 +674,9 @@ func (builder *DatadogAgentBuilder) WithAPMSingleStepInstrumentationEnabled(enab DisabledNamespaces: disabledNamespaces, LibVersions: libVersion, LanguageDetection: &v2alpha1.LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(languageDetectionEnabled)}, + Injector: &v2alpha1.InjectorConfig{ + ImageTag: injectorImageTag, + }, } return builder }