feat: redis -> valkey
All checks were successful
/ deploy (push) Successful in 24s

This commit is contained in:
ange 2024-09-27 07:54:02 +07:00
parent 79b027fe07
commit 68f44eb5e4
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
3 changed files with 18 additions and 24 deletions

2
.env
View File

@ -1,3 +1,3 @@
PROD_URL=git.gmoker.com 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 IMAGERUNNER=docker.io/gitea/act_runner:0.2.10-dind-rootless

View File

@ -19,31 +19,25 @@ function kcreatecm() {
function kgseckey() { function kgseckey() {
local sec="$1"; shift local sec="$1"; shift
local key="$1"; shift local key="$1"; shift
local ret
ret="$(kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d)" if ! kubectl get secret "$sec" -ojson | jq -re ".data.\"$key\" // empty" | base64 -d; then
if [ "$?" -ne 0 ] || [ -z "$ret" ]; then
return 1 return 1
fi fi
echo "$ret"
} }
function kgcmkey() { function kgcmkey() {
local cm="$1"; shift local cm="$1"; shift
local key="$1"; shift local key="$1"; shift
local ret;
ret="$(kubectl get configmap "$cm" -o jsonpath="{.data.$key}")" if ! kubectl get configmap "$cm" -ojson | jq -re ".data.\"$key\" // empty"; then
if [ "$?" -ne 0 ] || [ -z "$ret" ]; then
return 1 return 1
fi fi
echo "$ret"
} }
kapply common/db.yaml kapply common/db.yaml
export REDIS_HOST=redis export REDIS_HOST=valkey
export REDIS_DB=0 export REDIS_DB=0
export REDIS_PORT=6379 export REDIS_PORT=6379
export POSTGRES_HOST; POSTGRES_HOST="$(kgseckey postgres-app host)" export POSTGRES_HOST; POSTGRES_HOST="$(kgseckey postgres-app host)"
@ -60,7 +54,7 @@ kcreatesec gitea-admin \
--from-literal=username="$GITEA_USERNAME" \ --from-literal=username="$GITEA_USERNAME" \
--from-literal=password="$GITEA_PASSWORD" --from-literal=password="$GITEA_PASSWORD"
kubectl run --image "$IMAGEAPP" secrets sleep 60 kubectl run --image "$IMAGEAPP" secrets sleep 600
sleep 5 sleep 5
kcreatesec gitea \ kcreatesec gitea \
--from-literal=secret_key="$(kgseckey gitea secret_key || kubectl exec secrets -- gitea generate secret SECRET_KEY)" \ --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) --from-file=app.ini=<(envsubst "$(env | xargs printf '$%s ')" < config/app.ini)
kapply common/job.yaml \ kapply common/job.yaml \
common/redis.yaml \ common/valkey.yaml \
common/app.yaml common/app.yaml
kubectl rollout restart statefulset app kubectl rollout restart statefulset app

View File

@ -2,36 +2,36 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: redis name: valkey
labels: labels:
app: redis app: valkey
spec: spec:
selector: selector:
app: redis app: valkey
ports: ports:
- name: redis - name: valkey
port: 6379 port: 6379
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: StatefulSet kind: StatefulSet
metadata: metadata:
name: redis name: valkey
spec: spec:
selector: selector:
matchLabels: matchLabels:
app: redis app: valkey
serviceName: redis serviceName: valkey
replicas: $NB_REPLICAS replicas: $NB_REPLICAS
template: template:
metadata: metadata:
labels: labels:
app: redis app: valkey
spec: spec:
containers: containers:
- name: redis - name: valkey
image: docker.io/redis:latest image: docker.io/valkey/valkey:latest
ports: ports:
- name: redis - name: valkey
containerPort: 6379 containerPort: 6379
volumeMounts: volumeMounts:
- name: data - name: data