Documentation
¶
Index ¶
- Constants
- func AddWindowsLogCollectionVolumes(spec *corev1.PodSpec, paths WindowsLogPaths) (skippedOverlappingContainerLogsPath string)
- func ApplyWindowsPodTransformation(tmpl *corev1.PodTemplateSpec, dda metav1.Object, logCollectionEnabled bool, ...) (skippedOverlappingContainerLogsPath string)
- func DefaultCapabilitiesForSystemProbe() []corev1.Capability
- func DefaultSeccompConfigDataForSystemProbe(ddaSpec *v2alpha1.DatadogAgentSpec) map[string]string
- func DefaultSyscallsForSystemProbe() []string
- func EnsureAgentNotReadyStartupToleration(logger logr.Logger, spec *corev1.PodSpec)
- func EnsureWindowsServercoreImage(spec *corev1.PodSpec)
- func GetAgentRoleName(dda metav1.Object) string
- func GetDefaultAgentClusterRolePolicyRules(excludeNonResourceRules bool, useFineGrainedAuthorization bool, ...) []rbacv1.PolicyRule
- func HasFIPSAgentImage(spec *corev1.PodSpec) bool
- func NewDaemonset(owner metav1.Object, componentKind, componentName, version string, ...) *appsv1.DaemonSet
- func NewDefaultAgentDaemonset(dda metav1.Object, agentComponent feature.RequiredComponent, ...) *appsv1.DaemonSet
- func NewDefaultAgentPodTemplateSpec(dda metav1.Object, agentComponent feature.RequiredComponent, ...) *corev1.PodTemplateSpec
- func StripLinuxOnlySettings(spec *corev1.PodSpec)
- func StripLinuxOnlySettingsFromTemplate(tmpl *corev1.PodTemplateSpec)
- type WindowsLogPaths
Constants ¶
const ( DDContainerImageEnabled = "DD_CONTAINER_IMAGE_ENABLED" DDPodName = "DD_POD_NAME" DDRemoteAgentConfigStreamConsumerEnabled = "DD_REMOTE_AGENT_CONFIGSTREAM_CONSUMER_ENABLED" )
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:
- 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.
- 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.
- Coerce the default agent image to the -servercore variant.
- Add the Windows host-log hostPath mounts when log collection is enabled.
- Force non-local traffic so APM/DogStatsD are reachable without Unix sockets.
- 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
EnsureAgentNotReadyStartupToleration appends the agent-not-ready Equal toleration when not already tolerated per Kubernetes toleration matching.
func EnsureWindowsServercoreImage ¶ added in v1.30.0
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 ¶
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
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
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.