Skip to content

Commit

Permalink
Introduce custom ConfigMap for system-probe and move built-in configu…
Browse files Browse the repository at this point in the history
…ration to ENV vars (#316)
  • Loading branch information
vboulineau committed Jun 3, 2021
1 parent b802426 commit fdbdd7f
Show file tree
Hide file tree
Showing 13 changed files with 401 additions and 152 deletions.
11 changes: 11 additions & 0 deletions api/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ const (
DDPPMReceiverSocket = "DD_APM_RECEIVER_SOCKET"
DDProcessAgentEnabled = "DD_PROCESS_AGENT_ENABLED"
DDSystemProbeAgentEnabled = "DD_SYSTEM_PROBE_ENABLED"
DDSystemProbeSocketPath = "DD_SYSPROBE_SOCKET"
DDSystemProbeCollectDNSStatsEnabled = "DD_COLLECT_DNS_STATS"
DDSystemProbeNPMEnabled = "DD_SYSTEM_PROBE_NETWORK_ENABLED"
DDSystemProbeEnvPrefix = "DD_SYSTEM_PROBE_CONFIG_"
DDSystemProbeDebugPort = DDSystemProbeEnvPrefix + "DEBUG_PORT"
DDSystemProbeConntrackEnabled = DDSystemProbeEnvPrefix + "ENABLE_CONNTRACK"
DDSystemProbeBPFDebugEnabled = DDSystemProbeEnvPrefix + "BPF_DEBUG"
DDSystemProbeTCPQueueLengthEnabled = DDSystemProbeEnvPrefix + "ENABLE_TCP_QUEUE_LENGTH"
DDSystemProbeOOMKillEnabled = DDSystemProbeEnvPrefix + "ENABLE_OOM_KILL"
DDEnableMetadataCollection = "DD_ENABLE_METADATA_COLLECTION"
DDKubeletHost = "DD_KUBERNETES_KUBELET_HOST"
DDKubeletTLSVerify = "DD_KUBELET_TLS_VERIFY"
Expand All @@ -103,12 +112,14 @@ const (
DDRuntimeSecurityConfigPoliciesDir = "DD_RUNTIME_SECURITY_CONFIG_POLICIES_DIR"
DDRuntimeSecurityConfigSocket = "DD_RUNTIME_SECURITY_CONFIG_SOCKET"
DDRuntimeSecurityConfigSyscallMonitorEnabled = "DD_RUNTIME_SECURITY_CONFIG_SYSCALL_MONITOR_ENABLED"
DDRuntimeSecurityConfigRemoteTaggerEnabled = "DD_RUNTIME_SECURITY_CONFIG_REMOTE_TAGGER"
DDExternalMetricsProviderEndpoint = "DD_EXTERNAL_METRICS_PROVIDER_ENDPOINT"
DDPrometheusScrapeEnabled = "DD_PROMETHEUS_SCRAPE_ENABLED"
DDPrometheusScrapeServiceEndpoints = "DD_PROMETHEUS_SCRAPE_SERVICE_ENDPOINTS"
DDPrometheusScrapeChecks = "DD_PROMETHEUS_SCRAPE_CHECKS"
DDExternalMetricsProviderAPIKey = "DD_EXTERNAL_METRICS_PROVIDER_API_KEY"
DDExternalMetricsProviderAppKey = "DD_EXTERNAL_METRICS_PROVIDER_APP_KEY"
DDAuthTokenFilePath = "DD_AUTH_TOKEN_FILE_PATH"

// KubernetesEnvvarName Env var used by the Datadog Agent container entrypoint
// to add kubelet config provider and listener
Expand Down
9 changes: 7 additions & 2 deletions api/v1alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ type SystemProbeSpec struct {
// CollectDNSStats enables DNS stat collection.
CollectDNSStats *bool `json:"collectDNSStats,omitempty"`

// Enable custom configuration for system-probe, corresponding to the system-probe.yaml config file.
// This custom configuration has less priority than all settings above.
// +optional
CustomConfig *CustomConfigSpec `json:"customConfig,omitempty"`

// The Datadog SystemProbe supports many environment variables.
// See also: https://docs.datadoghq.com/agent/docker/?tab=standard#environment-variables
//
Expand Down Expand Up @@ -676,7 +681,7 @@ type ConfigDirSpec struct {
// ConfigFileConfigMapSpec contains configMap information used to store a config file.
// +k8s:openapi-gen=true
type ConfigFileConfigMapSpec struct {
// Name the ConfigMap name.
// The name of source ConfigMap.
Name string `json:"name,omitempty"`
// FileKey corresponds to the key used in the ConfigMap.Data to store the configuration file content.
FileKey string `json:"fileKey,omitempty"`
Expand All @@ -689,7 +694,7 @@ type ConfigFileConfigMapSpec struct {
type CustomConfigSpec struct {
// ConfigData corresponds to the configuration file content.
ConfigData *string `json:"configData,omitempty"`
// ConfigMap name of a ConfigMap used to mount the configuration file.
// Enable to specify a reference to an already existing ConfigMap.
ConfigMap *ConfigFileConfigMapSpec `json:"configMap,omitempty"`
}

Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/datadogagent_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ func IsValidDatadogAgent(spec *DatadogAgentSpec) error {
errs = append(errs, fmt.Errorf("invalid spec.agent.customConfig, err: %w", err))
}
}

if spec.Agent.SystemProbe.CustomConfig != nil {
if err = IsValidCustomConfigSpec(spec.Agent.SystemProbe.CustomConfig); err != nil {
errs = append(errs, fmt.Errorf("invalid spec.agent.systemProbe.customConfig, err: %w", err))
}
}
}

if spec.ClusterAgent != nil {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/test/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type NewDatadogAgentOptions struct {
ClusterAgentVolumeMounts []corev1.VolumeMount
ClusterAgentEnvVars []corev1.EnvVar
CustomConfig string
SystemProbeCustomConfigMapName string
AgentDaemonsetName string
ClusterAgentDeploymentName string
ClusterChecksRunnerEnabled bool
Expand Down Expand Up @@ -294,6 +295,10 @@ func NewDefaultedDatadogAgent(ns, name string, options *NewDatadogAgentOptions)
if options.SystemProbeOOMKillEnabled {
ad.Spec.Agent.SystemProbe.EnableOOMKill = datadoghqv1alpha1.NewBoolPointer(true)
}

if options.SystemProbeCustomConfigMapName != "" {
ad.Spec.Agent.SystemProbe.CustomConfig = &datadoghqv1alpha1.CustomConfigSpec{ConfigMap: &datadoghqv1alpha1.ConfigFileConfigMapSpec{Name: options.SystemProbeCustomConfigMapName}}
}
}

if options.Creds != nil {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions api/v1alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 39 additions & 15 deletions config/crd/bases/v1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,16 @@ spec:
file content.
type: string
configMap:
description: ConfigMap name of a ConfigMap used to
mount the configuration file.
description: Enable to specify a reference to an already
existing ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used
in the ConfigMap.Data to store the configuration
file content.
type: string
name:
description: Name the ConfigMap name.
description: The name of source ConfigMap.
type: string
type: object
type: object
Expand Down Expand Up @@ -2512,15 +2512,15 @@ spec:
content.
type: string
configMap:
description: ConfigMap name of a ConfigMap used to mount the
configuration file.
description: Enable to specify a reference to an already existing
ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used in the
ConfigMap.Data to store the configuration file content.
type: string
name:
description: Name the ConfigMap name.
description: The name of source ConfigMap.
type: string
type: object
type: object
Expand Down Expand Up @@ -3464,6 +3464,30 @@ spec:
to connect to the netlink/conntrack subsystem to add NAT
information to connection data. See also: http://conntrack-tools.netfilter.org/'
type: boolean
customConfig:
description: Enable custom configuration for system-probe,
corresponding to the system-probe.yaml config file. This
custom configuration has less priority than all settings
above.
properties:
configData:
description: ConfigData corresponds to the configuration
file content.
type: string
configMap:
description: Enable to specify a reference to an already
existing ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used in
the ConfigMap.Data to store the configuration file
content.
type: string
name:
description: The name of source ConfigMap.
type: string
type: object
type: object
debugPort:
description: DebugPort Specify the port to expose pprof and
expvar for system-probe agent.
Expand Down Expand Up @@ -6335,15 +6359,15 @@ spec:
content.
type: string
configMap:
description: ConfigMap name of a ConfigMap used to mount the
configuration file.
description: Enable to specify a reference to an already existing
ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used in the
ConfigMap.Data to store the configuration file content.
type: string
name:
description: Name the ConfigMap name.
description: The name of source ConfigMap.
type: string
type: object
type: object
Expand Down Expand Up @@ -8892,15 +8916,15 @@ spec:
content.
type: string
configMap:
description: ConfigMap name of a ConfigMap used to mount the
configuration file.
description: Enable to specify a reference to an already existing
ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used in the
ConfigMap.Data to store the configuration file content.
type: string
name:
description: Name the ConfigMap name.
description: The name of source ConfigMap.
type: string
type: object
type: object
Expand Down Expand Up @@ -9106,16 +9130,16 @@ spec:
file content.
type: string
configMap:
description: ConfigMap name of a ConfigMap used to mount
the configuration file.
description: Enable to specify a reference to an already
existing ConfigMap.
properties:
fileKey:
description: FileKey corresponds to the key used in
the ConfigMap.Data to store the configuration file
content.
type: string
name:
description: Name the ConfigMap name.
description: The name of source ConfigMap.
type: string
type: object
type: object
Expand Down

0 comments on commit fdbdd7f

Please sign in to comment.