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

OTel Agent Feature Support #1559

Merged
merged 33 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
94b0882
OTel Agent Feature Support
mackjmr Dec 11, 2024
c20dc8c
update test
mackjmr Dec 12, 2024
cb51682
add port documentation
mackjmr Dec 12, 2024
b546ad5
remove flag support
mackjmr Dec 12, 2024
d5a8cdf
add examples
mackjmr Dec 12, 2024
5cfa20b
Merge branch 'main' into mackjmr/otel-agent-feature-support
mackjmr Dec 12, 2024
cc036f7
fix
mackjmr Dec 12, 2024
7a522c5
fix examples
mackjmr Dec 12, 2024
fe61d96
fix
mackjmr Dec 12, 2024
cf17884
fix test
mackjmr Dec 12, 2024
2a962e8
rename feature from otelAgent to otelCollector
mackjmr Dec 13, 2024
06a9f7d
rename
mackjmr Dec 13, 2024
719a485
rename directory/ pkg
mackjmr Dec 13, 2024
2945214
undo change to InitConfig volumes
mackjmr Dec 13, 2024
85e150b
remove unrelated changes
mackjmr Dec 13, 2024
838d361
add empty line
mackjmr Dec 13, 2024
b0b5a46
Merge branch 'main' into mackjmr/otel-agent-feature-support
mackjmr Dec 13, 2024
d7aaf6d
add otel collector feature to Test_defaultFeatures
mackjmr Dec 13, 2024
d8f55e2
add otel agent feature to factory test
mackjmr Dec 13, 2024
3d59fac
add annotation enabled/ feature disabled test
mackjmr Dec 13, 2024
fc532dd
Use Replace with i=1 instead of ReplaceAll as we know there is only 1…
mackjmr Dec 13, 2024
7f50ee1
fix examples
mackjmr Dec 13, 2024
1a69194
update example ports to 0.0.0.0 (defaults to localhost) and add annot…
mackjmr Dec 13, 2024
ff7868e
update o.ports rather than DDA directly
mackjmr Dec 17, 2024
1175a45
add support for core config
mackjmr Dec 18, 2024
d12e4e0
change env var path
mackjmr Dec 18, 2024
d1345c2
Move image to images.go per feedback
mackjmr Dec 19, 2024
1f75457
Merge branch 'main' into mackjmr/otel-agent-feature-support
mackjmr Dec 19, 2024
4a490b7
fix test after merge of main
mackjmr Dec 19, 2024
eb7f68e
add non default auth path volume mount, required for staging
mackjmr Dec 19, 2024
7d61660
add vm logs
mackjmr Dec 19, 2024
137220d
Merge branch 'main' into mackjmr/otel-agent-feature-support
levan-m Dec 19, 2024
a4f0b7c
change sync delay to 30s
mackjmr Dec 20, 2024
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 api/datadoghq/v2alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const (
DefaultDogstatsdPort = 8125
// DefaultDogstatsdPortName default dogstatsd port name
DefaultDogstatsdPortName = "dogstatsdport"
// DefaultOTelAgentConf default otel agent ConfigMap name
DefaultOTelAgentConf string = "otel-agent-config"
// DefaultKubeStateMetricsCoreConf default ksm core ConfigMap name
DefaultKubeStateMetricsCoreConf string = "kube-state-metrics-core-config"
// DefaultOrchestratorExplorerConf default orchestrator explorer ConfigMap name
Expand Down
7 changes: 7 additions & 0 deletions api/datadoghq/v2alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
defaultLogPodLogsPath string = "/var/log/pods"
defaultLogContainerSymlinksPath string = "/var/log/containers"

defaultOtelCollectorEnabled bool = false
defaultLiveProcessCollectionEnabled bool = false
defaultLiveContainerCollectionEnabled bool = true
defaultProcessDiscoveryEnabled bool = true
Expand Down Expand Up @@ -219,6 +220,12 @@ func defaultFeaturesConfig(ddaSpec *DatadogAgentSpec) {
}
apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.LiveContainerCollection.Enabled, defaultLiveContainerCollectionEnabled)

// OTelCollector Feature
if ddaSpec.Features.OtelCollector == nil {
ddaSpec.Features.OtelCollector = &OtelCollectorFeatureConfig{}
}
apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.OtelCollector.Enabled, defaultOtelCollectorEnabled)

