Skip to content

Commit b2f8df9

Browse files
committed
feat(valkey): add valkey sentinel proxy
1 parent bd4a1b8 commit b2f8df9

6 files changed

Lines changed: 99 additions & 4 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
Drycc (pronounced DAY-iss) Workflow is an open source Platform as a Service (PaaS) that adds a developer-friendly layer to any [Kubernetes](http://kubernetes.io) cluster, making it easy to deploy and manage applications on your own servers.
55

6+
## Usage
7+
8+
Different components use different db, as follows:
9+
10+
* `controller` use db 0
11+
* `passport` use db 1
12+
* `fluentbit` and `logger` use db 2
13+
* `manager` use db 10
14+
* `helmbroker` use db 11
15+
16+
The above are the default configurations for each component.
17+
618
## Description
719
A Container image for running standalone (not clustered) Valkey on a Kubernetes cluster.
820

_test/test.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
VERSION="$1"
44

55
CONTAINER_NETWORK="valkey"
6+
CONTAINER_PROXY_NAME="valkey-benchmark-proxy"
67
CONTAINER_MASTER_NAME="valkey-benchmark-master"
78
CONTAINER_SLAVE1_NAME="valkey-benchmark-slave1"
89
CONTAINER_SLAVE2_NAME="valkey-benchmark-slave2"
@@ -66,8 +67,25 @@ start-valkey-slave2() {
6667
podman exec "$CONTAINER_SLAVE2_NAME" init-stack valkey-start sentinel $CONTAINER_SLAVE2_NAME &
6768
}
6869

70+
start-valkey-proxy() {
71+
podman run -d \
72+
--rm \
73+
--network "$CONTAINER_NETWORK" \
74+
--ip 192.168.253.13 \
75+
--add-host="$CONTAINER_MASTER_NAME:192.168.253.10" \
76+
--add-host="$CONTAINER_SLAVE1_NAME:192.168.253.11" \
77+
--add-host="$CONTAINER_SLAVE2_NAME:192.168.253.12" \
78+
--env "REDISCLI_AUTH=$DRYCC_VALKEY_PASSWORD" \
79+
--env "DRYCC_VALKEY_SENTINEL=$DRYCC_VALKEY_SENTINEL" \
80+
--env "DRYCC_VALKEY_PASSWORD=$DRYCC_VALKEY_PASSWORD" \
81+
--name "$CONTAINER_PROXY_NAME" \
82+
"registry.drycc.cc/drycc/valkey:$VERSION" \
83+
valkey-start proxy
84+
}
85+
6986
clean-valkey() {
7087
{
88+
podman stop -i "$CONTAINER_PROXY_NAME"
7189
podman stop -i "$CONTAINER_SLAVE1_NAME"
7290
podman stop -i "$CONTAINER_SLAVE2_NAME"
7391
podman stop -i "$CONTAINER_MASTER_NAME"
@@ -80,8 +98,12 @@ podman network create --subnet=192.168.253.0/24 "$CONTAINER_NETWORK"
8098
start-valkey-master
8199
start-valkey-slave1
82100
start-valkey-slave2
101+
start-valkey-proxy
102+
103+
echo "run valkey proxy benchmark..."
104+
podman exec "$CONTAINER_PROXY_NAME" init-stack valkey-benchmark -p 16379 -a $DRYCC_VALKEY_PASSWORD
83105

84-
echo "run valkey benchmark..."
106+
echo "run valkey master benchmark..."
85107
podman exec "$CONTAINER_MASTER_NAME" init-stack valkey-benchmark -a $DRYCC_VALKEY_PASSWORD
86108

87109
echo "check slave all keys..."

charts/valkey/templates/valkey-statefulset.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,51 @@ spec:
2323
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset.type "component" "" "extraMatchLabels" .Values.podAntiAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}
2424
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values ) | nindent 10 }}
2525
containers:
26+
- name: proxy
27+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/valkey:{{ .Values.imageTag }}
28+
imagePullPolicy: {{ .Values.imagePullPolicy }}
29+
{{- if .Values.diagnosticMode.enabled }}
30+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 10 }}
31+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 10 }}
32+
{{- else }}
33+
args:
34+
- valkey-start
35+
- proxy
36+
{{- end }}
37+
env:
38+
- name: DRYCC_VALKEY_PASSWORD
39+
valueFrom:
40+
secretKeyRef:
41+
name: valkey-creds
42+
key: password
43+
- name: DRYCC_VALKEY_SENTINEL
44+
value: {{ printf "drycc-valkey.%s.svc.%s" $.Release.Namespace $.Values.global.clusterDomain }}
45+
ports:
46+
- containerPort: 16379
47+
startupProbe:
48+
initialDelaySeconds: 10
49+
periodSeconds: 10
50+
timeoutSeconds: 5
51+
successThreshold: 1
52+
failureThreshold: 22
53+
tcpSocket:
54+
port: 16379
55+
livenessProbe:
56+
initialDelaySeconds: 20
57+
periodSeconds: 5
58+
timeoutSeconds: 5
59+
successThreshold: 1
60+
failureThreshold: 5
61+
tcpSocket:
62+
port: 16379
63+
readinessProbe:
64+
initialDelaySeconds: 20
65+
periodSeconds: 5
66+
timeoutSeconds: 1
67+
successThreshold: 1
68+
failureThreshold: 5
69+
tcpSocket:
70+
port: 16379
2671
- name: server
2772
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/valkey:{{ .Values.imageTag }}
2873
imagePullPolicy: {{ .Values.imagePullPolicy }}

