diff --git a/charts/gitops-runtime/templates/_components/cap-app-proxy/environment-variables/_main-container.yaml b/charts/gitops-runtime/templates/_components/cap-app-proxy/environment-variables/_main-container.yaml index 807ccb89..b836acbb 100644 --- a/charts/gitops-runtime/templates/_components/cap-app-proxy/environment-variables/_main-container.yaml +++ b/charts/gitops-runtime/templates/_components/cap-app-proxy/environment-variables/_main-container.yaml @@ -225,7 +225,7 @@ CACHE_PORT: {{ (splitList ":" (include "codefresh-gitops-runtime.argocd.redis.ur CACHE_PASSWORD: valueFrom: secretKeyRef: - name: gitops-runtime-redis + name: {{ ternary "gitops-runtime-redis" "argocd-redis" (or .Values.redis.enabled (index .Values "redis-ha" "enabled")) }} key: auth CF_SERVICE_NAME: {{ $appProxyName }} CF_SERVICE_VERSION: {{ $appProxyVersion }} diff --git a/charts/gitops-runtime/templates/_helpers.tpl b/charts/gitops-runtime/templates/_helpers.tpl index f8faffc0..d58efc0c 100644 --- a/charts/gitops-runtime/templates/_helpers.tpl +++ b/charts/gitops-runtime/templates/_helpers.tpl @@ -289,7 +289,9 @@ Determine argocd redis url {{- $port := .Values.redis.service.ports.redis.port }} {{- printf "%s:%v" $serviceName $port }} {{- else }} - {{- fail "ERROR: .Values.redis or .Values.redis-ha must be enabled!" }} + {{- $serviceName := index .Values "global" "integrations" "argo-cd" "redis" "svc" }} + {{- $port := index .Values "global" "integrations" "argo-cd" "redis" "port" }} + {{- printf "%s:%v" $serviceName $port }} {{- end }} {{- end}} diff --git a/charts/gitops-runtime/templates/argo-gateway/_env.yaml b/charts/gitops-runtime/templates/argo-gateway/_env.yaml index e3f3c207..73eae6b4 100644 --- a/charts/gitops-runtime/templates/argo-gateway/_env.yaml +++ b/charts/gitops-runtime/templates/argo-gateway/_env.yaml @@ -75,7 +75,7 @@ REDIS_COMPRESSION: REDIS_PASSWORD: valueFrom: secretKeyRef: - name: gitops-runtime-redis + name: {{ ternary "gitops-runtime-redis" "argocd-redis" (or .Values.redis.enabled (index .Values "redis-ha" "enabled")) }} key: auth REDIS_SERVER: valueFrom: diff --git a/charts/gitops-runtime/templates/argo-gateway/deployment.yaml b/charts/gitops-runtime/templates/argo-gateway/deployment.yaml index 6f549993..6a48e125 100644 --- a/charts/gitops-runtime/templates/argo-gateway/deployment.yaml +++ b/charts/gitops-runtime/templates/argo-gateway/deployment.yaml @@ -1,5 +1,7 @@ {{- $context := deepCopy . }} {{- $_ := set $context "Values" (deepCopy (get .Values "argo-gateway")) }} +{{- $_ := set $context.Values "redis" (deepCopy (get .Values "redis")) }} +{{- $_ := set $context.Values "redis-ha" (deepCopy (get .Values "redis-ha")) }} {{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }} {{/* Merge environment variables from calculated, defaults and overwrites */}} {{- $defaults := (include "argo-gateway.resources.environment-variables.defaults" $context | fromYaml) }} diff --git a/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/_env.yaml b/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/_env.yaml index 1638fee4..f9b44f6c 100644 --- a/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/_env.yaml +++ b/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/_env.yaml @@ -129,7 +129,7 @@ REDIS_COMPRESSION: REDIS_PASSWORD: valueFrom: secretKeyRef: - name: gitops-runtime-redis + name: {{ ternary "gitops-runtime-redis" "argocd-redis" (or .Values.redis.enabled (index .Values "redis-ha" "enabled")) }} key: auth REDIS_SERVER: valueFrom: diff --git a/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/deployment.yaml b/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/deployment.yaml index 794e91c6..d29c6aef 100644 --- a/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/deployment.yaml +++ b/charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/deployment.yaml @@ -1,5 +1,7 @@ {{- $context := deepCopy . }} {{- $_ := set $context "Values" (deepCopy (get (index .Values "global") "event-reporters")) }} +{{- $_ := set $context.Values "redis" (deepCopy (get .Values "redis")) }} +{{- $_ := set $context.Values "redis-ha" (deepCopy (get .Values "redis-ha")) }} {{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }} {{/* Merge .Values.event-reporters. with .Values.global.event-reporters */}} {{- $valuesOverrides := index .Values "event-reporters" "cluster-event-reporter" }} diff --git a/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/_env.yaml b/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/_env.yaml index 7aebb239..97c308d9 100644 --- a/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/_env.yaml +++ b/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/_env.yaml @@ -129,7 +129,7 @@ REDIS_COMPRESSION: REDIS_PASSWORD: valueFrom: secretKeyRef: - name: gitops-runtime-redis + name: {{ ternary "gitops-runtime-redis" "argocd-redis" (or .Values.redis.enabled (index .Values "redis-ha" "enabled")) }} key: auth REDIS_SERVER: valueFrom: diff --git a/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/deployment.yaml b/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/deployment.yaml index fc620544..34c203cc 100644 --- a/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/deployment.yaml +++ b/charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/deployment.yaml @@ -1,5 +1,7 @@ {{- $context := deepCopy . }} {{- $_ := set $context "Values" (deepCopy (get (index .Values "global") "event-reporters")) }} +{{- $_ := set $context.Values "redis" (deepCopy (get .Values "redis")) }} +{{- $_ := set $context.Values "redis-ha" (deepCopy (get .Values "redis-ha")) }} {{- $_ := set $context.Values "global" (deepCopy (get .Values "global")) }} {{/* Merge .Values.event-reporters. with .Values.global.event-reporters */}} {{- $valuesOverrides := index .Values "event-reporters" "runtime-event-reporter" }} diff --git a/charts/gitops-runtime/tests/argo-api-gateway_test.yaml b/charts/gitops-runtime/tests/argo-api-gateway_test.yaml index 1f02ef8b..d30f1463 100644 --- a/charts/gitops-runtime/tests/argo-api-gateway_test.yaml +++ b/charts/gitops-runtime/tests/argo-api-gateway_test.yaml @@ -3,7 +3,7 @@ suite: argo-gateway tests templates: - argo-gateway/** tests: - - it: Argo Api Gateway ConfigMap should have valid data + - it: Argo Api Gateway ConfigMap should have valid data (default) template: argo-gateway/configmap.yaml values: - ./values/mandatory-values-ingress.yaml @@ -13,11 +13,23 @@ tests: value: argo-cd-server:80 - equal: path: data["redis.server"] - value: runtime-redis:6379 + value: argo-cd-redis:6379 - equal: path: data["repo.server"] value: argo-cd-repo-server:8081 + - it: Argo Api Gateway ConfigMap should have valid redis url + set: + redis: + enabled: true + template: argo-gateway/configmap.yaml + values: + - ./values/mandatory-values-ingress.yaml + asserts: + - equal: + path: data["redis.server"] + value: runtime-redis:6379 + - it: Argo Api Gateway Deployment should have valid matchLabel selectors template: argo-gateway/deployment.yaml values: diff --git a/charts/gitops-runtime/tests/event-reporters_test.yaml b/charts/gitops-runtime/tests/event-reporters_test.yaml index c86c5526..ee4e5718 100644 --- a/charts/gitops-runtime/tests/event-reporters_test.yaml +++ b/charts/gitops-runtime/tests/event-reporters_test.yaml @@ -30,8 +30,26 @@ tests: path: metadata.name value: runtime-event-reporter - - it: Runtime Reporter ConfigMap should have valid data + - it: Runtime Reporter ConfigMap should have valid data (default) template: event-reporters/runtime-event-reporter/configmap.yaml + values: + - ./values/mandatory-values-ingress.yaml + asserts: + - equal: + path: data["argocd.server"] + value: argo-cd-server:80 + - equal: + path: data["redis.server"] + value: argo-cd-redis:6379 + - equal: + path: data["repo.server"] + value: argo-cd-repo-server:8081 + + - it: Runtime Reporter ConfigMap should have valid data (.Values.redis.enabled=true) + template: event-reporters/runtime-event-reporter/configmap.yaml + set: + redis: + enabled: true values: - ./values/mandatory-values-ingress.yaml asserts: @@ -45,7 +63,7 @@ tests: path: data["repo.server"] value: argo-cd-repo-server:8081 - - it: Runtime Reporter ConfigMap should have valid redis-ha url + - it: Runtime Reporter ConfigMap should have valid redis-ha url (.Values.redis-ha.enabled=true) template: event-reporters/runtime-event-reporter/configmap.yaml values: - ./values/mandatory-values-ingress.yaml @@ -168,8 +186,33 @@ tests: cpu: 200m memory: 256Mi - - it: Runtime Reporter should have correct REDIS_ environment variables + - it: Runtime Reporter should have correct REDIS_ environment variables (default) template: event-reporters/runtime-event-reporter/deployment.yaml + values: + - ./values/mandatory-values-ingress.yaml + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: REDIS_SERVER + valueFrom: + configMapKeyRef: + name: runtime-event-reporter-cmd-params-cm + key: redis.server + - contains: + path: spec.template.spec.containers[0].env + content: + name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: argocd-redis + key: auth + + - it: Runtime Reporter should have correct REDIS_ environment variables (.Values.redis.enabled=true or .Values.redis-ha.enabled=true) + template: event-reporters/runtime-event-reporter/deployment.yaml + set: + redis: + enabled: true values: - ./values/mandatory-values-ingress.yaml asserts: diff --git a/charts/gitops-runtime/tests/external_argocd_test.yaml b/charts/gitops-runtime/tests/external_argocd_test.yaml index eb34ce5d..3c69fe28 100644 --- a/charts/gitops-runtime/tests/external_argocd_test.yaml +++ b/charts/gitops-runtime/tests/external_argocd_test.yaml @@ -407,7 +407,7 @@ tests: asserts: - equal: path: data["redis.server"] - value: runtime-redis:6379 + value: argo-cd-redis:6379 - it: runtime-event-reporter ConfigMap should have valid Sources Server address template: event-reporters/runtime-event-reporter/configmap.yaml @@ -555,7 +555,7 @@ tests: asserts: - equal: path: data["redis.server"] - value: runtime-redis:6379 + value: argo-cd-redis:6379 - it: argo-gateway ConfigMap should have valid Repo Server URL template: argo-gateway/configmap.yaml diff --git a/charts/gitops-runtime/tests/redis_test.yaml b/charts/gitops-runtime/tests/redis_test.yaml index 3993e30d..9a19503a 100644 --- a/charts/gitops-runtime/tests/redis_test.yaml +++ b/charts/gitops-runtime/tests/redis_test.yaml @@ -6,7 +6,10 @@ templates: - redis/** - charts/redis-ha/** tests: - - it: Standalone Redis Deployment should be created by default + - it: Standalone Redis Deployment should be created when redis.enabled is true + set: + redis: + enabled: true template: redis/deployment.yaml values: - ./values/mandatory-values-ingress.yaml @@ -33,14 +36,14 @@ tests: name: runtime-redis not: true - - it: App-Proxy should have CACHE_ environment variables (standalone Redis) + - it: App-Proxy should have CACHE_ environment variables (ArgoCD Redis) template: app-proxy/deployment.yaml values: - ./values/mandatory-values-ingress.yaml asserts: - equal: path: spec.template.spec.containers[0].env[?(@.name=="CACHE_HOST")].value - value: runtime-redis + value: argo-cd-redis - equal: path: spec.template.spec.containers[0].env[?(@.name=="CACHE_PORT")].value value: "6379" @@ -48,7 +51,7 @@ tests: path: spec.template.spec.containers[0].env[?(@.name=="CACHE_PASSWORD")].valueFrom value: secretKeyRef: - name: gitops-runtime-redis + name: argocd-redis key: auth - it: App-Proxy should have CACHE_ environment variables (Redis HA) @@ -70,3 +73,23 @@ tests: secretKeyRef: name: gitops-runtime-redis key: auth + + - it: App-Proxy should have CACHE_ environment variables (Standalone Redis) + template: app-proxy/deployment.yaml + set: + redis.enabled: true + values: + - ./values/mandatory-values-ingress.yaml + asserts: + - equal: + path: spec.template.spec.containers[0].env[?(@.name=="CACHE_HOST")].value + value: runtime-redis + - equal: + path: spec.template.spec.containers[0].env[?(@.name=="CACHE_PORT")].value + value: "6379" + - equal: + path: spec.template.spec.containers[0].env[?(@.name=="CACHE_PASSWORD")].valueFrom + value: + secretKeyRef: + name: gitops-runtime-redis + key: auth diff --git a/charts/gitops-runtime/values.yaml b/charts/gitops-runtime/values.yaml index b7f92bfb..91908dba 100644 --- a/charts/gitops-runtime/values.yaml +++ b/charts/gitops-runtime/values.yaml @@ -118,6 +118,11 @@ global: svc: argo-cd-repo-server # -- Port of the ArgoCD repo server port: 8081 + redis: + # -- Service name of the ArgoCD Redis + svc: argo-cd-redis + # -- Port of the ArgoCD Redis + port: 6379 # -- Configuration for external Argo Rollouts external-argo-rollouts: # -- Rollout reporter settings @@ -759,7 +764,7 @@ redis-secret-init: # -- Standalone redis deployment # Will be replaced by redis-ha subchart when `redis-ha.enabled=true` redis: - enabled: true + enabled: false fullnameOverride: "runtime-redis" # -- Redis image image: