Skip to content

Commit

Permalink
Replaced REDIS_IMAGE with REDIS_HELM_CHART
Browse files Browse the repository at this point in the history
Add helm test to deploy-redis-sentinel.sh
  • Loading branch information
warrenchristian1telus committed Oct 18, 2024
1 parent 942954f commit c998f8d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PHP_NAME=php
DB_SERVICE=db
CRON_NAME=cron
WEB_NAME=web
REDIS_NAME=redis
REDIS_NAME=redis-sentinel

APP_ENV=production
APP_KEY=base64:**Add_app_key_here**
Expand Down Expand Up @@ -77,9 +77,8 @@ MEMCACHED_HOST=127.0.0.1

REDIS_REDIS_HOST_IP=127.0.0.1 # For Redis Sentinel to connect to Redis
REDIS_REPO=oci://registry-1.docker.io/
REDIS_NAME=redis
REDIS_REPLICAS=3
REDIS_HOST=redis
REDIS_HOST=redis-sentinel
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_DATABASE=0
Expand Down
3 changes: 2 additions & 1 deletion .env.example.versions
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ DB_IMAGE=mariadb:10
WEB_IMAGE=nginxinc/nginx-unprivileged:1.25.4-alpine-slim
BACKUP_HELM_CHART=bcgov/backup-storage
BACKUP_IMAGE=bcgovimages/backup-container-mariadb:latest
REDIS_IMAGE=redis:7.2.5
# REDIS_IMAGE=redis:7.2.5 # deprecated for helm chart use
REDIS_HELM_CHART=bitnami/redis
MEMCACHED_IMAGE=memcached:1.6.9

# PHP extensions
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
PHP_NAME: ${{ env.PHP_NAME }}
CRON_NAME: ${{ env.CRON_NAME }}
CRON_IMAGE: ${{ env.CRON_IMAGE}}
REDIS_IMAGE: ${{ env.REDIS_IMAGE }}
REDIS_HELM_CHART: ${{ env.REDIS_HELM_CHART }}
REDIS_NAME: ${{ env.REDIS_NAME }}
REDIS_REPLICAS: ${{ env.REDIS_REPLICAS }}
DB_INIT_FILE_LOCATION: ${{ env.DB_INIT_FILE_LOCATION }}
Expand Down Expand Up @@ -255,7 +255,7 @@ jobs:
BACKUP_HELM_CHART: ${{ needs.checkEnv.outputs.BACKUP_HELM_CHART }}
CRON_IMAGE: ${{ needs.checkEnv.outputs.CRON_IMAGE }}
CRON_NAME: ${{ needs.checkEnv.outputs.CRON_NAME }}
REDIS_IMAGE: ${{ needs.checkEnv.outputs.REDIS_IMAGE }}
REDIS_HELM_CHART: ${{ needs.checkEnv.outputs.REDIS_HELM_CHART }}
REDIS_NAME: ${{ needs.checkEnv.outputs.REDIS_NAME }}
REDIS_REPLICAS: ${{ needs.checkEnv.outputs.REDIS_REPLICAS }}
BUILD_NAMESPACE: ${{ needs.checkEnv.outputs.BUILD_NAMESPACE }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
if: success()
run: bash ./openshift/scripts/deploy-redis-sentinel.sh
env:
REDIS_IMAGE: ${{ inputs.REDIS_IMAGE }}
REDIS_HELM_CHART: ${{ inputs.REDIS_HELM_CHART }}
DEPLOY_NAMESPACE: ${{ inputs.DEPLOY_NAMESPACE }}
REDIS_NAME: ${{ inputs.REDIS_NAME }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
Expand Down
31 changes: 30 additions & 1 deletion openshift/scripts/deploy-redis-sentinel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ oc project $OC_PROJECT

helm repo add bitnami https://charts.bitnami.com/bitnami

# Create a temporary values file
cat > values.yml<<EOF
global:
redis:
Expand All @@ -15,6 +16,34 @@ sentinel:
enabled: true
EOF

helm install $REDIS_NAME-sentinel bitnami/redis --values values.yml
# Check if the Helm deployment exists
if helm list -q | grep -q "^$REDIS_NAME$"; then
echo "Helm deployment found. Updating..."

# Upgrade the Helm deployment with the new values
if [[ `helm upgrade $REDIS_NAME $REDIS_HELM_CHART --reuse-values -f values.yml 2>&1` =~ "Error" ]]; then
echo "❌ Helm upgrade FAILED."
exit 1
fi

if [[ `oc describe deployment $REDIS_NAME 2>&1` =~ "NotFound" ]]; then
echo "Helm deployment ($REDIS_NAME) exists, but NOT FOUND."
exit 1
fi
else
echo "Helm $REDIS_NAME NOT FOUND. Beginning deployment..."

helm install $REDIS_NAME-sentinel $REDIS_HELM_CHART --values values.yml

# Set best-effort resource limits for the deployment
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
fi

echo "Helm updates completed for $REDIS_NAME."

# Clean up the temporary values file
rm values.yaml

e ho "Deploying Redis Insight..."
oc apply -f ./openshift/redis-insight.yml

0 comments on commit c998f8d

Please sign in to comment.