From e652aa71e7e5fec5f0c0744cd3662b36ad6c32b2 Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Fri, 2 Feb 2024 18:57:58 -0800 Subject: [PATCH] fix: use redis cluster (#27) Signed-off-by: Jason C. Leach --- .devcontainer/docker-compose.yml | 2 +- devops/charts/controller/templates/deployment.yaml | 7 +++++-- devops/charts/controller/templates/secrets.yaml | 10 +--------- devops/charts/controller/values.yaml | 2 +- requirements.txt | 3 ++- src/redis_config.py | 8 +++++--- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 19ac7df..319fcb4 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -24,4 +24,4 @@ services: networks: - local_network environment: - - REDIS_URL=redis://redis:6379/0 + - REDIS_URI=redis://redis:6379/0 diff --git a/devops/charts/controller/templates/deployment.yaml b/devops/charts/controller/templates/deployment.yaml index b2f54bf..6760231 100644 --- a/devops/charts/controller/templates/deployment.yaml +++ b/devops/charts/controller/templates/deployment.yaml @@ -58,8 +58,6 @@ spec: envFrom: - secretRef: name: {{ include "attestation-controller.fullname" . }}-traction-creds - - secretRef: - name: {{ include "attestation-controller.fullname" . }}-redis-creds env: - name: PORT value: {{.Values.service.targetPort | quote}} @@ -71,3 +69,8 @@ spec: value: {{.Values.env.GOOGLE_AUTH_JSON_PATH | quote}} - name: MESSAGE_TEMPLATES_PATH value: {{.Values.env.MESSAGE_TEMPLATES_PATH | quote}} + - name: REDIS_URI + valueFrom: + secretKeyRef: + name: redis-shared + key: connection-string \ No newline at end of file diff --git a/devops/charts/controller/templates/secrets.yaml b/devops/charts/controller/templates/secrets.yaml index 8736da2..b416285 100644 --- a/devops/charts/controller/templates/secrets.yaml +++ b/devops/charts/controller/templates/secrets.yaml @@ -17,12 +17,4 @@ type: Opaque data: TRACTION_WALLET_ID: {{.Values.wallet_id | b64enc}} TRACTION_WALLET_KEY: {{.Values.wallet_key | b64enc}} ---- -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "attestation-controller.fullname" . }}-redis-creds - labels: {{- include "attestation-controller.labels" . | nindent 4}} -type: Opaque -data: - REDIS_URL: {{.Values.redis_url | b64enc}} + diff --git a/devops/charts/controller/values.yaml b/devops/charts/controller/values.yaml index cbb81ef..d3ee8a3 100644 --- a/devops/charts/controller/values.yaml +++ b/devops/charts/controller/values.yaml @@ -14,7 +14,7 @@ image: registry: ghcr.io repository: bcgov/mobile-attestation-vc-controller/controller # Overrides the image tag whose default is the chart appVersion. - tag: "fdbeea6" + tag: "90bffd6" env: TRACTION_BASE_URL: "https://traction-tenant-proxy-dev.apps.silver.devops.gov.bc.ca" diff --git a/requirements.txt b/requirements.txt index a740ee3..4a01594 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,5 @@ google-api-python-client google-auth-oauthlib google-auth gunicorn -redis \ No newline at end of file +redis +redis-py-cluster \ No newline at end of file diff --git a/src/redis_config.py b/src/redis_config.py index 9764a57..5363561 100644 --- a/src/redis_config.py +++ b/src/redis_config.py @@ -1,7 +1,9 @@ -import redis +# import redis import os +from rediscluster import RedisCluster # Get the Redis URL from environment variables -redis_url = os.getenv('REDIS_URL') +redis_uri = os.getenv("REDIS_URI") -redis_instance = redis.from_url(redis_url, decode_responses=True) +# redis_instance = redis.from_url(redis_url, decode_responses=True) +redis_instance = RedisCluster.from_url(redis_uri, decode_responses=True)