diff --git a/redis/Chart.yaml b/redis/Chart.yaml new file mode 100644 index 0000000..2a91fa4 --- /dev/null +++ b/redis/Chart.yaml @@ -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" diff --git a/redis/templates/_helpers.tpl b/redis/templates/_helpers.tpl new file mode 100644 index 0000000..5cf1451 --- /dev/null +++ b/redis/templates/_helpers.tpl @@ -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 }} diff --git a/redis/templates/deployment.yaml b/redis/templates/deployment.yaml new file mode 100644 index 0000000..0ee0eee --- /dev/null +++ b/redis/templates/deployment.yaml @@ -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 }} diff --git a/redis/templates/pvc.yaml b/redis/templates/pvc.yaml new file mode 100644 index 0000000..36ae43b --- /dev/null +++ b/redis/templates/pvc.yaml @@ -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 }} diff --git a/redis/templates/service.yaml b/redis/templates/service.yaml new file mode 100644 index 0000000..ae83081 --- /dev/null +++ b/redis/templates/service.yaml @@ -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 }} diff --git a/redis/values.yaml b/redis/values.yaml new file mode 100644 index 0000000..2a92b61 --- /dev/null +++ b/redis/values.yaml @@ -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: []