From cfcfdaa22fbc493741318563c0fd37e3d0e84521 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Thu, 2 Apr 2020 09:14:21 +0200 Subject: [PATCH] Add a new initContainer to copy default config files, fix #3 --- Chart.yaml | 2 +- scripts/peertube-chown.sh | 9 +++++++++ scripts/peertube-init.sh | 4 +--- templates/deployment.yaml | 22 ++++++++++++++++++++-- templates/peertube-chown.yml | 6 ++++++ values.yaml | 4 ++-- 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 scripts/peertube-chown.sh create mode 100644 templates/peertube-chown.yml diff --git a/Chart.yaml b/Chart.yaml index 61c2df7..fe89503 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "v2.1.0-buster" description: A Helm chart for Kubernetes name: peertube -version: 1.0.0 +version: 1.0.2 diff --git a/scripts/peertube-chown.sh b/scripts/peertube-chown.sh new file mode 100644 index 0000000..917bdae --- /dev/null +++ b/scripts/peertube-chown.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Ensure user is ok for config files +find /config ! -user peertube -exec chown peertube:peertube {} \; + +# Ensure user is ok for data files +find /data ! -user peertube -exec chown peertube:peertube {} \; + +exit 0 \ No newline at end of file diff --git a/scripts/peertube-init.sh b/scripts/peertube-init.sh index 064ea5f..c760dbd 100644 --- a/scripts/peertube-init.sh +++ b/scripts/peertube-init.sh @@ -8,9 +8,7 @@ fi # Always copy default and custom env configuration file, in cases new keys were added cp /app/config/default.yaml /config cp /app/support/docker/production/config/custom-environment-variables.yaml /config +# Patch user after the cp find /config ! -user peertube -exec chown peertube:peertube {} \; -# Ensure user is ok for data files -find /data ! -user peertube -exec chown peertube:peertube {} \; - exit 0 \ No newline at end of file diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 0c6572d..cf9049e 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -19,9 +19,8 @@ spec: app: {{ template "peertube.name" . }} release: {{ .Release.Name }} spec: -{{- if .Values.initcontainer.enabled }} initContainers: - - name: init-peertube + - name: peertube-init image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: @@ -35,6 +34,21 @@ spec: command: - sh - /init/peertube-init.sh +{{- if .Values.chowncontainer.enabled }} + - name: peertube-chown + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: data + mountPath: /data + - name: config + mountPath: /config + - mountPath: /init + name: peertube-chown + readOnly: true + command: + - sh + - /init/peertube-chown.sh {{- end }} containers: - name: {{ .Chart.Name }} @@ -136,3 +150,7 @@ spec: defaultMode: 420 name: peertube-init name: peertube-init + - configMap: + defaultMode: 420 + name: peertube-chown + name: peertube-chown diff --git a/templates/peertube-chown.yml b/templates/peertube-chown.yml new file mode 100644 index 0000000..94b80d4 --- /dev/null +++ b/templates/peertube-chown.yml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: peertube-chown +data: + {{- (.Files.Glob "scripts/peertube-chown.sh").AsConfig | nindent 2 }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 62e86a5..50072c3 100644 --- a/values.yaml +++ b/values.yaml @@ -28,10 +28,10 @@ ingress: hosts: - peertube.domain.tld -# At start initcontainer check every video files and chown it to peertube. +# At start chowncontainer check every video files and chown it to peertube user. # If you have lots of videos, it may take age. # If you are sure your rights are ok, you may disable this container to speed up start. -initcontainer: +chowncontainer: enabled: true resources: