From 1052ccf6636d1cc17eb002d89c34fe4d3573a2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Cabrera=20Mi=C3=B1agorri?= Date: Mon, 8 Jul 2019 12:22:34 +0200 Subject: [PATCH] [stable/redis] Add support to execute Redis as root (#15276) * [stable/redis] Add support to execute Redis as root Signed-off-by: Miguel A. Cabrera Minagorri * Change Redis hardcoded data directory to the value at the Values.yaml when changing permissions deploying as root Signed-off-by: Miguel A. Cabrera Minagorri --- stable/redis/Chart.yaml | 2 +- stable/redis/templates/redis-master-statefulset.yaml | 4 ++++ stable/redis/templates/redis-slave-statefulset.yaml | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/stable/redis/Chart.yaml b/stable/redis/Chart.yaml index 234311ba2f..23449ee9da 100644 --- a/stable/redis/Chart.yaml +++ b/stable/redis/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: redis -version: 8.0.18 +version: 8.0.19 appVersion: 5.0.5 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/templates/redis-master-statefulset.yaml b/stable/redis/templates/redis-master-statefulset.yaml index 18f2bbce90..2bafaa1446 100644 --- a/stable/redis/templates/redis-master-statefulset.yaml +++ b/stable/redis/templates/redis-master-statefulset.yaml @@ -68,6 +68,10 @@ spec: - /bin/bash - -c - | + {{- if (eq .Values.securityContext.runAsUser 0.0) }} + useradd redis + chown -R redis {{ .Values.master.persistence.path }} + {{- end }} if [[ -n $REDIS_PASSWORD_FILE ]]; then password_aux=`cat ${REDIS_PASSWORD_FILE}` export REDIS_PASSWORD=$password_aux diff --git a/stable/redis/templates/redis-slave-statefulset.yaml b/stable/redis/templates/redis-slave-statefulset.yaml index da6b9228ed..32eae33052 100644 --- a/stable/redis/templates/redis-slave-statefulset.yaml +++ b/stable/redis/templates/redis-slave-statefulset.yaml @@ -76,6 +76,10 @@ spec: - /bin/bash - -c - | + {{- if (eq .Values.securityContext.runAsUser 0.0) }} + useradd redis + chown -R redis {{ .Values.slave.persistence.path }} + {{- end }} if [[ -n $REDIS_PASSWORD_FILE ]]; then password_aux=`cat ${REDIS_PASSWORD_FILE}` export REDIS_PASSWORD=$password_aux