Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions internal/controller/datadogagent/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
DDDataPlaneDogstatsdEnabled = "DD_DATA_PLANE_DOGSTATSD_ENABLED"
DDDataPlaneOTLPEnabled = "DD_DATA_PLANE_OTLP_ENABLED"
DDDataPlaneRemoteAgentEnabled = "DD_DATA_PLANE_REMOTE_AGENT_ENABLED"
DDDataPlaneAPIListenAddress = "DD_DATA_PLANE_API_LISTEN_ADDRESS"
DDDataPlaneUseNewConfigStreamEndpoint = "DD_DATA_PLANE_USE_NEW_CONFIG_STREAM_ENDPOINT"
DDKubernetesPodResourcesSocket = "DD_KUBERNETES_KUBELET_PODRESOURCES_SOCKET"
DDKubernetesUseEndpointSlices = "DD_KUBERNETES_USE_ENDPOINT_SLICES"
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/datadogagent/feature/dataplane/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package dataplane

import (
"fmt"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -15,6 +17,7 @@ import (
"github.com/DataDog/datadog-operator/internal/controller/datadogagent/common"
"github.com/DataDog/datadog-operator/internal/controller/datadogagent/feature"
featureutils "github.com/DataDog/datadog-operator/internal/controller/datadogagent/feature/utils"
"github.com/DataDog/datadog-operator/pkg/constants"
)

func init() {
Expand Down Expand Up @@ -112,6 +115,13 @@ func (f *dataPlaneFeature) ManageNodeAgent(managers feature.PodTemplateManagers,
Value: "true",
})

// Explicitly set the API listen address so the operator controls which port ADP
// listens on, keeping probes in sync regardless of ADP's compiled-in default.
managers.EnvVar().AddEnvVarToContainer(apicommon.AgentDataPlaneContainerName, &corev1.EnvVar{
Name: common.DDDataPlaneAPIListenAddress,
Value: fmt.Sprintf("0.0.0.0:%d", constants.DefaultADPHealthPort),
})

if f.dogstatsdEnabled {
managers.EnvVar().AddEnvVarToContainer(apicommon.CoreAgentContainerName, &corev1.EnvVar{
Name: common.DDDataPlaneDogstatsdEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package dataplane

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/DataDog/datadog-operator/internal/controller/datadogagent/feature/fake"
"github.com/DataDog/datadog-operator/internal/controller/datadogagent/feature/test"
"github.com/DataDog/datadog-operator/internal/controller/datadogagent/feature/utils"
"github.com/DataDog/datadog-operator/pkg/constants"
"github.com/DataDog/datadog-operator/pkg/testutils"
)

Expand All @@ -29,6 +31,10 @@ func Test_dataPlaneFeature(t *testing.T) {
Name: common.DDDataPlaneDogstatsdEnabled,
Value: "true",
}
dataPlaneAPIListenAddressEnvVar := &corev1.EnvVar{
Name: common.DDDataPlaneAPIListenAddress,
Value: fmt.Sprintf("0.0.0.0:%d", constants.DefaultADPHealthPort),
}

tests := test.FeatureTestSuite{
{
Expand Down Expand Up @@ -88,6 +94,9 @@ func Test_dataPlaneFeature(t *testing.T) {
mgr := mgrInterface.(*fake.PodTemplateManagers)
agentEnvVars := mgr.EnvVarMgr.EnvVarsByC[apicommon.CoreAgentContainerName]
assert.Contains(t, agentEnvVars, dataPlaneEnabledEnvVar, "DD_DATA_PLANE_ENABLED should be set when Data Plane is enabled via CRD")

adpEnvVars := mgr.EnvVarMgr.EnvVarsByC[apicommon.AgentDataPlaneContainerName]
assert.Contains(t, adpEnvVars, dataPlaneAPIListenAddressEnvVar, "DD_DATA_PLANE_API_LISTEN_ADDRESS should be set on ADP container")
},
),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
// DefaultAgentHealthPort default agent health port
DefaultAgentHealthPort int32 = 5555

DefaultADPHealthPort = 5100
DefaultADPHealthPort = 5400

// DefaultApmPort default apm port
DefaultApmPort = 8126
Expand Down
Loading