// LiveProcessCollection Feature
if ddaSpec.Features.LiveProcessCollection == nil {
ddaSpec.Features.LiveProcessCollection = &LiveProcessCollectionFeatureConfig{}
Expand Down
182 changes: 182 additions & 0 deletions api/datadoghq/v2alpha1/datadogagent_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -329,6 +332,9 @@ func Test_defaultFeatures(t *testing.T) {
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
Expand Down Expand Up @@ -416,6 +422,9 @@ func Test_defaultFeatures(t *testing.T) {
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
Expand Down Expand Up @@ -548,6 +557,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -689,6 +701,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -825,6 +840,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -961,6 +979,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1106,6 +1127,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1242,6 +1266,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1381,6 +1408,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1512,6 +1542,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1665,6 +1698,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1752,6 +1788,146 @@ func Test_defaultFeatures(t *testing.T) {
},
},
},

{
name: "OTel Collector is enabled",
ddaSpec: &DatadogAgentSpec{
Features: &DatadogFeatures{
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
},
},
},
want: &DatadogAgentSpec{
Features: &DatadogFeatures{
LogCollection: &LogCollectionFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultLogCollectionEnabled),
},
LiveProcessCollection: &LiveProcessCollectionFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultLiveProcessCollectionEnabled),
},
LiveContainerCollection: &LiveContainerCollectionFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultLiveContainerCollectionEnabled),
},
ProcessDiscovery: &ProcessDiscoveryFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultProcessDiscoveryEnabled),
},
OOMKill: &OOMKillFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOOMKillEnabled),
},
TCPQueueLength: &TCPQueueLengthFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultTCPQueueLengthEnabled),
},
EBPFCheck: &EBPFCheckFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultEBPFCheckEnabled),
},
ServiceDiscovery: &ServiceDiscoveryFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultServiceDiscoveryEnabled),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
SingleStepInstrumentation: &SingleStepInstrumentation{
Enabled: apiutils.NewBoolPointer(defaultAPMSingleStepInstrEnabled),
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
},
SCA: &ASMSCAConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMSCAEnabled),
},
IAST: &ASMIASTConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
CWS: &CWSFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCWSEnabled),
},
NPM: &NPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultNPMEnabled),
},
USM: &USMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultUSMEnabled),
},
Dogstatsd: &DogstatsdFeatureConfig{
OriginDetectionEnabled: apiutils.NewBoolPointer(defaultDogstatsdOriginDetectionEnabled),
HostPortConfig: &HostPortConfig{Enabled: apiutils.NewBoolPointer(defaultDogstatsdHostPortEnabled)},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultDogstatsdSocketEnabled),
Path: apiutils.NewStringPointer(defaultDogstatsdHostSocketPath),
},
},
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPGRPCEndpoint),
},
HTTP: &OTLPHTTPConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPHTTPEnabled),
HostPortConfig: nil,
Endpoint: apiutils.NewStringPointer(defaultOTLPHTTPEndpoint),
},
}}},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultRemoteConfigurationEnabled),
},
EventCollection: &EventCollectionFeatureConfig{
CollectKubernetesEvents: apiutils.NewBoolPointer(defaultCollectKubernetesEvents),
},
OrchestratorExplorer: &OrchestratorExplorerFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOrchestratorExplorerEnabled),
ScrubContainers: apiutils.NewBoolPointer(defaultOrchestratorExplorerScrubContainers),
},
ExternalMetricsServer: &ExternalMetricsServerFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultExternalMetricsServerEnabled),
},
KubeStateMetricsCore: &KubeStateMetricsCoreFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultKubeStateMetricsCoreEnabled),
},
ClusterChecks: &ClusterChecksFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultClusterChecksEnabled),
UseClusterChecksRunners: apiutils.NewBoolPointer(defaultUseClusterChecksRunners),
},
AdmissionController: &AdmissionControllerFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionControllerEnabled),
Validation: &AdmissionControllerValidationConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionControllerValidationEnabled),
},
Mutation: &AdmissionControllerMutationConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionControllerMutationEnabled),
},
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
ServiceName: apiutils.NewStringPointer(defaultAdmissionServiceName),
CWSInstrumentation: &CWSInstrumentationConfig{
Enabled: apiutils.NewBoolPointer(DefaultAdmissionControllerCWSInstrumentationEnabled),
},
},
PrometheusScrape: &PrometheusScrapeFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultPrometheusScrapeEnabled),
},
HelmCheck: &HelmCheckFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultHelmCheckEnabled),
},
},
},
},
{
// This test sets same defaults as the one with `Features: nil`; and leaves other configs as empty structs.
name: "all feature configs are empty structs, configures defaults where applicable, leaves others empty",
Expand Down Expand Up @@ -1824,6 +2000,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down Expand Up @@ -1963,6 +2142,9 @@ func Test_defaultFeatures(t *testing.T) {
LanguageDetection: &LanguageDetectionConfig{Enabled: apiutils.NewBoolPointer(defaultLanguageDetectionEnabled)},
},
},
OtelCollector: &OtelCollectorFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOtelCollectorEnabled),
},
ASM: &ASMFeatureConfig{
Threats: &ASMThreatsConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMThreatsEnabled),
Expand Down
25 changes: 25 additions & 0 deletions api/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type DatadogAgentSpec struct {
type DatadogFeatures struct {
// Application-level features

// OtelCollector configuration.
OtelCollector *OtelCollectorFeatureConfig `json:"otelCollector,omitempty"`
// LogCollection configuration.
LogCollection *LogCollectionFeatureConfig `json:"logCollection,omitempty"`
// LiveProcessCollection configuration.
Expand Down Expand Up @@ -682,6 +684,29 @@ type KubeStateMetricsCoreFeatureConfig struct {
Conf *CustomConfig `json:"conf,omitempty"`
}

// OtelCollectorFeatureConfig contains the configuration for the otel-agent.
// +k8s:openapi-gen=true
type OtelCollectorFeatureConfig struct {
// Enabled enables the OTel Agent.
// Default: true
// +optional
Enabled *bool `json:"enabled,omitempty"`

// Conf overrides the configuration for the default Kubernetes State Metrics Core check.
// This must point to a ConfigMap containing a valid cluster check configuration.
// When passing a configmap, file name *must* be otel-config.yaml.
// +optional
Conf *CustomConfig `json:"conf,omitempty"`
dineshg13 marked this conversation as resolved.
Show resolved Hide resolved

// Ports contains the ports for the otel-agent.
// Defaults: otel-grpc:4317 / otel-http:4318. Note: setting 4317
// or 4318 manually is *only* supported if name match default names (otel-grpc, otel-http).
// If not, this will lead to a port conflict.
// This limitation will be lifted once annotations support is removed.
// +optional
Ports []*corev1.ContainerPort `json:"ports,omitempty"`
}

// AdmissionControllerFeatureConfig contains the Admission Controller feature configuration.
// The Admission Controller runs in the Cluster Agent.
type AdmissionControllerFeatureConfig struct {
Expand Down
Loading
Loading