agent

package
v1.32.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DDContainerImageEnabled = "DD_CONTAINER_IMAGE_ENABLED"
	DDPodName               = "DD_POD_NAME"
)

Variables

This section is empty.

Functions

func AddWindowsLogCollectionVolumes added in v1.30.0

func AddWindowsLogCollectionVolumes(spec *corev1.PodSpec, paths WindowsLogPaths) (skippedOverlappingContainerLogsPath string)

AddWindowsLogCollectionVolumes adds the Windows host-log hostPath volumes + mounts to the core agent (the logcollection feature only injects the Linux paths, which the strip removes). It mounts tempStoragePath (default C:/var/log) and podLogsPath (default C:/var/log/pods).

containerLogsPath (the container-runtime log store that pod logs may symlink into) has no default and is mounted only when set to a Windows path that does NOT overlap the config dir. On containerd (the supported Windows runtime) pod logs are regular files under C:/var/log/pods, so it is normally unset; defaulting it to C:/ProgramData would overlap C:/ProgramData/Datadog and rely on non-guaranteed Windows nested-mount overlay. Symlink-based runtimes set it to the store's own subdirectory (a sibling of the config dir, e.g. C:/ProgramData/docker/containers). A path that overlaps the config dir is skipped and returned (empty otherwise) so the caller can surface a condition instead of silently failing log collection.

It is a no-op if there is no core agent container. Configured paths set the HOST path only; the in-container mount path is the Agent's standard Windows path.

func ApplyWindowsPodTransformation added in v1.30.0

func ApplyWindowsPodTransformation(tmpl *corev1.PodTemplateSpec, dda metav1.Object, logCollectionEnabled bool, logPaths WindowsLogPaths) (skippedOverlappingContainerLogsPath string)

ApplyWindowsPodTransformation converts an already-built (Linux) node-agent pod template into a Windows-compatible one, in place. It is used on the DatadogAgentProfile+provider path: a profile targeting Windows nodes (annotation datadoghq.com/provider=windows) builds a normal agent DaemonSet through the shared machinery — which owns naming, labels, node affinity and overrides — and this function then Windows-ifies the pod contents:

  1. Strip every Linux-only artifact (StripLinuxOnlySettingsFromTemplate): non-Windows containers, "/"-path mounts/volumes, Unix-socket + Linux-only env, container and pod securityContext, hostPID/hostIPC, and all Linux init containers.
  2. Re-add the Windows config bootstrap: a shared emptyDir + PowerShell init container that seeds it with the image's conf.d + a datadog.yaml, mounted at C:/ProgramData/Datadog on the surviving agent containers, plus the Windows container commands and the Windows auth-token path.
  3. Coerce the default agent image to the -servercore variant.
  4. Add the Windows host-log hostPath mounts when log collection is enabled.
  5. Force non-local traffic so APM/DogStatsD are reachable without Unix sockets.
  6. Add the Windows nodeSelector + the node.kubernetes.io/os=windows:NoSchedule toleration.

logPaths carries the configured logCollection paths (Windows defaults are applied for the Linux/empty values).

It returns a configured logCollection.containerLogsPath that was skipped for overlapping the agent config dir (empty string otherwise), so the caller can surface a warning/condition.

func DefaultCapabilitiesForSystemProbe

func DefaultCapabilitiesForSystemProbe() []corev1.Capability

DefaultCapabilitiesForSystemProbe returns the default Security Context Capabilities for the System Probe container

func DefaultSeccompConfigDataForSystemProbe added in v1.15.0

func DefaultSeccompConfigDataForSystemProbe(ddaSpec *v2alpha1.DatadogAgentSpec) map[string]string

DefaultSeccompConfigDataForSystemProbe returns configmap data for the default seccomp profile

func DefaultSyscallsForSystemProbe added in v1.23.0

func DefaultSyscallsForSystemProbe() []string

DefaultSyscallsForSystemProbe returns the default syscalls for the System Probe

func EnsureAgentNotReadyStartupToleration added in v1.29.0

func EnsureAgentNotReadyStartupToleration(logger logr.Logger, spec *corev1.PodSpec)

EnsureAgentNotReadyStartupToleration appends the agent-not-ready Equal toleration when not already tolerated per Kubernetes toleration matching.

func EnsureWindowsServercoreImage added in v1.30.0

func EnsureWindowsServercoreImage(spec *corev1.PodSpec)

EnsureWindowsServercoreImage makes sure the default Datadog Agent image on the Windows pod spec carries the "-servercore" tag suffix. It MUST run after override.PodTemplateSpec applies the nodeAgent image override: the generic OverrideAgentImage path replaces the whole tag (servercore is not modeled as a preserved suffix), so a user pinning image.tag=7.81.0 on the default image would otherwise get the Linux agent image.

