Skip to content

Commit 5b4f2c9

Browse files
committed
fix: Remove dependency on argocd-redis secret
Signed-off-by: Jayendra Parsai <[email protected]>
1 parent b648a6e commit 5b4f2c9

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

controllers/argocdagent/deployment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func buildPrincipalContainerEnv(cr *argoproj.ArgoCD) []corev1.EnvVar {
370370
SecretKeyRef: &corev1.SecretKeySelector{
371371
Key: PrincipalRedisPasswordKey,
372372
LocalObjectReference: corev1.LocalObjectReference{
373-
Name: "argocd-redis",
373+
Name: PrincipalRedisSecretname,
374374
},
375375
Optional: ptr.To(true),
376376
},
@@ -411,7 +411,8 @@ const (
411411
EnvArgoCDPrincipalJwtSecretName = "ARGOCD_PRINCIPAL_JWT_SECRET_NAME"
412412
EnvArgoCDPrincipalImage = "ARGOCD_PRINCIPAL_IMAGE"
413413
EnvRedisPassword = "REDIS_PASSWORD"
414-
PrincipalRedisPasswordKey = "auth"
414+
PrincipalRedisPasswordKey = "admin.password"
415+
PrincipalRedisSecretname = "argocd-redis-initial-password" // #nosec G101
415416
)
416417

417418
// Logging Configuration

controllers/argocdagent/deployment_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ func TestReconcilePrincipalDeployment_VerifyDeploymentSpec(t *testing.T) {
396396
if env.Name == "REDIS_PASSWORD" {
397397
assert.NotNil(t, env.ValueFrom, "REDIS_PASSWORD should reference a secret")
398398
assert.NotNil(t, env.ValueFrom.SecretKeyRef, "REDIS_PASSWORD should reference a secret key")
399-
assert.Equal(t, "argocd-redis", env.ValueFrom.SecretKeyRef.Name)
400-
assert.Equal(t, "auth", env.ValueFrom.SecretKeyRef.Key)
399+
assert.Equal(t, PrincipalRedisSecretname, env.ValueFrom.SecretKeyRef.Name)
400+
assert.Equal(t, "admin.password", env.ValueFrom.SecretKeyRef.Key)
401401
} else {
402402
// All other environment variables should have direct values, not references
403403
assert.Nil(t, env.ValueFrom, "Environment variable %s should have direct value, not reference", env.Name)

controllers/argocdagent/scripts/create-agent-config.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ export ARGOCD_AGENT_PRINCIPAL_NAMESPACE=argocd # Should be same as ArgoCD instan
2222
KUBECTL=$(which kubectl)
2323
OPENSSL=$(which openssl)
2424

25-
# Create a secret for the redis password
26-
${KUBECTL} create secret generic argocd-redis -n argocd --from-literal=auth="$(${KUBECTL} get secret argocd-redis-initial-password -n argocd -o jsonpath='{.data.admin\.password}' | base64 -d)"
27-
2825
IPADDR=""
2926
if test "$IPADDR" = ""; then
3027
IPADDR=$(kubectl -n ${ARGOCD_AGENT_PRINCIPAL_NAMESPACE} get svc argocd-agent-principal -o jsonpath='{.spec.clusterIP}')

tests/ginkgo/sequential/1-051_validate_argocd_agent_principal_test.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"strings"
3030
"time"
3131

32-
"github.com/google/uuid"
3332
. "github.com/onsi/ginkgo/v2"
3433
. "github.com/onsi/gomega"
3534
appsv1 "k8s.io/api/apps/v1"
@@ -160,6 +159,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
160159
"argocd-agent-principal-tls",
161160
"argocd-agent-ca",
162161
"argocd-agent-resource-proxy-tls",
162+
"example-redis-initial-password",
163163
}
164164

165165
serviceNames = []string{argoCDAgentPrincipalName, fmt.Sprintf("%s-agent-principal-metrics", argoCDName), fmt.Sprintf("%s-redis", argoCDName), fmt.Sprintf("%s-repo-server", argoCDName), fmt.Sprintf("%s-server", argoCDName), fmt.Sprintf("%s-agent-principal-resource-proxy", argoCDName), fmt.Sprintf("%s-agent-principal-healthz", argoCDName)}
@@ -309,25 +309,16 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
309309
}
310310
Expect(k8sClient.Create(ctx, tlsSecret)).To(Succeed())
311311
}
312-
313-
// Create argocd-redis secret
314-
redisSecret := &corev1.Secret{
315-
ObjectMeta: metav1.ObjectMeta{
316-
Name: "argocd-redis",
317-
Namespace: ns.Name,
318-
},
319-
Data: map[string][]byte{
320-
"auth": []byte(uuid.New().String()),
321-
},
322-
}
323-
Expect(k8sClient.Create(ctx, redisSecret)).To(Succeed())
324312
}
325313

