Skip to content

Commit

Permalink
create default Cluster Agent dependencies (#512)
Browse files Browse the repository at this point in the history
* v2: cluster-agent start with only default config
* Add kustomize config to test v2
* automatically add default tags and ownerref
  • Loading branch information
clamoriniere committed Jun 7, 2022
1 parent f19ecf5 commit 615b938
Show file tree
Hide file tree
Showing 61 changed files with 1,390 additions and 512 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DEFAULT_CHANNEL=alpha
GOARCH?=amd64
PLATFORM=$(shell uname -s)-$(shell uname -m)
ROOT=$(dir $(abspath $(firstword $(MAKEFILE_LIST))))
KUSTOMIZE_CONFIG?=config/default

# Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION)
Expand Down Expand Up @@ -129,11 +130,11 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from a cluster
.PHONY: deploy
deploy: manifests $(KUSTOMIZE) ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config
cd config/manager && $(ROOT)/$(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply --force-conflicts --server-side -f -
$(KUSTOMIZE) build $(KUSTOMIZE_CONFIG)| kubectl apply --force-conflicts --server-side -f -

.PHONY: undeploy
undeploy: $(KUSTOMIZE) ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -
$(KUSTOMIZE) build $(KUSTOMIZE_CONFIG) | kubectl delete -f -

.PHONY: manifests
manifests: generate-manifests patch-crds ## Generate manifestcd s e.g. CRD, RBAC etc.
Expand Down
1 change: 1 addition & 0 deletions apis/datadoghq/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
// Default Image name
DefaultAgentImageName string = "agent"
DefaultClusterAgentImageName string = "cluster-agent"
DefaultImageRegistry string = "gcr.io/datadoghq"

// ExtendedDaemonset defaulting
DefaultRollingUpdateMaxUnavailable = "10%"
Expand Down
128 changes: 91 additions & 37 deletions apis/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,97 @@ package common

// Datadog env var names
const (
DDIgnoreAutoConf = "DD_IGNORE_AUTOCONF"
DDKubeStateMetricsCoreEnabled = "DD_KUBE_STATE_METRICS_CORE_ENABLED"
DDKubeStateMetricsCoreConfigMap = "DD_KUBE_STATE_METRICS_CORE_CONFIGMAP_NAME"
DDProcessAgentEnabled = "DD_PROCESS_AGENT_ENABLED"
DDAPMEnabled = "DD_APM_ENABLED"
DDSystemProbeNPMEnabledEnvVar = "DD_SYSTEM_PROBE_NETWORK_ENABLED"
DDSystemProbeEnabledEnvVar = "DD_SYSTEM_PROBE_ENABLED"
DDSystemProbeExternal = "DD_SYSTEM_PROBE_EXTERNAL"
DDSystemProbeServiceMonitoringEnabled = "DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED"
DDSystemProbeSocket = "DD_SYSPROBE_SOCKET"
DDComplianceEnabled = "DD_COMPLIANCE_CONFIG_ENABLED"
DDComplianceCheckInterval = "DD_COMPLIANCE_CONFIG_CHECK_INTERVAL"
DDHostRootEnvVar = "HOST_ROOT"
DDEnableOOMKillEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_OOM_KILL"
DDEnableTCPQueueLengthEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_TCP_QUEUE_LENGTH"
DDLeaderElection = "DD_LEADER_ELECTION"
DDClusterAgentKubeServiceName = "DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME"
DDHealthPort = "DD_HEALTH_PORT"
DDLogsEnabled = "DD_LOGS_ENABLED"
DDLogsConfigContainerCollectAll = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL"
DDLogsContainerCollectUsingFiles = "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE"
DDLogsConfigOpenFilesLimit = "DD_LOGS_CONFIG_OPEN_FILES_LIMIT"
DDPrometheusScrapeEnabled = "DD_PROMETHEUS_SCRAPE_ENABLED"
DDPrometheusScrapeServiceEndpoints = "DD_PROMETHEUS_SCRAPE_SERVICE_ENDPOINTS"
DDPrometheusScrapeChecks = "DD_PROMETHEUS_SCRAPE_CHECKS"
DDCollectKubernetesEvents = "DD_COLLECT_KUBERNETES_EVENTS"
DDLeaderLeaseName = "DD_LEADER_LEASE_NAME"
DDClusterAgentTokenName = "DD_CLUSTER_AGENT_TOKEN_NAME"
DDClusterAgentEnabled = "DD_CLUSTER_AGENT_ENABLED"
DDClusterChecksEnabled = "DD_CLUSTER_CHECKS_ENABLED"
DDCLCRunnerEnabled = "DD_CLC_RUNNER_ENABLED"
DDCLCRunnerHost = "DD_CLC_RUNNER_HOST"
DDCLCRunnerID = "DD_CLC_RUNNER_ID"
DDExtraConfigProviders = "DD_EXTRA_CONFIG_PROVIDERS"
DDEnableMetadataCollection = "DD_ENABLE_METADATA_COLLECTION"
DDDogstatsdEnabled = "DD_USE_DOGSTATSD"
DDHostname = "DD_HOSTNAME"
DatadogHost = "DATADOG_HOST"
DDAdmissionControllerEnabled = "DD_ADMISSION_CONTROLLER_ENABLED"
DDAdmissionControllerInjectConfig = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_ENABLED"
DDAdmissionControllerInjectConfigMode = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_MODE"
DDAdmissionControllerInjectTags = "DD_ADMISSION_CONTROLLER_INJECT_TAGS_ENABLED"
DDAdmissionControllerLocalServiceName = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_LOCAL_SERVICE_NAME"
DDAdmissionControllerMutateUnlabelled = "DD_ADMISSION_CONTROLLER_MUTATE_UNLABELLED"
DDAdmissionControllerServiceName = "DD_ADMISSION_CONTROLLER_SERVICE_NAME"
DDAPIKey = "DD_API_KEY"
DDAPMEnabled = "DD_APM_ENABLED"
DDAppKey = "DD_APP_KEY"
DDAuthTokenFilePath = "DD_AUTH_TOKEN_FILE_PATH"
DDClcRunnerEnabled = "DD_CLC_RUNNER_ENABLED"
DDClcRunnerHost = "DD_CLC_RUNNER_HOST"
DDClcRunnerID = "DD_CLC_RUNNER_ID"
DDClusterAgentAuthToken = "DD_CLUSTER_AGENT_AUTH_TOKEN"
DDClusterAgentEnabled = "DD_CLUSTER_AGENT_ENABLED"
DDClusterAgentKubeServiceName = "DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME"
DDClusterAgentTokenName = "DD_CLUSTER_AGENT_TOKEN_NAME"
DDClusterChecksEnabled = "DD_CLUSTER_CHECKS_ENABLED"
DDClusterName = "DD_CLUSTER_NAME"
DDCollectKubernetesEvents = "DD_COLLECT_KUBERNETES_EVENTS"
DDComplianceConfigCheckInterval = "DD_COMPLIANCE_CONFIG_CHECK_INTERVAL"
DDComplianceConfigDir = "DD_COMPLIANCE_CONFIG_DIR"
DDComplianceConfigEnabled = "DD_COMPLIANCE_CONFIG_ENABLED"
DDCriSocketPath = "DD_CRI_SOCKET_PATH"
DDddURL = "DD_DD_URL"
DDDogstatsdEnabled = "DD_USE_DOGSTATSD"
DDDogstatsdMapperProfiles = "DD_DOGSTATSD_MAPPER_PROFILES"
DDDogstatsdOriginDetection = "DD_DOGSTATSD_ORIGIN_DETECTION"
DDDogstatsdPort = "DD_DOGSTATSD_PORT"
DDDogstatsdSocket = "DD_DOGSTATSD_SOCKET"
DDEnableMetadataCollection = "DD_ENABLE_METADATA_COLLECTION"
DDEnableOOMKillEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_OOM_KILL"
DDEnableTCPQueueLengthEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_TCP_QUEUE_LENGTH"
DDExternalMetricsProviderAPIKey = "DD_EXTERNAL_METRICS_PROVIDER_API_KEY"
DDExternalMetricsProviderAppKey = "DD_EXTERNAL_METRICS_PROVIDER_APP_KEY"
DDExternalMetricsProviderEndpoint = "DD_EXTERNAL_METRICS_PROVIDER_ENDPOINT"
DDExtraConfigProviders = "DD_EXTRA_CONFIG_PROVIDERS"
DDExtraListeners = "DD_EXTRA_LISTENERS"
DDHealthPort = "DD_HEALTH_PORT"
DDHostname = "DD_HOSTNAME"
DDHostRootEnvVar = "HOST_ROOT"
DDIgnoreAutoConf = "DD_IGNORE_AUTOCONF"
DDKubeletCAPath = "DD_KUBELET_CLIENT_CA"
DDKubeletHost = "DD_KUBERNETES_KUBELET_HOST"
DDKubeletTLSVerify = "DD_KUBELET_TLS_VERIFY"
DDKubeStateMetricsCoreConfigMap = "DD_KUBE_STATE_METRICS_CORE_CONFIGMAP_NAME"
DDKubeStateMetricsCoreEnabled = "DD_KUBE_STATE_METRICS_CORE_ENABLED"
DDLeaderElection = "DD_LEADER_ELECTION"
DDLeaderLeaseName = "DD_LEADER_LEASE_NAME"
DDLogLevel = "DD_LOG_LEVEL"
DDLogsConfigContainerCollectAll = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL"
DDLogsConfigOpenFilesLimit = "DD_LOGS_CONFIG_OPEN_FILES_LIMIT"
DDLogsContainerCollectUsingFiles = "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE"
DDLogsEnabled = "DD_LOGS_ENABLED"
DDMetricsProviderEnabled = "DD_EXTERNAL_METRICS_PROVIDER_ENABLED"
DDMetricsProviderPort = "DD_EXTERNAL_METRICS_PROVIDER_PORT"
DDMetricsProviderUseDatadogMetric = "DD_EXTERNAL_METRICS_PROVIDER_USE_DATADOGMETRIC_CRD"
DDMetricsProviderWPAController = "DD_EXTERNAL_METRICS_PROVIDER_WPA_CONTROLLER"
DDNamespaceLabelsAsTags = "DD_KUBERNETES_NAMESPACE_LABELS_AS_TAGS"
DDNodeLabelsAsTags = "DD_KUBERNETES_NODE_LABELS_AS_TAGS"
DDPodAnnotationsAsTags = "DD_KUBERNETES_POD_ANNOTATIONS_AS_TAGS"
DDPodLabelsAsTags = "DD_KUBERNETES_POD_LABELS_AS_TAGS"
DDPPMReceiverSocket = "DD_APM_RECEIVER_SOCKET"
DDProcessAgentEnabled = "DD_PROCESS_AGENT_ENABLED"
DDPrometheusScrapeChecks = "DD_PROMETHEUS_SCRAPE_CHECKS"
DDPrometheusScrapeEnabled = "DD_PROMETHEUS_SCRAPE_ENABLED"
DDPrometheusScrapeServiceEndpoints = "DD_PROMETHEUS_SCRAPE_SERVICE_ENDPOINTS"
DDRuntimeSecurityConfigEnabled = "DD_RUNTIME_SECURITY_CONFIG_ENABLED"
DDRuntimeSecurityConfigPoliciesDir = "DD_RUNTIME_SECURITY_CONFIG_POLICIES_DIR"
DDRuntimeSecurityConfigRemoteTaggerEnabled = "DD_RUNTIME_SECURITY_CONFIG_REMOTE_TAGGER"
DDRuntimeSecurityConfigSocket = "DD_RUNTIME_SECURITY_CONFIG_SOCKET"
DDRuntimeSecurityConfigSyscallMonitorEnabled = "DD_RUNTIME_SECURITY_CONFIG_SYSCALL_MONITOR_ENABLED"
DDSecretBackendCommand = "DD_SECRET_BACKEND_COMMAND"
DDSite = "DD_SITE"
DDSystemProbeAgentEnabled = "DD_SYSTEM_PROBE_ENABLED"
DDSystemProbeBPFDebugEnabled = DDSystemProbeEnvPrefix + "BPF_DEBUG"
DDSystemProbeCollectDNSStatsEnabled = "DD_COLLECT_DNS_STATS"
DDSystemProbeConntrackEnabled = DDSystemProbeEnvPrefix + "ENABLE_CONNTRACK"
DDSystemProbeDebugPort = DDSystemProbeEnvPrefix + "DEBUG_PORT"
DDSystemProbeEnabled = "DD_SYSTEM_PROBE_ENABLED"
DDSystemProbeEnvPrefix = "DD_SYSTEM_PROBE_CONFIG_"
DDSystemProbeExternal = "DD_SYSTEM_PROBE_EXTERNAL"
DDSystemProbeNPMEnabled = "DD_SYSTEM_PROBE_NETWORK_ENABLED"
DDSystemProbeServiceMonitoringEnabled = "DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED"
DDSystemProbeSocket = "DD_SYSPROBE_SOCKET"
DDSystemProbeOOMKillEnabled = DDSystemProbeEnvPrefix + "ENABLE_OOM_KILL"
DDSystemProbeTCPQueueLengthEnabled = DDSystemProbeEnvPrefix + "ENABLE_TCP_QUEUE_LENGTH"
DDTags = "DD_TAGS"
DockerHost = "DOCKER_HOST"

// KubernetesEnvvarName Env var used by the Datadog Agent container entrypoint
// to add kubelet config provider and listener
Expand Down
72 changes: 0 additions & 72 deletions apis/datadoghq/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,7 @@ package v1alpha1

// Datadog env var names
const (
DatadogHost = "DATADOG_HOST"
DDAPIKey = "DD_API_KEY"
DDSecretBackendCommand = "DD_SECRET_BACKEND_COMMAND"
DDClusterName = "DD_CLUSTER_NAME"
DDSite = "DD_SITE"
DDddURL = "DD_DD_URL"
DDLogLevel = "DD_LOG_LEVEL"
DDNamespaceLabelsAsTags = "DD_KUBERNETES_NAMESPACE_LABELS_AS_TAGS"
DDNodeLabelsAsTags = "DD_KUBERNETES_NODE_LABELS_AS_TAGS"
DDPodLabelsAsTags = "DD_KUBERNETES_POD_LABELS_AS_TAGS"
DDPodAnnotationsAsTags = "DD_KUBERNETES_POD_ANNOTATIONS_AS_TAGS"
DDTags = "DD_TAGS"
DDCollectKubeEvents = "DD_COLLECT_KUBERNETES_EVENTS"
DDLeaderElection = "DD_LEADER_ELECTION"
DDLeaderLeaseName = "DD_LEADER_LEASE_NAME"
DDLogsEnabled = "DD_LOGS_ENABLED"
DDLogsConfigContainerCollectAll = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL"
DDLogsContainerCollectUsingFiles = "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE"
DDLogsConfigOpenFilesLimit = "DD_LOGS_CONFIG_OPEN_FILES_LIMIT"
DDDogstatsdOriginDetection = "DD_DOGSTATSD_ORIGIN_DETECTION"
DDDogstatsdPort = "DD_DOGSTATSD_PORT"
DDDogstatsdSocket = "DD_DOGSTATSD_SOCKET"
DDDogstatsdMapperProfiles = "DD_DOGSTATSD_MAPPER_PROFILES"
DDClusterAgentAuthToken = "DD_CLUSTER_AGENT_AUTH_TOKEN"
DDClusterAgentTokenName = "DD_CLUSTER_AGENT_TOKEN_NAME"
DDMetricsProviderEnabled = "DD_EXTERNAL_METRICS_PROVIDER_ENABLED"
DDMetricsProviderPort = "DD_EXTERNAL_METRICS_PROVIDER_PORT"
DDMetricsProviderUseDatadogMetric = "DD_EXTERNAL_METRICS_PROVIDER_USE_DATADOGMETRIC_CRD"
DDMetricsProviderWPAController = "DD_EXTERNAL_METRICS_PROVIDER_WPA_CONTROLLER"
DDAppKey = "DD_APP_KEY"
DDExtraListeners = "DD_EXTRA_LISTENERS"
DDHostname = "DD_HOSTNAME"
DDPPMReceiverSocket = "DD_APM_RECEIVER_SOCKET"
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"
DDKubeletHost = "DD_KUBERNETES_KUBELET_HOST"
DDKubeletTLSVerify = "DD_KUBELET_TLS_VERIFY"
DDKubeletCAPath = "DD_KUBELET_CLIENT_CA"
DDCriSocketPath = "DD_CRI_SOCKET_PATH"
DockerHost = "DOCKER_HOST"
DDAdmissionControllerEnabled = "DD_ADMISSION_CONTROLLER_ENABLED"
DDAdmissionControllerMutateUnlabelled = "DD_ADMISSION_CONTROLLER_MUTATE_UNLABELLED"
DDAdmissionControllerInjectConfig = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_ENABLED"
DDAdmissionControllerInjectTags = "DD_ADMISSION_CONTROLLER_INJECT_TAGS_ENABLED"
DDAdmissionControllerServiceName = "DD_ADMISSION_CONTROLLER_SERVICE_NAME"
DDAdmissionControllerInjectConfigMode = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_MODE"
DDAdmissionControllerLocalServiceName = "DD_ADMISSION_CONTROLLER_INJECT_CONFIG_LOCAL_SERVICE_NAME"
DDComplianceConfigEnabled = "DD_COMPLIANCE_CONFIG_ENABLED"
DDComplianceConfigCheckInterval = "DD_COMPLIANCE_CONFIG_CHECK_INTERVAL"
DDComplianceConfigDir = "DD_COMPLIANCE_CONFIG_DIR"
DDRuntimeSecurityConfigEnabled = "DD_RUNTIME_SECURITY_CONFIG_ENABLED"
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"

// Datadog volume names and mount paths

LogDatadogVolumeName = "logdatadog"
LogDatadogVolumePath = "/var/log/datadog"
TmpVolumeName = "tmp"
Expand Down
49 changes: 49 additions & 0 deletions apis/datadoghq/v1alpha1/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,55 @@ import (
apicommon "github.com/DataDog/datadog-operator/apis/datadoghq/common"
)

// GetDefaultCredentialsSecretName returns the default name for credentials secret
func GetDefaultCredentialsSecretName(dda *DatadogAgent) string {
return dda.Name
}

// GetAPIKeySecret returns the API key secret name and the key inside the secret
// returns <is_set>, secretName, secretKey
func GetAPIKeySecret(credentials *DatadogCredentials, defaultName string) (bool, string, string) {
if credentials.APISecret != nil {
if credentials.APISecret.KeyName != "" {
return true, credentials.APISecret.SecretName, credentials.APISecret.KeyName
}

return true, credentials.APISecret.SecretName, apicommon.DefaultAPIKeyKey
}

if credentials.APIKeyExistingSecret != "" {
return true, credentials.APIKeyExistingSecret, apicommon.DefaultAPIKeyKey
}

if credentials.APIKey != "" {
return true, defaultName, apicommon.DefaultAPIKeyKey
}

return false, defaultName, apicommon.DefaultAPIKeyKey
}

// GetAppKeySecret returns the APP key secret name and the key inside the secret
// returns <is_set>, secretName, secretKey
func GetAppKeySecret(credentials *DatadogCredentials, defaultName string) (bool, string, string) {
if credentials.APPSecret != nil {
if credentials.APPSecret.KeyName != "" {
return true, credentials.APPSecret.SecretName, credentials.APPSecret.KeyName
}

return true, credentials.APPSecret.SecretName, apicommon.DefaultAPPKeyKey
}

if credentials.AppKeyExistingSecret != "" {
return true, credentials.AppKeyExistingSecret, apicommon.DefaultAPPKeyKey
}

if credentials.AppKey != "" {
return true, defaultName, apicommon.DefaultAPPKeyKey
}

return false, defaultName, apicommon.DefaultAPPKeyKey
}

// GetKeysFromCredentials returns any key data that need to be stored in a new secret
func GetKeysFromCredentials(credentials *DatadogCredentials) map[string][]byte {
data := make(map[string][]byte)
Expand Down
5 changes: 4 additions & 1 deletion apis/datadoghq/v1alpha1/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ func GetConfName(owner metav1.Object, conf *CustomConfigSpec, defaultName string
return fmt.Sprintf("%s-%s", owner.GetName(), defaultName)
}

// GetAgentServiceAccount returns the node agent serviceAccountName
// GetAgentServiceAccount returns the agent serviceAccountName
func GetAgentServiceAccount(dda *DatadogAgent) string {
saDefault := fmt.Sprintf("%s-%s", dda.Name, common.DefaultAgentResourceSuffix)

if dda.Spec.Agent.Rbac != nil && dda.Spec.Agent.Rbac.ServiceAccountName != nil {
return *dda.Spec.Agent.Rbac.ServiceAccountName
}
return saDefault
}

Expand Down
Loading

0 comments on commit 615b938

Please sign in to comment.