From 45db9539409f70835f4ce80b97f889bd80de18ee Mon Sep 17 00:00:00 2001 From: Warren Christian <70002196+warrenchristian1telus@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:17:09 -0700 Subject: [PATCH] Reduce PVC size for Redis cluster Adjust REDIS_NAME --- .env.example | 2 +- openshift/scripts/deploy-redis-sentinel.sh | 12 ++++++++++-- openshift/scripts/redis-client-increment.sh | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 1e97225b..7d8985dd 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ PHP_NAME=php DB_SERVICE=db CRON_NAME=cron WEB_NAME=web -REDIS_NAME=redis-sentinel +REDIS_NAME=redis APP_ENV=production APP_KEY=base64:**Add_app_key_here** diff --git a/openshift/scripts/deploy-redis-sentinel.sh b/openshift/scripts/deploy-redis-sentinel.sh index 8bdc6465..5d247031 100644 --- a/openshift/scripts/deploy-redis-sentinel.sh +++ b/openshift/scripts/deploy-redis-sentinel.sh @@ -12,8 +12,14 @@ global: password: "$REDIS_PASSWORD" replica: replicaCount: $REDIS_REPLICAS + persistence: + enabled: true + size: 5Gi sentinel: enabled: true + persistence: + enabled: true + size: 100Mi EOF # Check if the Helm deployment exists @@ -33,7 +39,7 @@ if helm list -q | grep -q "^$REDIS_NAME$"; then else echo "Helm $REDIS_NAME NOT FOUND. Beginning deployment..." - helm install $REDIS_NAME-sentinel $REDIS_HELM_CHART --values values.yml + helm install $REDIS_NAME $REDIS_HELM_CHART --values values.yml fi echo "Helm updates completed for $REDIS_NAME." @@ -42,8 +48,10 @@ echo "Helm updates completed for $REDIS_NAME." echo "Setting best-effort resource limits for the deployment..." oc set resources deployment/$REDIS_NAME --limits=cpu=0,memory=0 --requests=cpu=0,memory=0 + + # Clean up the temporary values file rm values.yaml -e ho "Deploying Redis Insight..." +echo "Deploying Redis Insight..." oc apply -f ./openshift/redis-insight.yml diff --git a/openshift/scripts/redis-client-increment.sh b/openshift/scripts/redis-client-increment.sh index 1df43ca8..8b3e1558 100644 --- a/openshift/scripts/redis-client-increment.sh +++ b/openshift/scripts/redis-client-increment.sh @@ -1,8 +1,9 @@ #!/bin/bash export REDISCLI_AUTH=$REDIS_PASSWORD +export REDIS_HOST=$(oc get svc redis-sentinel -o jsonpath='{.spec.clusterIP}') while true do - CURRENT_PRIMARY=$(redis-cli -h redis-sentinel -p 26379 SENTINEL get-master-addr-by-name mymaster) + CURRENT_PRIMARY=$(redis-cli -h $REDIS_HOST -p 26379 SENTINEL get-master-addr-by-name mymaster) CURRENT_PRIMARY_HOST=$(echo $CURRENT_PRIMARY | cut -d' ' -f1 | head -n 1) echo "Current master's host: $CURRENT_PRIMARY_HOST" redis-cli -h ${CURRENT_PRIMARY_HOST} -p 6379 INCR mycounter