Skip to content

Commit

Permalink
Fix conflicting resource names for dda w/operator (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanny-jiang authored Dec 17, 2024
1 parent f0e51ab commit 10486ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions components/datadog/agent/kubernetes_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ func NewDDAWithOperator(e config.Env, resourceName string, kubeProvider *kuberne
return err
}

pulumiResourceOptions := append(ddaParams.PulumiResourceOptions, pulumi.Parent(comp))
ddaParams.PulumiResourceOptions = append(ddaParams.PulumiResourceOptions, pulumi.Parent(comp))

_, err = dda.K8sAppDefinition(e, kubeProvider, ddaParams, pulumiResourceOptions...)
_, err = dda.K8sAppDefinition(e, kubeProvider, ddaParams, ddaParams.PulumiResourceOptions...)

if err != nil {
return err
}

baseName := "dda-linux"
baseName := "dda-with-operator-linux"

comp.LinuxNodeAgent, err = componentskube.NewKubernetesObjRef(e, baseName+"-nodeAgent", ddaParams.Namespace, "Pod", pulumi.String("").ToStringOutput(), pulumi.String("datadoghq/v2alpha1").ToStringOutput(), map[string]string{"app.kubernetes.io/instance": ddaParams.DDAConfig.Name + "-agent"})

Expand Down
14 changes: 7 additions & 7 deletions components/datadog/operator/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type HelmComponent struct {
func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi.ResourceOption) (*HelmComponent, error) {
apiKey := e.AgentAPIKey()
appKey := e.AgentAPPKey()
baseName := "dda"

opts = append(opts, pulumi.Providers(args.KubeProvider), e.WithProviders(config.ProviderRandom), pulumi.DeletedWith(args.KubeProvider))

helmComponent := &HelmComponent{}
Expand All @@ -64,7 +64,7 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi
secret, err := corev1.NewSecret(e.Ctx(), "datadog-credentials", &corev1.SecretArgs{
Metadata: metav1.ObjectMetaArgs{
Namespace: ns.Metadata.Name(),
Name: pulumi.Sprintf("%s-datadog-credentials", baseName),
Name: pulumi.String("dda-datadog-credentials"),
},
StringData: pulumi.StringMap{
"api-key": apiKey,
Expand Down Expand Up @@ -93,9 +93,9 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi
operatorImagePath = args.OperatorFullImagePath
}
operatorImagePath, operatorImageTag := utils.ParseImageReference(operatorImagePath)
linuxInstallName := baseName + "-operator-linux"
linuxInstallName := "datadog-operator-linux"

values := buildLinuxHelmValues(baseName, operatorImagePath, operatorImageTag)
values := buildLinuxHelmValues(operatorImagePath, operatorImageTag)
values.configureImagePullSecret(imgPullSecret)

defaultYAMLValues := values.toYAMLPulumiAssetOutput()
Expand Down Expand Up @@ -132,10 +132,10 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi

type HelmValues pulumi.Map

func buildLinuxHelmValues(baseName string, operatorImagePath string, operatorImageTag string) HelmValues {
func buildLinuxHelmValues(operatorImagePath string, operatorImageTag string) HelmValues {
return HelmValues{
"apiKeyExistingSecret": pulumi.String(baseName + "-datadog-credentials"),
"appKeyExistingSecret": pulumi.String(baseName + "-datadog-credentials"),
"apiKeyExistingSecret": pulumi.String("dda-datadog-credentials"),
"appKeyExistingSecret": pulumi.String("dda-datadog-credentials"),
"image": pulumi.Map{
"repository": pulumi.String(operatorImagePath),
"tag": pulumi.String(operatorImageTag),
Expand Down
6 changes: 3 additions & 3 deletions scenarios/aws/kindvm/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ spec:
)
}

operatorAgentComponent, err := agent.NewDDAWithOperator(&awsEnv, awsEnv.CommonNamer().ResourceName("dd-operator-agent"), kindKubeProvider, ddaOptions...)
k8sAgentWithOperatorComp, err := agent.NewDDAWithOperator(&awsEnv, awsEnv.CommonNamer().ResourceName("datadog-agent-with-operator"), kindKubeProvider, ddaOptions...)

if err != nil {
return err
}

dependsOnCrd = utils.PulumiDependsOn(operatorAgentComponent)
dependsOnCrd = utils.PulumiDependsOn(k8sAgentWithOperatorComp)

if err := operatorAgentComponent.Export(awsEnv.Ctx(), nil); err != nil {
if err := k8sAgentWithOperatorComp.Export(awsEnv.Ctx(), nil); err != nil {
return err
}

Expand Down

0 comments on commit 10486ae

Please sign in to comment.