[redis-ha] Added sysctl init container same as in stable/redis (#12633)

* [redis-ha] Added sysctl init container same as in stable/redis

Signed-off-by: killmeplz <killmeplz879@hotmail.com>

* redis-ha Added host sys volume

Signed-off-by: killmeplz <killmeplz879@hotmail.com>
This commit is contained in:
Peter Shilo
2019-04-15 05:22:14 -07:00
committed by Kubernetes Prow Robot
parent 60da05319b
commit f027055688
5 changed files with 65 additions and 2 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ keywords:
- redis
- keyvalue
- database
version: 3.3.5
version: 3.4.0
appVersion: 5.0.3
description: Highly available Kubernetes implementation of Redis
icon: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Redis_Logo.svg/1200px-Redis_Logo.svg.png
+24 -1
View File
@@ -83,7 +83,14 @@ The following table lists the configurable parameters of the Redis chart and the
| `exporter.extraArgs` | Additional args for the exporter | `{}` |
| `podDisruptionBudget` | Pod Disruption Budget rules | `{}` |
| `hostPath.path` | Use this path on the host for data storage | not set |
| `hostPath.chown` | Run an init-container as root to set ownership on the hostPath | true |
| `hostPath.chown` | Run an init-container as root to set ownership on the hostPath | `true` |
| `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,
@@ -124,3 +131,19 @@ Sentinel options supported must be in the the `sentinel <option> <master-group-n
```
If more control is needed from either the redis or sentinel config then an entire config can be defined under `redis.customConfig` or `sentinel.customConfig`. Please note that these values will override any configuration options under their respective section. For example, if you define `sentinel.customConfig` then the `sentinel.config` is ignored.
## 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
```
+10
View File
@@ -25,6 +25,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- 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 -}}
{{- /*
Credit: @technosophos
https://github.com/technosophos/common-chart/
@@ -50,6 +50,21 @@ spec:
{{ toYaml .Values.securityContext | indent 8 }}
serviceAccountName: {{ template "redis-ha.serviceAccountName" . }}
initContainers:
{{- 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:
runAsNonRoot: false
privileged: true
runAsUser: 0
{{- end }}
{{- if and .Values.hostPath.path .Values.hostPath.chown }}
- name: hostpath-chown
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
@@ -217,6 +232,11 @@ spec:
- name: probes
configMap:
name: {{ template "redis-ha.fullname" . }}-probes
{{- if .Values.sysctlImage.mountHostSys }}
- name: host-sys
hostPath:
path: /sys
{{- end }}
{{- if .Values.persistentVolume.enabled }}
volumeClaimTemplates:
- metadata:
+10
View File
@@ -28,6 +28,16 @@ serviceAccount:
rbac:
create: true
sysctlImage:
enabled: false
command: []
registry: docker.io
repository: bitnami/minideb
tag: latest
pullPolicy: Always
mountHostSys: false
## Redis specific configuration options
redis:
port: 6379