Coercion is intentionally limited to the default Datadog Agent image name ("agent"): a fully custom image (e.g. registry.local/custom-agent:win2022) is the user's responsibility and must already be Windows-compatible — we must not mangle its tag. Images whose tag already contains "servercore" are left unchanged.

func GetAgentRoleName

func GetAgentRoleName(dda metav1.Object) string

GetAgentRoleName returns the name of the role for the Agent

func GetDefaultAgentClusterRolePolicyRules added in v1.15.0

func GetDefaultAgentClusterRolePolicyRules(excludeNonResourceRules bool, useFineGrainedAuthorization bool, kubeletUseAPIServer bool) []rbacv1.PolicyRule

GetDefaultAgentClusterRolePolicyRules returns the default policy rules for the Agent cluster role. kubeletUseAPIServer adds get/list on pods so the Agent can discover pods via the API server when the kubelet endpoint is not reachable (e.g. GKE Autopilot).

func HasFIPSAgentImage added in v1.30.0

func HasFIPSAgentImage(spec *corev1.PodSpec) bool

HasFIPSAgentImage reports whether any container uses the default Datadog Agent image with a FIPS-flavored tag (e.g. gcr.io/datadoghq/agent:7.80.2-fips). ensureServercoreTag would silently rewrite such a tag to a non-FIPS -servercore image, so the reconciler uses this to reject FIPS on Windows even when it was requested via an image tag override (not the global FIPS flags).

func NewDaemonset

func NewDaemonset(owner metav1.Object, componentKind, componentName, version string, selector *metav1.LabelSelector, instanceName string) *appsv1.DaemonSet

NewDaemonset use to generate the skeleton of a new daemonset based on few information

func NewDefaultAgentDaemonset

func NewDefaultAgentDaemonset(dda metav1.Object, agentComponent feature.RequiredComponent, instanceName string) *appsv1.DaemonSet

NewDefaultAgentDaemonset return a new default agent DaemonSet TODO: remove instanceName once v2 reconcile is removed

func NewDefaultAgentPodTemplateSpec

func NewDefaultAgentPodTemplateSpec(dda metav1.Object, agentComponent feature.RequiredComponent, labels map[string]string) *corev1.PodTemplateSpec

NewDefaultAgentPodTemplateSpec returns a defaulted node agent PodTemplateSpec with a single multi-process container or multiple single-process containers

func StripLinuxOnlySettings added in v1.30.0

func StripLinuxOnlySettings(spec *corev1.PodSpec)

StripLinuxOnlySettings removes Linux-incompatible mutations from a Windows PodSpec. See stripLinuxOnlyFromSpec for the full description; prefer StripLinuxOnlySettingsFromTemplate which also cleans container-scoped pod annotations.

func StripLinuxOnlySettingsFromTemplate added in v1.30.0

func StripLinuxOnlySettingsFromTemplate(tmpl *corev1.PodTemplateSpec)

StripLinuxOnlySettingsFromTemplate removes Linux-incompatible mutations from a full PodTemplateSpec — including container-scoped pod annotations (AppArmor profiles, etc.) that reference removed containers, which Kubernetes would otherwise reject.

It is called AFTER features run their ManageNodeAgent hooks. The model is an allowlist, not a denylist, because the feature surface grows over time and a denylist is always one feature behind:

  • Containers: keep ONLY windowsAllowedContainerNames (core/trace/process agent). Everything else (system-probe, security-agent, host-profiler, flightrecorder, fips-proxy, otel-agent, …) is removed.
  • Init containers: keep ONLY windowsAllowedInitContainerNames (the Windows bootstrap).
  • Volume mounts: on each surviving container, drop any mount whose MountPath is a Linux absolute path (starts with "/"). Windows mounts use C:/... paths, so this uniformly catches hostPath mounts (/proc, /), emptyDir mounts at Linux paths (/var/run/sysprobe, /var/run/datadog/flightrecorder), and config mounts.
  • Volumes: drop any volume not referenced by a surviving container's mounts.
  • SecurityContext: clear Linux fields (capabilities, seccomp, SELinux, AppArmor, readOnlyRootFilesystem).

Preserved: all feature env vars, Windows-path mounts/volumes added by the Windows builder.

Types

type WindowsLogPaths added in v1.30.0

type WindowsLogPaths struct {
	TempStoragePath string // pointer dir (RW); default C:/var/log
	PodLogsPath     string // pod logs (RO);    default C:/var/log/pods
	// ContainerLogsPath is the container-runtime log store; only mounted when set to a
	// non-overlapping Windows path. See AddWindowsLogCollectionVolumes.
	ContainerLogsPath string
}

WindowsLogPaths holds the host log paths to mount on the Windows agent. Empty fields fall back to the Windows defaults. These come from features.logCollection.{tempStoragePath, podLogsPath,containerLogsPath} so custom Windows log paths take effect.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL