diff --git a/stable/redis/Chart.yaml b/stable/redis/Chart.yaml index 8d9c199d84..e26df759c1 100644 --- a/stable/redis/Chart.yaml +++ b/stable/redis/Chart.yaml @@ -1,5 +1,5 @@ name: redis -version: 5.3.0 +version: 5.4.0 appVersion: 4.0.12 description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. keywords: diff --git a/stable/redis/README.md b/stable/redis/README.md index d72116ca0b..16029c86d9 100644 --- a/stable/redis/README.md +++ b/stable/redis/README.md @@ -200,6 +200,13 @@ The following table lists the configurable parameters of the Redis chart and the | `slave.resources` | Redis slave CPU/Memory resource requests/limits | `master.resources` | | `slave.affinity` | Enable node/pod affinity for slaves | {} | | `slave.priorityClassName` | Redis Slave pod priorityClassName | {} | +| `sysctlImage.enabled` | Enable an init container to modify Kernel settings | `false` | +| `sysctlImage.command` | sysctlImage command to execute | [] | +| `sysctlImage.registry` | sysctlImage Init container registry | `docker.io` | +| `sysctlImage.repository` | sysctlImage Init container name | `bitnami/minideb` | +| `sysctlImage.tag` | sysctlImage Init container tag | `latest` | +| `sysctlImage.pullPolicy` | sysctlImage Init container pull policy | `Always` | +| `sysctlImage.mountHostSys` | Mount the host `/sys` folder to `/host-sys` | `false` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, @@ -253,3 +260,19 @@ $ helm install --set persistence.existingClaim=PVC_NAME stable/redis ## Metrics The chart optionally can start a metrics exporter for [prometheus](https://prometheus.io). The metrics endpoint (port 9121) is exposed in the service. Metrics can be scraped from within the cluster using something similar as the described in the [example Prometheus scrape configuration](https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml). If metrics are to be scraped from outside the cluster, the Kubernetes API proxy can be utilized to access the endpoint. + +## Host Kernel Settings +Redis may require some changes in the kernel of the host machine to work as expected, in particular increasing the `somaxconn` value and disabling transparent huge pages. +To do so, you can set up a privileged initContainer with the `sysctlImage` config values, for example: +``` +sysctlImage: + enabled: true + mountHostSys: true + command: + - /bin/sh + - -c + - |- + install_packages systemd + sysctl -w net.core.somaxconn=10000 + echo never > /host-sys/kernel/mm/transparent_hugepage/enabled +``` diff --git a/stable/redis/ci/production-values.yaml b/stable/redis/ci/production-values.yaml index ff7d005d53..4be8386deb 100644 --- a/stable/redis/ci/production-values.yaml +++ b/stable/redis/ci/production-values.yaml @@ -353,3 +353,14 @@ volumePermissions: ## configmap: |- # maxmemory-policy volatile-lru + +## Sysctl InitContainer +## used to perform sysctl operation to modify Kernel settings (needed sometimes to avoid warnings) +sysctlImage: + enabled: true + mountHostSys: true + command: + - /bin/sh + - -c + - |- + echo "sample command" diff --git a/stable/redis/templates/_helpers.tpl b/stable/redis/templates/_helpers.tpl index 9a77561872..f9e0b50d16 100644 --- a/stable/redis/templates/_helpers.tpl +++ b/stable/redis/templates/_helpers.tpl @@ -164,3 +164,12 @@ Get the password secret. {{- printf "%s" (include "redis.fullname" .) -}} {{- end -}} {{- end -}} + +{{/* +Return sysctl image +*/}} +{{- define "redis.sysctl.image" -}} +{{- $registryName := default "docker.io" .Values.sysctlImage.registry -}} +{{- $tag := default "latest" .Values.sysctlImage.tag | toString -}} +{{- printf "%s/%s:%s" $registryName .Values.sysctlImage.repository $tag -}} +{{- end -}} diff --git a/stable/redis/templates/redis-master-statefulset.yaml b/stable/redis/templates/redis-master-statefulset.yaml index c7aa4564a5..e10b7fd8cf 100644 --- a/stable/redis/templates/redis-master-statefulset.yaml +++ b/stable/redis/templates/redis-master-statefulset.yaml @@ -154,8 +154,10 @@ spec: - name: config mountPath: /opt/bitnami/redis/etc {{- end }} - {{- if and ( and .Values.master.persistence.enabled (not .Values.persistence.existingClaim) ) .Values.master.securityContext.enabled }} + {{- $needsVolumePermissions := and ( and .Values.master.persistence.enabled (not .Values.persistence.existingClaim) ) .Values.master.securityContext.enabled }} + {{- if or $needsVolumePermissions .Values.sysctlImage.enabled }} initContainers: + {{- if $needsVolumePermissions }} - name: volume-permissions image: "{{ template "volumePermissions.image" . }}" imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }} @@ -167,6 +169,21 @@ spec: mountPath: {{ .Values.master.persistence.path }} subPath: {{ .Values.master.persistence.subPath }} {{- end }} + {{- if .Values.sysctlImage.enabled }} + - name: init-sysctl + image: {{ template "redis.sysctl.image" . }} + {{- if .Values.sysctlImage.mountHostSys }} + volumeMounts: + - name: host-sys + mountPath: /host-sys + {{- end }} + command: +{{ toYaml .Values.sysctlImage.command | indent 10 }} + securityContext: + privileged: true + runAsUser: 0 + {{- end }} + {{- end }} volumes: - name: health configMap: @@ -192,6 +209,11 @@ spec: claimName: {{ .Values.persistence.existingClaim }} {{- end }} {{- end }} + {{- if .Values.sysctlImage.mountHostSys }} + - name: host-sys + hostPath: + path: /sys + {{- end }} {{- if and .Values.master.persistence.enabled (not .Values.persistence.existingClaim) }} volumeClaimTemplates: - metadata: diff --git a/stable/redis/templates/redis-slave-deployment.yaml b/stable/redis/templates/redis-slave-deployment.yaml index e16cd73237..dddb0e1760 100644 --- a/stable/redis/templates/redis-slave-deployment.yaml +++ b/stable/redis/templates/redis-slave-deployment.yaml @@ -153,6 +153,21 @@ spec: - name: config mountPath: /opt/bitnami/redis/etc {{- end }} + {{- if .Values.sysctlImage.enabled }} + initContainers: + - name: init-sysctl + image: {{ template "redis.sysctl.image" . }} + {{- if .Values.sysctlImage.mountHostSys }} + volumeMounts: + - name: host-sys + mountPath: /host-sys + {{- end }} + command: +{{ toYaml .Values.sysctlImage.command | indent 10 }} + securityContext: + privileged: true + runAsUser: 0 + {{- end }} volumes: - name: health configMap: @@ -170,4 +185,9 @@ spec: {{- end }} - name: redis-data emptyDir: {} + {{- if .Values.sysctlImage.mountHostSys }} + - name: host-sys + hostPath: + path: /sys + {{- end }} {{- end }} diff --git a/stable/redis/values-production.yaml b/stable/redis/values-production.yaml index 6eb13ec562..c18afb393f 100644 --- a/stable/redis/values-production.yaml +++ b/stable/redis/values-production.yaml @@ -376,3 +376,14 @@ volumePermissions: ## configmap: |- # maxmemory-policy volatile-lru + +## Sysctl InitContainer +## used to perform sysctl operation to modify Kernel settings (needed sometimes to avoid warnings) +sysctlImage: + enabled: false + command: [] + registry: docker.io + repository: bitnami/minideb + tag: latest + pullPolicy: Always + mountHostSys: false diff --git a/stable/redis/values.yaml b/stable/redis/values.yaml index 7cf99407c2..356fa99126 100644 --- a/stable/redis/values.yaml +++ b/stable/redis/values.yaml @@ -377,3 +377,14 @@ volumePermissions: ## configmap: |- # maxmemory-policy volatile-lru + +## Sysctl InitContainer +## used to perform sysctl operation to modify Kernel settings (needed sometimes to avoid warnings) +sysctlImage: + enabled: false + command: [] + registry: docker.io + repository: bitnami/minideb + tag: latest + pullPolicy: Always + mountHostSys: false