try chatgpt provided chart for redis/keyDB
This commit is contained in:
@@ -1,35 +1,17 @@
|
|||||||
|
# Chart: keydb-custom
|
||||||
|
# Helm chart tailored for KeyDB (EqAlpha) on 2 Raspberry Pi 5 nodes
|
||||||
|
# - Mode: master (statefulset index 0) + replica (index 1)
|
||||||
|
# - Replica runs as replicaof master at startup
|
||||||
|
# - server-threads = 4
|
||||||
|
# - Config mounted via ConfigMap
|
||||||
|
# - Liveness / readiness probes included
|
||||||
|
# - Persistence via PersistentVolumeClaim (storageClass configurable)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Chart.yaml
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: redis
|
name: keydb-custom # https://chatgpt.com/c/69315a7d-cb88-832c-bc18-3be2b519356d
|
||||||
description: A Helm chart for Kubernetes
|
description: "Custom KeyDB Helm chart for 2-node Master+Replica on Raspberry Pi 5"
|
||||||
|
|
||||||
dependencies:
|
|
||||||
- name: tool
|
|
||||||
version: 0.1.0
|
|
||||||
repository: https://gitea.arcodange.duckdns.org/api/packages/arcodange-org/helm
|
|
||||||
- name: keydb
|
|
||||||
version: 0.5.22
|
|
||||||
repository: https://charts.bitnami.com/bitnami
|
|
||||||
# - name: redis
|
|
||||||
# version: 24.0.0
|
|
||||||
# repository: https://charts.bitnami.com/bitnami
|
|
||||||
|
|
||||||
# A chart can be either an 'application' or a 'library' chart.
|
|
||||||
#
|
|
||||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
|
||||||
# to be deployed.
|
|
||||||
#
|
|
||||||
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
|
||||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
|
||||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
|
||||||
type: application
|
type: application
|
||||||
|
|
||||||
# This is the chart version. This version number should be incremented each time you make changes
|
|
||||||
# to the chart and its templates, including the app version.
|
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
|
appVersion: "latest"
|
||||||
# This is the version number of the application being deployed. This version number should be
|
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
|
||||||
# It is recommended to use it with quotes.
|
|
||||||
# appVersion: "1.16.0"
|
|
||||||
12
redis/templates/NOTES.txt
Normal file
12
redis/templates/NOTES.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/NOTES.txt
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
1. Get the application URL by running these commands:
|
||||||
|
export POD0=$(kubectl get pods -l app={{ include "keydb-custom.name" . }} -o jsonpath="{.items[0].metadata.name}")
|
||||||
|
kubectl logs $POD0
|
||||||
|
|
||||||
|
2. To connect via keydb-cli from a pod:
|
||||||
|
kubectl run -it --rm --image=eqalpha/keydb --restart=Never keydb-client -- /bin/sh
|
||||||
|
# inside the pod:
|
||||||
|
keydb-cli -h {{ include "keydb-custom.fullname" . }}-0.{{ include "keydb-custom.fullname" . }}-headless -a "{{ .Values.auth.password }}" PING
|
||||||
11
redis/templates/_helpers.tpl
Normal file
11
redis/templates/_helpers.tpl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/_helpers.tpl
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
{{- define "keydb-custom.name" -}}
|
||||||
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "keydb-custom.fullname" -}}
|
||||||
|
{{- printf "%s" (include "keydb-custom.name" .) -}}
|
||||||
|
{{- end -}}
|
||||||
21
redis/templates/configmap.yaml
Normal file
21
redis/templates/configmap.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/configmap.yaml
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: '{{ include "keydb-custom.fullname" . }}-conf'
|
||||||
|
labels:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
data:
|
||||||
|
keydb.conf: |
|
||||||
|
# Minimal keydb.conf generated from values
|
||||||
|
server-threads {{ .Values.keydb.serverThreads }}
|
||||||
|
maxmemory {{ .Values.keydb.maxmemory }}
|
||||||
|
maxmemory-policy {{ .Values.keydb.maxmemoryPolicy }}
|
||||||
|
appendonly {{ .Values.keydb.appendonly }}
|
||||||
|
protected-mode no
|
||||||
|
bind 0.0.0.0
|
||||||
|
port {{ .Values.service.port }}
|
||||||
|
# requirepass is handled via env (not in file)
|
||||||
17
redis/templates/headless-svc.yaml
Normal file
17
redis/templates/headless-svc.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/headless-svc.yaml
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: '{{ include "keydb-custom.fullname" . }}-headless'
|
||||||
|
labels:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
selector:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
name: keydb
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{{- if eq .Values.tool.kind "HelmChart" -}}
|
|
||||||
{{- include "tool.helm-chart-config.tpl" . -}}
|
|
||||||
{{- end -}}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{{- if eq .Values.tool.kind "HelmChart" -}}
|
|
||||||
{{- include "tool.helm-chart.tpl" . -}}
|
|
||||||
{{- end -}}
|
|
||||||
11
redis/templates/secret-auth.yaml
Normal file
11
redis/templates/secret-auth.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/secret-auth.yaml
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: '{{ include "keydb-custom.fullname" . }}-auth'
|
||||||
|
type: Opaque
|
||||||
|
stringData:
|
||||||
|
password: "{{ .Values.auth.password }}"
|
||||||
135
redis/templates/statefulset.yaml
Normal file
135
redis/templates/statefulset.yaml
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# templates/statefulset.yaml
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
{{""}}
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: {{ include "keydb-custom.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
spec:
|
||||||
|
serviceName: {{ include "keydb-custom.fullname" . }}-headless
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ include "keydb-custom.name" . }}
|
||||||
|
spec:
|
||||||
|
{{- if .Values.nodeAffinity }}
|
||||||
|
affinity:
|
||||||
|
nodeAffinity: {{ toYaml .Values.nodeAffinity | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.podAntiAffinity.enabled }}
|
||||||
|
affinity:
|
||||||
|
podAntiAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: "app"
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- {{ include "keydb-custom.name" . }}
|
||||||
|
topologyKey: "kubernetes.io/hostname"
|
||||||
|
{{- end }}
|
||||||
|
containers:
|
||||||
|
- name: keydb
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- name: keydb
|
||||||
|
containerPort: {{ .Values.service.port }}
|
||||||
|
env:
|
||||||
|
- name: KEYDB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "keydb-custom.fullname" . }}-auth
|
||||||
|
key: password
|
||||||
|
- name: KEYDB_CONF_FILE
|
||||||
|
value: "/etc/keydb/keydb.conf"
|
||||||
|
volumeMounts:
|
||||||
|
- name: keydb-conf
|
||||||
|
mountPath: /etc/keydb
|
||||||
|
- name: data
|
||||||
|
mountPath: /bitnami/keydb
|
||||||
|
resources:
|
||||||
|
{{ toYaml .Values.resources | nindent 12 }}
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
# Startup logic:
|
||||||
|
# - pod index 0 starts as master
|
||||||
|
# - pod index >0 will start and then configure REPLICAOF to master
|
||||||
|
POD_NAME=$(hostname)
|
||||||
|
# derive ordinal from pods named <release>-<ordinal>
|
||||||
|
ORDINAL=${POD_NAME##*-}
|
||||||
|
# start keydb-server in background to accept CONFIG/CLI commands
|
||||||
|
keydb-server /etc/keydb/keydb.conf &
|
||||||
|
sleep 1
|
||||||
|
if [ "${ORDINAL}" != "0" ]; then
|
||||||
|
# wait for master to be ready
|
||||||
|
MASTER_HOST={{ include "keydb-custom.fullname" . }}-0.{{ include "keydb-custom.fullname" . }}-headless
|
||||||
|
until nc -z ${MASTER_HOST} {{ .Values.service.port }}; do sleep 1; done
|
||||||
|
# configure replication (use CLI to set replicaof)
|
||||||
|
if [ -n "$KEYDB_PASSWORD" ]; then
|
||||||
|
keydb-cli -a "$KEYDB_PASSWORD" REPLICAOF ${MASTER_HOST} {{ .Values.service.port }}
|
||||||
|
else
|
||||||
|
keydb-cli REPLICAOF ${MASTER_HOST} {{ .Values.service.port }}
|
||||||
|
fi
|
||||||
|
echo "Configured replicaof ${MASTER_HOST}:{{ .Values.service.port }}"
|
||||||
|
# tail logs (block) to keep container running
|
||||||
|
wait
|
||||||
|
else
|
||||||
|
# master: block on server process
|
||||||
|
wait
|
||||||
|
fi
|
||||||
|
readinessProbe:
|
||||||
|
{{- if .Values.readinessProbe.enabled }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
# quick PING check
|
||||||
|
if [ -n "$KEYDB_PASSWORD" ]; then
|
||||||
|
keydb-cli -a "$KEYDB_PASSWORD" PING > /dev/null 2>&1 && exit 0 || exit 1
|
||||||
|
else
|
||||||
|
keydb-cli PING > /dev/null 2>&1 && exit 0 || exit 1
|
||||||
|
fi
|
||||||
|
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
livenessProbe:
|
||||||
|
{{- if .Values.livenessProbe.enabled }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [ -n "$KEYDB_PASSWORD" ]; then
|
||||||
|
keydb-cli -a "$KEYDB_PASSWORD" PING > /dev/null 2>&1 && exit 0 || exit 1
|
||||||
|
else
|
||||||
|
keydb-cli PING > /dev/null 2>&1 && exit 0 || exit 1
|
||||||
|
fi
|
||||||
|
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
volumes:
|
||||||
|
- name: keydb-conf
|
||||||
|
configMap:
|
||||||
|
name: {{ include "keydb-custom.fullname" . }}-conf
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: data
|
||||||
|
spec:
|
||||||
|
accessModes: {{ toYaml .Values.persistence.accessModes | nindent 8 }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.persistence.size }}
|
||||||
|
storageClassName: "{{ .Values.persistence.storageClass }}"
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
redis: &redis_config
|
|
||||||
architecture: replication
|
|
||||||
global:
|
|
||||||
defaultStorageClass: local-path
|
|
||||||
sentinel:
|
|
||||||
enabled: true
|
|
||||||
master:
|
|
||||||
resourcesPreset: &resources small
|
|
||||||
replica:
|
|
||||||
resourcesPreset: *resources
|
|
||||||
|
|
||||||
tool:
|
|
||||||
# kind: 'SubChart' or 'HelmChart', if subchart then uncomment Chart.yaml dependency, else comment and use tool library with helm chart template
|
|
||||||
kind: 'SubChart'
|
|
||||||
repo: https://charts.bitnami.com/bitnami
|
|
||||||
chart: redis
|
|
||||||
version: 24.0.0
|
|
||||||
values: *redis_config
|
|
||||||
@@ -1,26 +1,59 @@
|
|||||||
keydb: &keydb_config
|
# -----------------------------------------------------------------------------
|
||||||
image:
|
# values.yaml
|
||||||
registry: docker.io
|
# -----------------------------------------------------------------------------
|
||||||
repository: eqalpha/keydb # Remplace l'image Redis par KeyDB
|
# Default values - adjust to your environment
|
||||||
|
replicaCount: 2
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: eqalpha/keydb
|
||||||
tag: latest
|
tag: latest
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
global:
|
|
||||||
defaultStorageClass: local-path
|
|
||||||
security:
|
|
||||||
allowInsecureImages: true
|
|
||||||
architecture: replication
|
|
||||||
auth:
|
|
||||||
password: redisarcodange
|
|
||||||
master:
|
|
||||||
resourcesPreset: &resources small
|
|
||||||
replica:
|
|
||||||
activeReplica: true
|
|
||||||
resourcesPreset: *resources
|
|
||||||
|
|
||||||
tool:
|
service:
|
||||||
# kind: 'SubChart' or 'HelmChart', if subchart then uncomment Chart.yaml dependency, else comment and use tool library with helm chart template
|
port: 6379
|
||||||
kind: 'SubChart'
|
headless: true
|
||||||
repo: https://charts.bitnami.com/bitnami
|
|
||||||
chart: keydb
|
auth:
|
||||||
version: 0.5.22
|
enabled: true
|
||||||
values: *keydb_config
|
password: "redisarcodange"
|
||||||
|
|
||||||
|
keydb:
|
||||||
|
serverThreads: 4
|
||||||
|
maxmemory: "70%"
|
||||||
|
maxmemoryPolicy: "allkeys-lru"
|
||||||
|
appendonly: "no"
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
size: 1Gi
|
||||||
|
storageClass: "local-storage" # set to your storageClass: longhorn, local-path, etc.
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: "300m"
|
||||||
|
memory: "512Mi"
|
||||||
|
limits:
|
||||||
|
cpu: "1200m"
|
||||||
|
memory: "1Gi"
|
||||||
|
|
||||||
|
nodeAffinity: {}
|
||||||
|
|
||||||
|
podAntiAffinity:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
securityContext:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
livenessProbe:
|
||||||
|
enabled: true
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 5
|
||||||
|
|
||||||
|
readinessProbe:
|
||||||
|
enabled: true
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
timeoutSeconds: 2
|
||||||
Reference in New Issue
Block a user