From 53d1cd54f0b710c402dfd25278a66735eba969f1 Mon Sep 17 00:00:00 2001 From: Stephan van Maris Date: Thu, 29 Mar 2018 22:50:03 +0200 Subject: [PATCH] add an InitContainer to the Deployment to copy the files from the ConfigMap to an EmptyDir (#4271) * Update deployment.yaml ConfigMaps are mounted read-only since Kubernetes 1.9.4 (kubernetes/kubernetes#58720). The Grafana Chart uses a ConfigMap to provision the config- and dashboard directories. Grafana tries to create/modify files in these directories, which is not allowed anymore. This PR adds an busybox initContainer to the Deployment that copies the files from the ConfigMap to a new emptyDir, similar to #4169. Fixes #4267. * bump Chart version --- stable/grafana/Chart.yaml | 2 +- stable/grafana/templates/deployment.yaml | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/stable/grafana/Chart.yaml b/stable/grafana/Chart.yaml index 48961a30ac..cf79fb4995 100755 --- a/stable/grafana/Chart.yaml +++ b/stable/grafana/Chart.yaml @@ -1,5 +1,5 @@ name: grafana -version: 0.8.3 +version: 0.8.4 description: The leading tool for querying and visualizing time series and metrics. home: https://grafana.net icon: https://raw.githubusercontent.com/grafana/grafana/master/public/img/logo_transparent_400x.png diff --git a/stable/grafana/templates/deployment.yaml b/stable/grafana/templates/deployment.yaml index c85dd87428..9f3799c208 100644 --- a/stable/grafana/templates/deployment.yaml +++ b/stable/grafana/templates/deployment.yaml @@ -50,6 +50,19 @@ spec: app: {{ template "grafana.server.fullname" . }} {{- end }} {{- end }} + initContainers: + - name: copy-configs + image: busybox + command: ['sh', '-c', 'cp /tmp/config-volume-configmap/* /tmp/config-volume 2>/dev/null || true; cp /tmp/dashboard-volume-configmap/* /tmp/dashboard-volume 2>/dev/null || true'] + volumeMounts: + - name: config-volume-configmap + mountPath: /tmp/config-volume-configmap + - name: dashboard-volume-configmap + mountPath: /tmp/dashboard-volume-configmap + - name: config-volume + mountPath: /tmp/config-volume + - name: dashboard-volume + mountPath: /tmp/dashboard-volume containers: - name: {{ template "grafana.name" . }} image: "{{ .Values.server.image }}" @@ -92,9 +105,13 @@ spec: terminationGracePeriodSeconds: {{ default 300 .Values.server.terminationGracePeriodSeconds }} volumes: - name: config-volume + emptyDir: {} + - name: dashboard-volume + emptyDir: {} + - name: config-volume-configmap configMap: name: {{ template "grafana.server.fullname" . }}-config - - name: dashboard-volume + - name: dashboard-volume-configmap configMap: name: {{ template "grafana.server.fullname" . }}-dashs - name: storage-volume