diff --git a/charts/redis/Chart.yaml b/charts/redis/Chart.yaml index c5ff56e61aa4ed24b9ca3b6d2b911bfb19af046a..e8871d3c1d2244b271f010a41ef2f37fec920eb4 100644 --- a/charts/redis/Chart.yaml +++ b/charts/redis/Chart.yaml @@ -8,7 +8,7 @@ maintainers: - name: groundhog2k # This is the chart version -version: "0.6.5" +version: "0.6.6" # This is the version number of the application being deployed. appVersion: "7.0.10" diff --git a/charts/redis/README.md b/charts/redis/README.md index 1da1cdbab35dc7eded5d03fa5d33938ba6286a22..1c1cabfc0850dd11e20e615bb81bdc2a551222ff 100644 --- a/charts/redis/README.md +++ b/charts/redis/README.md @@ -1,6 +1,6 @@ # Redis -   +   ## Changelog @@ -142,6 +142,7 @@ helm uninstall my-release | storage.persistentVolumeClaimName | string | `nil` | PVC name when existing storage volume should be used | | storage.requestedSize | string | `nil` | Size for new PVC, when no existing PVC is used | | storage.className | string | `nil` | Storage class name | +| storage.keepPvc | bool | `false` | Keep a created Persistent volume claim when uninstalling the helm chart (only for `useDeploymentWhenNonHA`) | ## Redis parameters diff --git a/charts/redis/RELEASENOTES.md b/charts/redis/RELEASENOTES.md index 39b2ee4e2c279c22968441dde511354f988578d9..fabbff79e39c6002fadb669899024810ccafb6ce 100644 --- a/charts/redis/RELEASENOTES.md +++ b/charts/redis/RELEASENOTES.md @@ -25,4 +25,5 @@ | 0.6.3 | 7.0.9 | Upgraded to Redis 7.0.9 | | 0.6.4 | 7.0.9 | Added option to use Deployment instead of StatefulSet for Non-HA deployments - thx @tim-hanssen | | 0.6.5 | 7.0.10 | Upgraded to Redis 7.0.10 | +| 0.6.6 | 7.0.10 | Fixed redis volume deployment in non-HA mode | | | | | diff --git a/charts/redis/templates/pvc.yaml b/charts/redis/templates/pvc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c35a0d96c5b75b10a6ecdd7316d3f7b2f4a0de8a --- /dev/null +++ b/charts/redis/templates/pvc.yaml @@ -0,0 +1,27 @@ +{{- if and (not .Values.haMode.enabled) (.Values.useDeploymentWhenNonHA) }} +{{- $createPvc := and (empty .Values.storage.persistentVolumeClaimName) (.Values.storage.requestedSize) }} +{{- if $createPvc }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "redis.fullname" . }} + labels: + {{- include "redis.labels" . | nindent 4 }} + {{- if .Values.storage.keepPvc }} + annotations: + "helm.sh/resource-policy": keep + {{- end }} +spec: + {{- with .Values.storage }} + accessModes: + {{- toYaml .accessModes | nindent 4 }} + volumeMode: Filesystem + resources: + requests: + storage: {{ .requestedSize }} + {{- if .className }} + storageClassName: {{ .className }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/redis/templates/statefulset.yaml b/charts/redis/templates/statefulset.yaml index b4cbbf257225f3127219c1fc2f5cb630a32d143f..473848498ce2c28dd2a2a70be57114eb39717b13 100644 --- a/charts/redis/templates/statefulset.yaml +++ b/charts/redis/templates/statefulset.yaml @@ -1,11 +1,14 @@ +{{- $createPvc := and (empty .Values.storage.persistentVolumeClaimName) (.Values.storage.requestedSize) }} +{{- $deployWithNonHA := and (not .Values.haMode.enabled) (.Values.useDeploymentWhenNonHA) }} +{{- $fullname := include "redis.fullname" . }} apiVersion: apps/v1 -{{- if and (not .Values.haMode.enabled) (.Values.useDeploymentWhenNonHA) }} +{{- if $deployWithNonHA }} kind: Deployment {{- else }} kind: StatefulSet {{- end }} metadata: - name: {{ include "redis.fullname" . }} + name: {{ $fullname }} labels: {{- include "redis.labels" . | nindent 4 }} spec: @@ -18,7 +21,7 @@ spec: revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} {{- end }} {{- if or (.Values.haMode.enabled) (not .Values.useDeploymentWhenNonHA) }} - serviceName: {{ include "redis.fullname" . }}-headless + serviceName: {{ $fullname }}-headless podManagementPolicy: {{ .Values.podManagementPolicy }} updateStrategy: type: {{ .Values.updateStrategyType }} @@ -282,12 +285,12 @@ spec: volumes: - name: scripts configMap: - name: {{ include "redis.fullname" . }}-scripts + name: {{ $fullname }}-scripts defaultMode: 0555 {{- if or (.Values.redisConfig) (.Values.sentinelConfig) }} - name: config configMap: - name: {{ include "redis.fullname" . }} + name: {{ $fullname }} {{- end }} {{- range $secret := .Values.extraRedisSecrets }} - name: {{ $secret.name }} @@ -312,7 +315,6 @@ spec: secretName: {{ .Values.extraSecretSentinelConfigs }} {{- end }} {{- with .Values.storage }} - {{- $createPvc := and (empty .persistentVolumeClaimName) .requestedSize }} {{- if not $createPvc }} - name: redis-data {{- if .persistentVolumeClaimName }} @@ -322,6 +324,11 @@ spec: emptyDir: {} {{- end }} {{- else }} + {{- if $deployWithNonHA }} + - name: redis-data + persistentVolumeClaim: + claimName: {{ $fullname }} + {{- else }} volumeClaimTemplates: - metadata: name: redis-data @@ -337,4 +344,5 @@ spec: requests: storage: {{ .requestedSize }} {{- end }} + {{- end }} {{- end }} diff --git a/charts/redis/values.yaml b/charts/redis/values.yaml index d7803cbb3c2e007055f48debf1b7808a161c274d..48298063585f7de3ef0a5ce5300c42f1583f5233 100644 --- a/charts/redis/values.yaml +++ b/charts/redis/values.yaml @@ -236,3 +236,6 @@ storage: ## Default access mode (ReadWriteOnce) accessModes: - ReadWriteOnce + + ## Keep a created Persistent volume claim when uninstalling the helm chart (only for non-HA mode with option useDeploymentWhenNonHA: true) + keepPvc: false