charts/valkey/templates/valkey-svc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ spec:
1313
clusterIP: None
1414
publishNotReadyAddresses: true
1515
ports:
16+
- name: proxy
17+
port: 16379
18+
targetPort: 16379
19+
protocol: TCP
1620
- name: server
1721
port: 6379
1822
targetPort: 6379

rootfs/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ FROM registry.drycc.cc/drycc/base:${CODENAME}
44
ENV DRYCC_UID=1001 \
55
DRYCC_GID=1001 \
66
DRYCC_HOME_DIR=/data \
7-
VALKEY_VERSION="8.0.1"
7+
VALKEY_VERSION="8.0.1" \
8+
VALKEY_SENTINEL_PROXY_VERSION="1.0.1"
89

910
RUN groupadd drycc --gid ${DRYCC_GID} \
1011
&& useradd drycc -u ${DRYCC_UID} -g ${DRYCC_GID} -s /bin/bash -m -d ${DRYCC_HOME_DIR}
@@ -14,6 +15,7 @@ COPY etc/valkey /etc/valkey
1415
COPY bin/valkey-start /bin/valkey-start
1516

1617
RUN install-stack valkey ${VALKEY_VERSION} \
18+
&& install-stack valkey-sentinel-proxy ${VALKEY_SENTINEL_PROXY_VERSION} \
1719
&& rm -rf \
1820
/usr/share/doc \
1921
/usr/share/man \

rootfs/bin/valkey-start

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
print_usage() {
77
echo "Valid commands for valkey-start:"
88
echo ""
9+
echo "proxy <announce-host> start valkey proxy"
910
echo "server <announce-host> start valkey server"
1011
echo "sentinel <announce-host> start valkey sentinel"
1112
echo ""
12-
echo "Such as 'weed-start server valkey.valkey.svc.cluster.local' to start valkey server."
13+
echo "Such as 'valkey-start server valkey.valkey.svc.cluster.local' to start valkey server."
1314
}
1415

1516
remove_in_file() {
@@ -24,6 +25,15 @@ get_master_info() {
2425
eval "$command"
2526
}
2627

28+
start_valkey_proxy() {
29+
exec valkey-sentinel-proxy \
30+
--listen=:16379 \
31+
--master=drycc \
32+
--max-procs=4 \
33+
--sentinel-addr="${DRYCC_VALKEY_SENTINEL}":26379 \
34+
--sentinel-pass="${DRYCC_VALKEY_PASSWORD}"
35+
}
36+
2737
start_valkey_server() {
2838
announce_ip="$1"
2939
VALKEY_CONFIG_FILE=/data/server/valkey.conf
@@ -92,7 +102,7 @@ start_valkey_sentinel() {
92102
}
93103

94104
command="$1"
95-
if [[ ${command} == "server" || ${command} == "sentinel" ]]; then
105+
if [[ ${command} == "proxy" || ${command} == "server" || ${command} == "sentinel" ]]; then
96106
"start_valkey_$command" "$2"
97107
else
98108
print_usage

0 commit comments

Comments
 (0)