326314
// verifyExpectedResourcesExist will verify that the resources that are created for principal and ArgoCD are created.
327315
verifyExpectedResourcesExist := func(ns *corev1.Namespace) {
328316

329317
By("verifying expected resources exist")
330-
318+
Eventually(&corev1.Secret{
319+
ObjectMeta: metav1.ObjectMeta{
320+
Name: secretNames[4], Namespace: ns.Name,
321+
}}, "30s", "2s").Should(k8sFixture.ExistByName())
331322
Eventually(serviceAccount).Should(k8sFixture.ExistByName())
332323
Eventually(role).Should(k8sFixture.ExistByName())
333324
Eventually(roleBinding).Should(k8sFixture.ExistByName())
@@ -537,6 +528,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
537528

538529
By("Create ArgoCD instance")
539530

531+
argoCD.Spec.ArgoCDAgent.Principal.Server.Image = "quay.io/jparsai/argocd-agent:test"
540532
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
541533

542534
By("Verify expected resources are created for principal pod")
@@ -547,7 +539,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
547539

548540
container := deploymentFixture.GetTemplateSpecContainerByName(argoCDAgentPrincipalName, *principalDeployment)
549541
Expect(container).ToNot(BeNil())
550-
Expect(container.Image).To(Equal("quay.io/argoprojlabs/argocd-agent:v0.3.2"))
542+
Expect(container.Image).To(Equal("quay.io/jparsai/argocd-agent:test"))
551543

552544
By("Verify environment variables are set correctly")
553545

@@ -566,7 +558,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
566558
ac.Spec.ArgoCDAgent.Principal.Server.LogFormat = "json"
567559
ac.Spec.ArgoCDAgent.Principal.Server.KeepAliveMinInterval = "60s"
568560
ac.Spec.ArgoCDAgent.Principal.Server.EnableWebSocket = ptr.To(true)
569-
ac.Spec.ArgoCDAgent.Principal.Server.Image = "quay.io/argoprojlabs/argocd-agent:v0.4.0"
561+
ac.Spec.ArgoCDAgent.Principal.Server.Image = "quay.io/jparsai/argocd-agent:test1"
570562

571563
ac.Spec.ArgoCDAgent.Principal.Namespace.AllowedNamespaces = []string{"agent-managed", "agent-autonomous"}
572564
ac.Spec.ArgoCDAgent.Principal.Namespace.EnableNamespaceCreate = ptr.To(true)
@@ -608,7 +600,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
608600
if container == nil {
609601
return false
610602
}
611-
return container.Image == "quay.io/argoprojlabs/argocd-agent:v0.4.0"
603+
return container.Image == "quay.io/jparsai/argocd-agent:test1"
612604
}, "120s", "5s").Should(BeTrue(), "Principal deployment should have the updated image")
613605

614606
By("verify that deployment is in Ready state")

tests/k8s/1-051_validate_argocd_agent_principal/01-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ spec:
193193
- name: REDIS_PASSWORD
194194
valueFrom:
195195
secretKeyRef:
196-
key: auth
197-
name: argocd-redis
196+
key: admin.password
197+
name: argocd-redis-initial-password
198198
optional: true
199199

tests/k8s/1-051_validate_argocd_agent_principal/05-create-agent-secrets.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ commands:
88
- command: kubectl wait --for=condition=progressing --timeout=60s deployment/argocd-agent-principal -n argocd-e2e-cluster-config
99

1010
# Create the minimal required secrets
11-
- command: kubectl create secret generic argocd-redis -n argocd-e2e-cluster-config --from-literal=auth=testpassword
1211
- command: kubectl create secret generic argocd-agent-jwt -n argocd-e2e-cluster-config --from-literal=jwt.key="dummy-key"
1312

1413
# Generate real TLS certificates using temporary files in current directory

0 commit comments

Comments
 (0)