Skip to content

Commit 57b00c8

Browse files
committed
Using spec.controlPlaneNamespace instead of cr.Namespace
Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
1 parent c076abc commit 57b00c8

28 files changed

+312
-312
lines changed

controllers/clusterargocd/applicationset.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetDeployment(cr *argoproj.
162162

163163
existing := newDeploymentWithSuffix("applicationset-controller", "controller", cr)
164164

165-
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing)
165+
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, existing.Name, existing)
166166
if err != nil {
167167
return err
168168
}
@@ -238,7 +238,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetDeployment(cr *argoproj.
238238
if scmRootCAConfigMapName := getSCMRootCAConfigMapName(cr); scmRootCAConfigMapName != "" {
239239
cm := newConfigMapWithName(scmRootCAConfigMapName, cr)
240240

241-
cmExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cr.Spec.ApplicationSet.SCMRootCAConfigMap, cm)
241+
cmExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cr.Spec.ApplicationSet.SCMRootCAConfigMap, cm)
242242
if err != nil {
243243
return err
244244
}
@@ -445,7 +445,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetServiceAccount(cr *argop
445445
setAppSetLabels(&sa.ObjectMeta)
446446

447447
exists := true
448-
if err := argoutil.FetchObject(r.Client, cr.Namespace, sa.Name, sa); err != nil {
448+
if err := argoutil.FetchObject(r.Client, cr.Spec.ControlPlaneNamespace, sa.Name, sa); err != nil {
449449
if !apierrors.IsNotFound(err) {
450450
return sa, err
451451
}
@@ -543,7 +543,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetClusterRoleBinding(cr *a
543543
{
544544
Kind: v1.ServiceAccountKind,
545545
Name: sa.Name,
546-
Namespace: cr.Namespace,
546+
Namespace: cr.Spec.ControlPlaneNamespace,
547547
},
548548
}
549549
clusterRB.RoleRef = v1.RoleRef{
@@ -620,7 +620,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetSourceNamespacesResource
620620
if value, ok := namespace.Labels[common.ArgoCDManagedByLabel]; ok && value != "" {
621621
log.Info(fmt.Sprintf("Skipping reconciling resources for namespace %s as it is already managed-by namespace %s.", namespace.Name, value))
622622
// remove any source namespace resources
623-
if val, ok1 := namespace.Labels[common.ArgoCDApplicationSetManagedByClusterArgoCDLabel]; ok1 && val != cr.Namespace {
623+
if val, ok1 := namespace.Labels[common.ArgoCDApplicationSetManagedByClusterArgoCDLabel]; ok1 && val != cr.Spec.ControlPlaneNamespace {
624624
delete(r.ManagedApplicationSetSourceNamespaces, namespace.Name)
625625
if err := r.cleanupUnmanagedApplicationSetSourceNamespaceResources(cr, namespace.Name); err != nil {
626626
log.Error(err, fmt.Sprintf("error cleaning up resources for namespace %s", namespace.Name))
@@ -640,8 +640,8 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetSourceNamespacesResource
640640
if namespace.Labels == nil {
641641
namespace.Labels = make(map[string]string)
642642
}
643-
namespace.Labels[common.ArgoCDApplicationSetManagedByClusterArgoCDLabel] = cr.Namespace
644-
explanation := fmt.Sprintf("adding label '%s=%s'", common.ArgoCDApplicationSetManagedByClusterArgoCDLabel, cr.Namespace)
643+
namespace.Labels[common.ArgoCDApplicationSetManagedByClusterArgoCDLabel] = cr.Spec.ControlPlaneNamespace
644+
explanation := fmt.Sprintf("adding label '%s=%s'", common.ArgoCDApplicationSetManagedByClusterArgoCDLabel, cr.Spec.ControlPlaneNamespace)
645645
argoutil.LogResourceUpdate(log, namespace, explanation)
646646
if err := r.Update(context.TODO(), namespace); err != nil {
647647
log.Error(err, fmt.Sprintf("failed to add label from namespace [%s]", namespace.Name))
@@ -678,7 +678,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetSourceNamespacesResource
678678
{
679679
Kind: v1.ServiceAccountKind,
680680
Name: getServiceAccountName(cr.Name, "applicationset-controller"),
681-
Namespace: cr.Namespace,
681+
Namespace: cr.Spec.ControlPlaneNamespace,
682682
},
683683
},
684684
}
@@ -708,7 +708,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetRole(cr *argoproj.Cluste
708708
setAppSetLabels(&role.ObjectMeta)
709709

710710
exists := true
711-
err := r.Get(context.TODO(), types.NamespacedName{Name: role.Name, Namespace: cr.Namespace}, role)
711+
err := r.Get(context.TODO(), types.NamespacedName{Name: role.Name, Namespace: cr.Spec.ControlPlaneNamespace}, role)
712712
if err != nil {
713713
if !apierrors.IsNotFound(err) {
714714
return role, err
@@ -751,7 +751,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetRoleBinding(cr *argoproj
751751

752752
// fetch existing rolebinding by name
753753
roleBindingExists := true
754-
if err := r.Get(context.TODO(), types.NamespacedName{Name: roleBinding.Name, Namespace: cr.Namespace}, roleBinding); err != nil {
754+
if err := r.Get(context.TODO(), types.NamespacedName{Name: roleBinding.Name, Namespace: cr.Spec.ControlPlaneNamespace}, roleBinding); err != nil {
755755
if !apierrors.IsNotFound(err) {
756756
return fmt.Errorf("failed to get the rolebinding associated with %s : %s", name, err)
757757
}
@@ -824,15 +824,15 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetService(cr *argoproj.Clu
824824
log.Info("reconciling applicationset service")
825825

826826
svc := newServiceWithSuffix(common.ApplicationSetServiceNameSuffix, common.ApplicationSetServiceNameSuffix, cr)
827-
serviceExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, svc.Name, svc)
827+
serviceExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, svc.Name, svc)
828828
if err != nil {
829829
return err
830830
}
831831

832832
if cr.Spec.ApplicationSet == nil || !cr.Spec.ApplicationSet.IsEnabled() {
833833

834834
if serviceExists {
835-
err := argoutil.FetchObject(r.Client, cr.Namespace, svc.Name, svc)
835+
err := argoutil.FetchObject(r.Client, cr.Spec.ControlPlaneNamespace, svc.Name, svc)
836836
if err != nil {
837837
return err
838838
}
@@ -875,7 +875,7 @@ func (r *ReconcileClusterArgoCD) reconcileApplicationSetService(cr *argoproj.Clu
875875

876876
// Returns the name of the role/rolebinding for the source namespaces for applicationset-controller in the format of "argocdName-argocdNamespace-applicationset"
877877
func getResourceNameForApplicationSetSourceNamespaces(cr *argoproj.ClusterArgoCD) string {
878-
return fmt.Sprintf("%s-%s-applicationset", cr.Name, cr.Namespace)
878+
return fmt.Sprintf("%s-%s-applicationset", cr.Name, cr.Spec.ControlPlaneNamespace)
879879
}
880880

881881
// removeUnmanagedApplicationSetSourceNamespaceResources cleansup resources from ApplicationSetSourceNamespaces if namespace is not managed by argocd instance.
@@ -976,7 +976,7 @@ func (r *ReconcileClusterArgoCD) setManagedApplicationSetSourceNamespaces(cr *ar
976976
}
977977
namespaces := &corev1.NamespaceList{}
978978
listOption := client.MatchingLabels{
979-
common.ArgoCDApplicationSetManagedByClusterArgoCDLabel: cr.Namespace,
979+
common.ArgoCDApplicationSetManagedByClusterArgoCDLabel: cr.Spec.ControlPlaneNamespace,
980980
}
981981

982982
// get the list of namespaces managed with "argocd.argoproj.io/applicationset-managed-by-cluster-argocd" label

controllers/clusterargocd/configmap.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func newConfigMap(cr *argoproj.ClusterArgoCD) *corev1.ConfigMap {
282282
cm := &corev1.ConfigMap{
283283
ObjectMeta: metav1.ObjectMeta{
284284
Name: cr.Name,
285-
Namespace: cr.Namespace,
285+
Namespace: cr.Spec.ControlPlaneNamespace,
286286
Labels: argoutil.LabelsForCluster(cr),
287287
},
288288
}
@@ -344,7 +344,7 @@ func (r *ReconcileClusterArgoCD) reconcileConfigMaps(cr *argoproj.ClusterArgoCD,
344344
func (r *ReconcileClusterArgoCD) reconcileCAConfigMap(cr *argoproj.ClusterArgoCD) error {
345345
cm := newConfigMapWithName(getCAConfigMapName(cr), cr)
346346

347-
configMapExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
347+
configMapExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
348348
if err != nil {
349349
return err
350350
}
@@ -353,7 +353,7 @@ func (r *ReconcileClusterArgoCD) reconcileCAConfigMap(cr *argoproj.ClusterArgoCD
353353
}
354354

355355
caSecret := argoutil.NewSecretWithSuffix(cr, common.ArgoCDCASuffix)
356-
caSecretExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, caSecret.Name, caSecret)
356+
caSecretExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, caSecret.Name, caSecret)
357357
if err != nil {
358358
return err
359359
}
@@ -516,7 +516,7 @@ func (r *ReconcileClusterArgoCD) reconcileArgoConfigMap(cr *argoproj.ClusterArgo
516516
}
517517

518518
existingCM := &corev1.ConfigMap{}
519-
found, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
519+
found, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
520520
if err != nil {
521521
return err
522522
}
@@ -594,7 +594,7 @@ func (r *ReconcileClusterArgoCD) reconcileGrafanaDashboards(cr *argoproj.Cluster
594594
func (r *ReconcileClusterArgoCD) reconcileRBAC(cr *argoproj.ClusterArgoCD) error {
595595
cm := newConfigMapWithName(common.ArgoCDRBACConfigMapName, cr)
596596

597-
found, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
597+
found, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
598598
if err != nil {
599599
return err
600600
}
@@ -724,7 +724,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAHealthConfigMap(cr *argoproj.Cl
724724
}
725725
if !cr.Spec.HA.Enabled {
726726
existingCM := &corev1.ConfigMap{}
727-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
727+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
728728
if err != nil {
729729
return err
730730
}
@@ -741,7 +741,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAHealthConfigMap(cr *argoproj.Cl
741741
}
742742

743743
existingCM := &corev1.ConfigMap{}
744-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
744+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
745745
if err != nil {
746746
return err
747747
}
@@ -773,7 +773,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAConfigMap(cr *argoproj.ClusterA
773773
if !cr.Spec.HA.Enabled {
774774

775775
existingCM := &corev1.ConfigMap{}
776-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
776+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
777777
if err != nil {
778778
return err
779779
}
@@ -791,7 +791,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAConfigMap(cr *argoproj.ClusterA
791791
}
792792

793793
existingCM := &corev1.ConfigMap{}
794-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
794+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
795795
if err != nil {
796796
return err
797797
}
@@ -812,7 +812,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAConfigMap(cr *argoproj.ClusterA
812812
func (r *ReconcileClusterArgoCD) recreateRedisHAConfigMap(cr *argoproj.ClusterArgoCD, useTLSForRedis bool) error {
813813
cm := newConfigMapWithName(common.ArgoCDRedisHAConfigMapName, cr)
814814

815-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
815+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
816816
if err != nil {
817817
return err
818818
}
@@ -828,7 +828,7 @@ func (r *ReconcileClusterArgoCD) recreateRedisHAConfigMap(cr *argoproj.ClusterAr
828828
func (r *ReconcileClusterArgoCD) recreateRedisHAHealthConfigMap(cr *argoproj.ClusterArgoCD, useTLSForRedis bool) error {
829829
cm := newConfigMapWithName(common.ArgoCDRedisHAHealthConfigMapName, cr)
830830

831-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
831+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
832832
if err != nil {
833833
return err
834834
}
@@ -844,7 +844,7 @@ func (r *ReconcileClusterArgoCD) recreateRedisHAHealthConfigMap(cr *argoproj.Clu
844844
// reconcileSSHKnownHosts will ensure that the ArgoCD SSH Known Hosts ConfigMap is present.
845845
func (r *ReconcileClusterArgoCD) reconcileSSHKnownHosts(cr *argoproj.ClusterArgoCD) error {
846846
cm := newConfigMapWithName(common.ArgoCDKnownHostsConfigMapName, cr)
847-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
847+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
848848
if err != nil {
849849
return err
850850
}
@@ -866,7 +866,7 @@ func (r *ReconcileClusterArgoCD) reconcileSSHKnownHosts(cr *argoproj.ClusterArgo
866866
// reconcileTLSCerts will ensure that the ArgoCD TLS Certs ConfigMap is present.
867867
func (r *ReconcileClusterArgoCD) reconcileTLSCerts(cr *argoproj.ClusterArgoCD) error {
868868
cm := newConfigMapWithName(common.ArgoCDTLSCertsConfigMapName, cr)
869-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
869+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
870870
if err != nil {
871871
return err
872872
}
@@ -886,7 +886,7 @@ func (r *ReconcileClusterArgoCD) reconcileTLSCerts(cr *argoproj.ClusterArgoCD) e
886886
// reconcileGPGKeysConfigMap creates a gpg-keys config map
887887
func (r *ReconcileClusterArgoCD) reconcileGPGKeysConfigMap(cr *argoproj.ClusterArgoCD) error {
888888
cm := newConfigMapWithName(common.ArgoCDGPGKeysConfigMapName, cr)
889-
exists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, cm)
889+
exists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, cm)
890890
if err != nil {
891891
return err
892892
}
@@ -921,7 +921,7 @@ func (r *ReconcileClusterArgoCD) reconcileArgoCmdParamsConfigMap(cr *argoproj.Cl
921921
}
922922

923923
existingCM := &corev1.ConfigMap{}
924-
isFound, err := argoutil.IsObjectFound(r.Client, cr.Namespace, cm.Name, existingCM)
924+
isFound, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, cm.Name, existingCM)
925925
if err != nil {
926926
return err
927927
}

controllers/clusterargocd/configmap_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestReconcileClusterArgoCD_reconcileRedisHAHealthConfigMap(t *testing.T) {
134134
// Modify ConfigMap data to simulate external changes
135135
existingCM := &corev1.ConfigMap{}
136136

137-
exists, err := argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAHealthConfigMapName, existingCM)
137+
exists, err := argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAHealthConfigMapName, existingCM)
138138
assert.Nil(t, err)
139139
assert.True(t, exists)
140140
existingCM.Data["redis_liveness.sh"] = "modified_script_content"
@@ -143,15 +143,15 @@ func TestReconcileClusterArgoCD_reconcileRedisHAHealthConfigMap(t *testing.T) {
143143
// Reconcile again and verify changes are reverted
144144
assert.NoError(t, r.reconcileRedisHAHealthConfigMap(cr, false))
145145
existingCMAfter := &corev1.ConfigMap{}
146-
exists, err = argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAHealthConfigMapName, existingCMAfter)
146+
exists, err = argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAHealthConfigMapName, existingCMAfter)
147147
assert.True(t, exists)
148148
assert.Nil(t, err)
149149
assert.Equal(t, getRedisLivenessScript(false), existingCMAfter.Data["redis_liveness.sh"])
150150

151151
// Disable HA and ensure ConfigMap is deleted
152152
cr.Spec.HA.Enabled = false
153153
assert.NoError(t, r.reconcileRedisHAHealthConfigMap(cr, false))
154-
exists, err = argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAHealthConfigMapName, existingCM)
154+
exists, err = argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAHealthConfigMapName, existingCM)
155155
assert.Nil(t, err)
156156
assert.False(t, exists)
157157
}
@@ -177,7 +177,7 @@ func TestReconcileClusterArgoCD_reconcileRedisHAConfigMap(t *testing.T) {
177177

178178
// Modify ConfigMap data to simulate external changes
179179
existingCM := &corev1.ConfigMap{}
180-
exists, err := argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAConfigMapName, existingCM)
180+
exists, err := argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAConfigMapName, existingCM)
181181
assert.Nil(t, err)
182182
assert.True(t, exists)
183183
existingCM.Data["haproxy.cfg"] = "modified_config_content"
@@ -186,15 +186,15 @@ func TestReconcileClusterArgoCD_reconcileRedisHAConfigMap(t *testing.T) {
186186
// Reconcile again and verify changes are reverted
187187
assert.NoError(t, r.reconcileRedisHAConfigMap(cr, false))
188188
existingCMAfter := &corev1.ConfigMap{}
189-
exists, err = argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAConfigMapName, existingCMAfter)
189+
exists, err = argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAConfigMapName, existingCMAfter)
190190
assert.Nil(t, err)
191191
assert.True(t, exists)
192192
assert.Equal(t, getRedisHAProxyConfig(cr, false), existingCMAfter.Data["haproxy.cfg"])
193193

194194
// Disable HA and ensure ConfigMap is deleted
195195
cr.Spec.HA.Enabled = false
196196
assert.NoError(t, r.reconcileRedisHAConfigMap(cr, false))
197-
exists, err = argoutil.IsObjectFound(cl, cr.Namespace, common.ArgoCDRedisHAConfigMapName, existingCM)
197+
exists, err = argoutil.IsObjectFound(cl, cr.Spec.ControlPlaneNamespace, common.ArgoCDRedisHAConfigMapName, existingCM)
198198
assert.Nil(t, err)
199199
assert.False(t, exists)
200200
}
@@ -1667,7 +1667,7 @@ func TestReconcileClusterArgoCD_RemovesLegacyLogEnforceFlag(t *testing.T) {
16671667
cm := &corev1.ConfigMap{
16681668
ObjectMeta: metav1.ObjectMeta{
16691669
Name: common.ArgoCDConfigMapName,
1670-
Namespace: cr.Namespace,
1670+
Namespace: cr.Spec.ControlPlaneNamespace,
16711671
},
16721672
Data: map[string]string{
16731673
"server.rbac.log.enforce.enable": "true",

controllers/clusterargocd/deployment.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (r *ReconcileClusterArgoCD) getArgoCDExport(cr *argoproj.ClusterArgoCD) (*a
5151
return nil, nil
5252
}
5353

54-
namespace := cr.Namespace
54+
namespace := cr.Spec.ControlPlaneNamespace
5555
if cr.Spec.Import.Namespace != nil && len(*cr.Spec.Import.Namespace) > 0 {
5656
namespace = *cr.Spec.Import.Namespace
5757
}
@@ -77,7 +77,7 @@ func getArgoExportSecretName(export *argoprojv1alpha1.ArgoCDExport) string {
7777

7878
func getArgoImportBackend(client client.Client, cr *argoproj.ClusterArgoCD) (string, error) {
7979
backend := common.ArgoCDExportStorageBackendLocal
80-
namespace := cr.Namespace
80+
namespace := cr.Spec.ControlPlaneNamespace
8181
if cr.Spec.Import != nil && cr.Spec.Import.Namespace != nil && len(*cr.Spec.Import.Namespace) > 0 {
8282
namespace = *cr.Spec.Import.Namespace
8383
}
@@ -328,7 +328,7 @@ func newDeployment(cr *argoproj.ClusterArgoCD) *appsv1.Deployment {
328328
return &appsv1.Deployment{
329329
ObjectMeta: metav1.ObjectMeta{
330330
Name: cr.Name,
331-
Namespace: cr.Namespace,
331+
Namespace: cr.Spec.ControlPlaneNamespace,
332332
Labels: argoutil.LabelsForCluster(cr),
333333
},
334334
}
@@ -486,7 +486,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisDeployment(cr *argoproj.ClusterAr
486486
}
487487

488488
existing := newDeploymentWithSuffix("redis", "redis", cr)
489-
deplFound, err := argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing)
489+
deplFound, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, existing.Name, existing)
490490
if err != nil {
491491
return err
492492
}
@@ -801,7 +801,7 @@ func (r *ReconcileClusterArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.Cl
801801
}
802802

803803
existing := newDeploymentWithSuffix("redis-ha-haproxy", "redis", cr)
804-
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing)
804+
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, existing.Name, existing)
805805
if err != nil {
806806
return err
807807
}
@@ -1142,7 +1142,7 @@ func (r *ReconcileClusterArgoCD) reconcileServerDeployment(cr *argoproj.ClusterA
11421142
}
11431143

11441144
existing := newDeploymentWithSuffix("server", "server", cr)
1145-
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing)
1145+
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Spec.ControlPlaneNamespace, existing.Name, existing)
11461146
if err != nil {
11471147
return err
11481148
}

0 commit comments

Comments
 (0)