feat(redis): add own Redis chart

Replaces the Bitnami OCI chart wrapper previously used directly from
the k3s repo (apps/redis). Standalone Deployment, password auth via
existingSecret, optional persistence (defaults to emptyDir to match
current usage as an ephemeral cache/session store).
This commit is contained in:
sha
2026-08-09 16:06:55 +03:00
parent 4681e9a5b3
commit 5cb2d991d8
6 changed files with 204 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
apiVersion: v2
name: redis
description: A Helm chart for Redis
type: application
annotations:
version-source: dockerhub-tags:library/redis
version: 0.1.0
appVersion: "8.10.0"
+34
View File
@@ -0,0 +1,34 @@
{{- define "redis.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "redis.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- define "redis.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "redis.labels" -}}
helm.sh/chart: {{ include "redis.chart" . }}
{{ include "redis.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "redis.selectorLabels" -}}
app.kubernetes.io/name: {{ include "redis.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
+91
View File
@@ -0,0 +1,91 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "redis.fullname" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
annotations:
version-source: dockerhub-tags:library/redis
kustomize.toolkit.fluxcd.io/prune: disabled
spec:
replicas: {{ .Values.replicaCount }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "redis.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "redis.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: redis
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
{{- if .Values.auth.enabled }}
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.auth.existingSecret }}
key: {{ .Values.auth.passwordKey }}
command:
- sh
- -c
- 'exec redis-server --requirepass "$REDIS_PASSWORD"'
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /data
readinessProbe:
exec:
command:
- redis-cli
{{- if .Values.auth.enabled }}
- -a
- $(REDIS_PASSWORD)
- --no-auth-warning
{{- end }}
- ping
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
exec:
command:
- redis-cli
{{- if .Values.auth.enabled }}
- -a
- $(REDIS_PASSWORD)
- --no-auth-warning
{{- end }}
- ping
initialDelaySeconds: 15
periodSeconds: 10
volumes:
- name: data
{{- if .Values.persistence.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "redis.fullname" . }}-data
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
+17
View File
@@ -0,0 +1,17 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "redis.fullname" . }}-data
labels:
{{- include "redis.labels" . | nindent 4 }}
annotations:
kustomize.toolkit.fluxcd.io/prune: disabled
spec:
accessModes:
- ReadWriteOnce
storageClassName: {{ .Values.persistence.storageClass }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}
+17
View File
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "redis.fullname" . }}
labels:
{{- include "redis.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
{{- include "redis.selectorLabels" . | nindent 4 }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
{{- if and (eq .Values.service.type "NodePort") .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
+37
View File
@@ -0,0 +1,37 @@
replicaCount: 1
image:
repository: redis
pullPolicy: IfNotPresent
tag: "" # defaults to Chart.AppVersion
nameOverride: ""
fullnameOverride: ""
auth:
enabled: true
existingSecret: ""
passwordKey: REDIS_PASSWORD
persistence:
enabled: false
existingClaim: ""
storageClass: local-path
size: 1Gi
service:
type: ClusterIP
port: 6379
nodePort: ""
resources:
requests:
memory: 128Mi
cpu: 50m
limits:
memory: 256Mi
cpu: 200m
nodeSelector: {}
affinity: {}
tolerations: []