Skip to content

Commit

Permalink
Merge pull request #7 from tegridy-io/feat/refine-redis
Browse files Browse the repository at this point in the history
Support redis for file locking
  • Loading branch information
DebakelOrakel authored Jan 31, 2024
2 parents d6bd7af + 674e677 commit e5c6968
Show file tree
Hide file tree
Showing 29 changed files with 1,652 additions and 13 deletions.
27 changes: 19 additions & 8 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ parameters:
redis:
'True':
- name: REDIS_HOST
value: redis-headless
value: redis-master
- name: REDIS_HOST_PORT
value: '26379'
value: '6379'
- name: REDIS_HOST_PASSWORD
valueFrom:
secretKeyRef:
name: redis
name: nextcloud
key: redis-password
'False': []
standalone:
sentinel: false
pdb: false
replication:
sentinel: true
pdb: true

namespace:
annotations: {}
Expand Down Expand Up @@ -85,10 +91,10 @@ parameters:
size: 5Gi

redis:
enabled: false
mode: replication
enabled: true
mode: standalone
persistence:
enabled: false
enabled: true
accessMode: ReadWriteOnce
storageClass: ''
size: 1Gi
Expand Down Expand Up @@ -140,23 +146,28 @@ parameters:
requests: {}
persistence:
enabled: ${nextcloud:redis:persistence:enabled}
accessMode: ${nextcloud:redis:persistence:accessMode}
size: ${nextcloud:redis:persistence:size}
serviceAccount:
create: false
replica:
resources:
limits: {}
requests: {}
persistence:
enabled: ${nextcloud:redis:persistence:enabled}
accessMode: ${nextcloud:redis:persistence:accessMode}
size: ${nextcloud:redis:persistence:size}
podAntiAffinityPreset: hard
sentinel:
enabled: true
enabled: ${nextcloud:_config:redis:${nextcloud:redis:mode}:sentinel}
resources:
limits: {}
requests: {}
persistence:
enabled: ${nextcloud:redis:persistence:enabled}
pdb:
create: true
create: ${nextcloud:_config:redis:${nextcloud:redis:mode}:pdb}
minAvailable: ""
maxUnavailable: 1
tls:
Expand Down
9 changes: 5 additions & 4 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ default::
+
[source,yaml]
----
enabled: false <1>
mode: replication <2>
enabled: true <1>
mode: standalone <2>
persistence: <3>
enabled: false
enabled: true
accessMode: ReadWriteOnce
storageClass: ''
size: 1Gi
----
<1> Enable redis for file locking.
<2> Configure reis mode.
<2> Configure redis mode.
<3> Configure persistence for redis.

NOTE: Currently only standalone mode supported!

== `helmValues`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ spec:
value: nextcloud.local
- name: NEXTCLOUD_DATA_DIR
value: /var/www/html/data
- name: REDIS_HOST
value: redis-master
- name: REDIS_HOST_PORT
value: '6379'
- name: REDIS_HOST_PASSWORD
valueFrom:
secretKeyRef:
key: redis-password
name: nextcloud
image: nextcloud:28.0.1-fpm-alpine
imagePullPolicy: IfNotPresent
name: nextcloud
Expand Down Expand Up @@ -198,6 +207,15 @@ spec:
value: nextcloud.local
- name: NEXTCLOUD_DATA_DIR
value: /var/www/html/data
- name: REDIS_HOST
value: redis-master
- name: REDIS_HOST_PORT
value: '6379'
- name: REDIS_HOST_PASSWORD
valueFrom:
secretKeyRef:
key: redis-password
name: nextcloud
image: nextcloud:28.0.1-fpm-alpine
imagePullPolicy: IfNotPresent
name: nextcloud-cron
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
data:
master.conf: |-
dir /data
# User-supplied master configuration:
rename-command FLUSHDB ""
rename-command FLUSHALL ""
# End of master configuration
redis.conf: |-
# User-supplied common configuration:
# Enable AOF https://redis.io/topics/persistence#append-only-file
appendonly yes
# Disable RDB persistence, AOF persistence already enabled.
save ""
# End of common configuration
replica.conf: |-
dir /data
# User-supplied replica configuration:
rename-command FLUSHDB ""
rename-command FLUSHALL ""
# End of replica configuration
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: redis
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: redis
app.kubernetes.io/version: 7.2.4
helm.sh/chart: redis-18.9.0
name: redis-configuration
namespace: app-defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
annotations: null
labels:
app.kubernetes.io/instance: redis
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: redis
app.kubernetes.io/version: 7.2.4
helm.sh/chart: redis-18.9.0
name: redis-headless
namespace: app-defaults
spec:
clusterIP: None
ports:
- name: tcp-redis
port: 6379
targetPort: redis
selector:
app.kubernetes.io/instance: redis
app.kubernetes.io/name: redis
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: v1
data:
ping_liveness_local.sh: |-
#!/bin/bash
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
response=$(
timeout -s 15 $1 \
redis-cli \
-h localhost \
-p $REDIS_PORT \
ping
)
if [ "$?" -eq "124" ]; then
echo "Timed out"
exit 1
fi
responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ] && [ "$responseFirstWord" != "MASTERDOWN" ]; then
echo "$response"
exit 1
fi
ping_liveness_local_and_master.sh: |-
script_dir="$(dirname "$0")"
exit_status=0
"$script_dir/ping_liveness_local.sh" $1 || exit_status=$?
"$script_dir/ping_liveness_master.sh" $1 || exit_status=$?
exit $exit_status
ping_liveness_master.sh: |-
#!/bin/bash
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
response=$(
timeout -s 15 $1 \
redis-cli \
-h $REDIS_MASTER_HOST \
-p $REDIS_MASTER_PORT_NUMBER \
ping
)
if [ "$?" -eq "124" ]; then
echo "Timed out"
exit 1
fi
responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ]; then
echo "$response"
exit 1
fi
ping_readiness_local.sh: |-
#!/bin/bash
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
response=$(
timeout -s 15 $1 \
redis-cli \
-h localhost \
-p $REDIS_PORT \
ping
)
if [ "$?" -eq "124" ]; then
echo "Timed out"
exit 1
fi
if [ "$response" != "PONG" ]; then
echo "$response"
exit 1
fi
ping_readiness_local_and_master.sh: |-
script_dir="$(dirname "$0")"
exit_status=0
"$script_dir/ping_readiness_local.sh" $1 || exit_status=$?
"$script_dir/ping_readiness_master.sh" $1 || exit_status=$?
exit $exit_status
ping_readiness_master.sh: |-
#!/bin/bash
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
response=$(
timeout -s 15 $1 \
redis-cli \
-h $REDIS_MASTER_HOST \
-p $REDIS_MASTER_PORT_NUMBER \
ping
)
if [ "$?" -eq "124" ]; then
echo "Timed out"
exit 1
fi
if [ "$response" != "PONG" ]; then
echo "$response"
exit 1
fi
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: redis
app.kubernetes.io/managed-by: commodore
app.kubernetes.io/name: redis
app.kubernetes.io/version: 7.2.4
helm.sh/chart: redis-18.9.0
name: redis-health
namespace: app-defaults
Loading

0 comments on commit e5c6968

Please sign in to comment.