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

Add beta support for Agent Data Plane. #1383

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apis/datadoghq/common/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const (
SystemProbeContainerName AgentContainerName = "system-probe"
// OtelAgent is the name of the OTel container
OtelAgent AgentContainerName = "otel-agent"
// AgentDataPlaneContainerName is the name of the ADP container
AgentDataPlaneContainerName AgentContainerName = "agent-data-plane"
// AllContainers is used internally to reference all containers in the pod
AllContainers AgentContainerName = "all"
// ClusterAgentContainerName is the name of the Cluster Agent container
Expand Down
34 changes: 34 additions & 0 deletions controllers/datadogagent/component/agent/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func agentOptimizedContainers(dda metav1.Object, requiredContainers []commonv1.A
containers = append(containers, systemProbeContainer(dda))
case commonv1.OtelAgent:
containers = append(containers, otelAgentContainer(dda))
case commonv1.AgentDataPlaneContainerName:
containers = append(containers, agentDataPlaneContainer(dda))
}
}

Expand Down Expand Up @@ -258,6 +260,18 @@ func systemProbeContainer(dda metav1.Object) corev1.Container {
}
}

func agentDataPlaneContainer(dda metav1.Object) corev1.Container {
return corev1.Container{
Name: string(commonv1.AgentDataPlaneContainerName),
Image: agentImage(),
Command: []string{"agent-data-plane"},
Env: envVarsForAgentDataPlane(dda),
VolumeMounts: volumeMountsForAgentDataPlane(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
}
}

func initVolumeContainer() corev1.Container {
return corev1.Container{
Name: "init-volume",
Expand Down Expand Up @@ -387,6 +401,14 @@ func envVarsForOtelAgent(dda metav1.Object) []corev1.EnvVar {
return append(envs, commonEnvVars(dda)...)
}

func envVarsForAgentDataPlane(dda metav1.Object) []corev1.EnvVar {
envs := []corev1.EnvVar{
// TODO: add additional env vars here
}

return append(envs, commonEnvVars(dda)...)
}

func volumeMountsForInitConfig() []corev1.VolumeMount {
return []corev1.VolumeMount{
common.GetVolumeMountForLogs(),
Expand Down Expand Up @@ -499,6 +521,18 @@ func volumeMountsForOtelAgent() []corev1.VolumeMount {
}
}

func volumeMountsForAgentDataPlane() []corev1.VolumeMount {
return []corev1.VolumeMount{
common.GetVolumeMountForLogs(),
common.GetVolumeMountForAuth(true),
common.GetVolumeMountForConfig(),
common.GetVolumeMountForDogstatsdSocket(false),
common.GetVolumeMountForRuntimeSocket(true),
common.GetVolumeMountForProc(),
common.GetVolumeMountForCgroups(),
}
}

func GetDefaultMetadata(owner metav1.Object, componentKind, componentName, version string, selector *metav1.LabelSelector) (map[string]string, map[string]string, *metav1.LabelSelector) {
labels := common.GetDefaultLabels(owner, componentKind, componentName, version)
annotations := object.GetDefaultAnnotations(owner)
Expand Down
2 changes: 2 additions & 0 deletions controllers/datadogagent/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type ReconcilerOptions struct {
DatadogAgentProfileEnabled bool
ProcessChecksInCoreAgentEnabled bool
OtelAgentEnabled bool
AgentDataPlaneEnabled bool
}

// Reconciler is the internal reconciler for Datadog Agent
Expand Down Expand Up @@ -112,6 +113,7 @@ func reconcilerOptionsToFeatureOptions(opts *ReconcilerOptions, logger logr.Logg
Logger: logger,
ProcessChecksInCoreAgentEnabled: opts.ProcessChecksInCoreAgentEnabled,
OtelAgentEnabled: opts.OtelAgentEnabled,
AgentDataPlaneEnabled: opts.AgentDataPlaneEnabled,
}
}

Expand Down
38 changes: 17 additions & 21 deletions controllers/datadogagent/feature/enabledefault/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type defaultFeature struct {
logger logr.Logger
disableNonResourceRules bool
otelAgentEnabled bool
agentDataPlaneEnabled bool

customConfigAnnotationKey string
customConfigAnnotationValue string
Expand Down Expand Up @@ -184,32 +185,27 @@ func (f *defaultFeature) Configure(dda *v2alpha1.DatadogAgent) feature.RequiredC
f.customConfigAnnotationKey = object.GetChecksumAnnotationKey(string(feature.DefaultIDType))
}

//
additionalAgentContainers := make([]commonv1.AgentContainerName, 0)

// In Operator 1.9 OTel Agent will be configured through a feature.
// In the meantime we add the OTel Agent as a required component here, if the flag is enabled.
if f.otelAgentEnabled {
return feature.RequiredComponents{
ClusterAgent: feature.RequiredComponent{
IsRequired: &trueValue,
},
Agent: feature.RequiredComponent{
IsRequired: &trueValue,
Containers: []commonv1.AgentContainerName{
commonv1.OtelAgent,
},
},
}
} else {
return feature.RequiredComponents{
ClusterAgent: feature.RequiredComponent{
IsRequired: &trueValue,
},
Agent: feature.RequiredComponent{
IsRequired: &trueValue,
},
}
additionalAgentContainers = append(additionalAgentContainers, commonv1.OtelAgent)
}

if f.agentDataPlaneEnabled {
additionalAgentContainers = append(additionalAgentContainers, commonv1.AgentDataPlaneContainerName)
}

return feature.RequiredComponents{
ClusterAgent: feature.RequiredComponent{
IsRequired: &trueValue,
},
Agent: feature.RequiredComponent{
IsRequired: &trueValue,
Containers: additionalAgentContainers,
},
}
}

// ManageDependencies allows a feature to manage its dependencies.
Expand Down
1 change: 1 addition & 0 deletions controllers/datadogagent/feature/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ type Options struct {

ProcessChecksInCoreAgentEnabled bool
OtelAgentEnabled bool
AgentDataPlaneEnabled bool
}

// BuildFunc function type used by each Feature during its factory registration.
Expand Down
13 changes: 7 additions & 6 deletions controllers/datadogagent/merger/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import commonv1 "github.com/DataDog/datadog-operator/apis/datadoghq/common/v1"
// AllAgentContainers is a map of all agent containers
var AllAgentContainers = map[commonv1.AgentContainerName]struct{}{
// Node agent containers
commonv1.CoreAgentContainerName: {},
commonv1.TraceAgentContainerName: {},
commonv1.ProcessAgentContainerName: {},
commonv1.SecurityAgentContainerName: {},
commonv1.SystemProbeContainerName: {},
commonv1.OtelAgent: {},
commonv1.CoreAgentContainerName: {},
commonv1.TraceAgentContainerName: {},
commonv1.ProcessAgentContainerName: {},
commonv1.SecurityAgentContainerName: {},
commonv1.SystemProbeContainerName: {},
commonv1.OtelAgent: {},
commonv1.AgentDataPlaneContainerName: {},
// DCA containers
commonv1.ClusterAgentContainerName: {},
// CCR container name is equivalent to core agent container name
Expand Down
2 changes: 2 additions & 0 deletions controllers/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type SetupOptions struct {
DatadogAgentProfileEnabled bool
ProcessChecksInCoreAgentEnabled bool
OtelAgentEnabled bool
AgentDataPlaneEnabled bool
}

// ExtendedDaemonsetOptions defines ExtendedDaemonset options
Expand Down Expand Up @@ -155,6 +156,7 @@ func startDatadogAgent(logger logr.Logger, mgr manager.Manager, vInfo *version.I
DatadogAgentProfileEnabled: options.DatadogAgentProfileEnabled,
ProcessChecksInCoreAgentEnabled: options.ProcessChecksInCoreAgentEnabled,
OtelAgentEnabled: options.OtelAgentEnabled,
AgentDataPlaneEnabled: options.AgentDataPlaneEnabled,
},
}).SetupWithManager(mgr)
}
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type options struct {
remoteConfigEnabled bool
processChecksInCoreAgentEnabled bool
otelAgentEnabled bool
agentDataPlaneEnabled bool

// Secret Backend options
secretBackendCommand string
Expand Down Expand Up @@ -157,6 +158,7 @@ func (opts *options) Parse() {
flag.BoolVar(&opts.remoteConfigEnabled, "remoteConfigEnabled", false, "Enable RemoteConfig capabilities in the Operator (beta)")
flag.BoolVar(&opts.processChecksInCoreAgentEnabled, "processChecksInCoreAgentEnabled", false, "Enable running process checks in the core agent (beta)")
flag.BoolVar(&opts.otelAgentEnabled, "otelAgentEnabled", false, "Enable the OTel agent container (beta)")
flag.BoolVar(&opts.agentDataPlaneEnabled, "agentDataPlaneEnabled", false, "Enable the Agent Data Plane container (beta)")

// ExtendedDaemonset configuration
flag.BoolVar(&opts.supportExtendedDaemonset, "supportExtendedDaemonset", false, "Support usage of Datadog ExtendedDaemonset CRD.")
Expand Down Expand Up @@ -298,6 +300,7 @@ func run(opts *options) error {
DatadogAgentProfileEnabled: opts.datadogAgentProfileEnabled,
ProcessChecksInCoreAgentEnabled: opts.processChecksInCoreAgentEnabled,
OtelAgentEnabled: opts.otelAgentEnabled,
AgentDataPlaneEnabled: opts.agentDataPlaneEnabled,
}

if err = controllers.SetupControllers(setupLog, mgr, options); err != nil {
Expand Down
Loading