From 68f44eb5e44bf8db9513441a973ce0f7c36241c9 Mon Sep 17 00:00:00 2001 From: ange Date: Fri, 27 Sep 2024 07:54:02 +0700 Subject: [PATCH] feat: redis -> valkey --- .env | 2 +- manifests/bin/deploy.sh | 18 ++++++---------- manifests/common/{redis.yaml => valkey.yaml} | 22 ++++++++++---------- 3 files changed, 18 insertions(+), 24 deletions(-) rename manifests/common/{redis.yaml => valkey.yaml} (66%) diff --git a/.env b/.env index 685ef78..15501e1 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ PROD_URL=git.gmoker.com -IMAGEAPP=docker.io/gitea/gitea:1.22.0-rootless +IMAGEAPP=docker.io/gitea/gitea:1.22.2-rootless IMAGERUNNER=docker.io/gitea/act_runner:0.2.10-dind-rootless diff --git a/manifests/bin/deploy.sh b/manifests/bin/deploy.sh index dd36979..8753e74 100755 --- a/manifests/bin/deploy.sh +++ b/manifests/bin/deploy.sh @@ -19,31 +19,25 @@ function kcreatecm() { function kgseckey() { local sec="$1"; shift local key="$1"; shift - local ret - ret="$(kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d)" - if [ "$?" -ne 0 ] || [ -z "$ret" ]; then + if ! kubectl get secret "$sec" -ojson | jq -re ".data.\"$key\" // empty" | base64 -d; then return 1 fi - echo "$ret" } function kgcmkey() { - local cm="$1"; shift + local cm="$1"; shift local key="$1"; shift - local ret; - ret="$(kubectl get configmap "$cm" -o jsonpath="{.data.$key}")" - if [ "$?" -ne 0 ] || [ -z "$ret" ]; then + if ! kubectl get configmap "$cm" -ojson | jq -re ".data.\"$key\" // empty"; then return 1 fi - echo "$ret" } kapply common/db.yaml -export REDIS_HOST=redis +export REDIS_HOST=valkey export REDIS_DB=0 export REDIS_PORT=6379 export POSTGRES_HOST; POSTGRES_HOST="$(kgseckey postgres-app host)" @@ -60,7 +54,7 @@ kcreatesec gitea-admin \ --from-literal=username="$GITEA_USERNAME" \ --from-literal=password="$GITEA_PASSWORD" -kubectl run --image "$IMAGEAPP" secrets sleep 60 +kubectl run --image "$IMAGEAPP" secrets sleep 600 sleep 5 kcreatesec gitea \ --from-literal=secret_key="$(kgseckey gitea secret_key || kubectl exec secrets -- gitea generate secret SECRET_KEY)" \ @@ -72,7 +66,7 @@ kcreatecm gitea \ --from-file=app.ini=<(envsubst "$(env | xargs printf '$%s ')" < config/app.ini) kapply common/job.yaml \ - common/redis.yaml \ + common/valkey.yaml \ common/app.yaml kubectl rollout restart statefulset app diff --git a/manifests/common/redis.yaml b/manifests/common/valkey.yaml similarity index 66% rename from manifests/common/redis.yaml rename to manifests/common/valkey.yaml index 485d2a8..4df2c6d 100644 --- a/manifests/common/redis.yaml +++ b/manifests/common/valkey.yaml @@ -2,36 +2,36 @@ apiVersion: v1 kind: Service metadata: - name: redis + name: valkey labels: - app: redis + app: valkey spec: selector: - app: redis + app: valkey ports: - - name: redis + - name: valkey port: 6379 --- apiVersion: apps/v1 kind: StatefulSet metadata: - name: redis + name: valkey spec: selector: matchLabels: - app: redis - serviceName: redis + app: valkey + serviceName: valkey replicas: $NB_REPLICAS template: metadata: labels: - app: redis + app: valkey spec: containers: - - name: redis - image: docker.io/redis:latest + - name: valkey + image: docker.io/valkey/valkey:latest ports: - - name: redis + - name: valkey containerPort: 6379 volumeMounts: - name: data