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

DDA w/operator component cleanups #1251

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 19 additions & 25 deletions components/datadog/agent/kubernetes_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ import (

func NewDDAWithOperator(e config.Env, resourceName string, kubeProvider *kubernetes.Provider, operatorOpts []operatorparams.Option, ddaOptions ...agentwithoperatorparams.Option) (*KubernetesAgent, error) {
return components.NewComponent(e, resourceName, func(comp *KubernetesAgent) error {

operatorParams, err := operatorparams.NewParams(e, operatorOpts...)
if err != nil {
return err
}

ddaParams, err := agentwithoperatorparams.NewParams(ddaOptions...)

if err != nil {
return err
}
Expand All @@ -33,36 +26,37 @@ func NewDDAWithOperator(e config.Env, resourceName string, kubeProvider *kuberne
return err
}

_, err = dda.K8sAppDefinition(e, kubeProvider, "datadog", ddaParams.FakeIntake, ddaParams.KubeletTLSVerify, e.Ctx().Stack(), ddaParams.DDAConfig, utils.PulumiDependsOn(operatorComp))
dda, err := dda.K8sAppDefinition(e, kubeProvider, ddaParams.Namespace, ddaParams.FakeIntake, ddaParams.KubeletTLSVerify, e.Ctx().Stack(), ddaParams.DDAConfig, utils.PulumiDependsOn(operatorComp))

if err != nil {
return err
}

baseName := "dda-linux"
if dda != nil {
fanny-jiang marked this conversation as resolved.
Show resolved Hide resolved
baseName := "dda-linux"

comp.LinuxNodeAgent, err = NewKubernetesObjRef(e, baseName+"-nodeAgent", operatorParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("Version").ToStringOutput(), map[string]string{"app": baseName + "-datadog"})
comp.LinuxNodeAgent, err = NewKubernetesObjRef(e, baseName+"-nodeAgent", ddaParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("Version").ToStringOutput(), map[string]string{"app": baseName + "-datadog"})

if err != nil {
return err
}
if err != nil {
return err
}

comp.LinuxClusterAgent, err = NewKubernetesObjRef(e, baseName+"-clusterAgent", operatorParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("Version").ToStringOutput(), map[string]string{
"app": baseName + "-datadog-cluster-agent",
})
comp.LinuxClusterAgent, err = NewKubernetesObjRef(e, baseName+"-clusterAgent", ddaParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("Version").ToStringOutput(), map[string]string{
"app": baseName + "-datadog-cluster-agent",
})

if err != nil {
return err
}
if err != nil {
return err
}

comp.LinuxClusterChecks, err = NewKubernetesObjRef(e, baseName+"-clusterChecks", operatorParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("version").ToStringOutput(), map[string]string{
"app": baseName + "-datadog-clusterchecks",
})
comp.LinuxClusterChecks, err = NewKubernetesObjRef(e, baseName+"-clusterChecks", ddaParams.Namespace, "Pod", pulumi.String("appVersion").ToStringOutput(), pulumi.String("version").ToStringOutput(), map[string]string{
"app": baseName + "-datadog-clusterchecks",
})

if err != nil {
return err
if err != nil {
return err
}
}

return nil
})
}
4 changes: 1 addition & 3 deletions components/datadog/agentwithoperatorparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ type Params struct {
type Option = func(*Params) error

func NewParams(options ...Option) (*Params, error) {
version := &Params{
Namespace: "datadog",
}
version := &Params{}
return common.ApplyOption(version, options)
}

Expand Down
9 changes: 7 additions & 2 deletions components/datadog/apps/dda/datadogagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ func K8sAppDefinition(e config.Env, kubeProvider *kubernetes.Provider, namespace
configureImagePullSecret(ddaConfig, imagePullSecret)
}

ddaName := "datadog-agent"
if e.PipelineID() != "" {
ddaName = fmt.Sprintf("datadog-agent-%s", e.PipelineID())
fanny-jiang marked this conversation as resolved.
Show resolved Hide resolved
}

_, err = apiextensions.NewCustomResource(e.Ctx(), "datadog-agent", &apiextensions.CustomResourceArgs{
ApiVersion: pulumi.String("datadoghq.com/v2alpha1"),
Kind: pulumi.String("DatadogAgent"),
Metadata: &metav1.ObjectMetaArgs{
Name: pulumi.String("datadog"),
Namespace: pulumi.String("datadog"),
Name: pulumi.String(ddaName),
Namespace: pulumi.String(namespace),
},
OtherFields: ddaConfig,
}, opts...)
Expand Down
5 changes: 1 addition & 4 deletions components/datadog/operatorparams/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ type Params struct {
type Option = func(*Params) error

func NewParams(e config.Env, options ...Option) (*Params, error) {
version := &Params{
Namespace: "datadog",
OperatorFullImagePath: "gcr.io/datadoghq/operator:latest",
}
version := &Params{}

if e.PipelineID() != "" && e.CommitSHA() != "" {
options = append(options, WithOperatorFullImagePath(utils.BuildDockerImagePath(fmt.Sprintf("%s/operator", e.InternalRegistry()), fmt.Sprintf("%s-%s", e.PipelineID(), e.CommitSHA()))))
Expand Down