From 78050af05f9ca698ca50161130020f8b83c30292 Mon Sep 17 00:00:00 2001 From: "victor.hery" Date: Fri, 3 Jan 2020 09:37:03 +0100 Subject: [PATCH 1/4] Add some more samples for easier installation --- README.md | 8 +++++--- sample/claim.pvc-pt.yml | 11 +++++++++++ sample/claim.pvc-ptconfig.yml | 11 +++++++++++ sample/claim.pvc-redis.yml | 11 +++++++++++ values.yml.sample => sample/values.yml | 0 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 sample/claim.pvc-pt.yml create mode 100644 sample/claim.pvc-ptconfig.yml create mode 100644 sample/claim.pvc-redis.yml rename values.yml.sample => sample/values.yml (100%) diff --git a/README.md b/README.md index 6957b94..52a4b61 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,11 @@ Federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly - [x] Use pvc to persist data - [ ] Improve readme for deployment -## Before deploy +## Before deploying -Currently if you want use persistent volume you need to create persistent volume and persistent volume claim +Currently if you want use persistent volume you need to create persistent volume and persistent volume claim. You may use sample claims from `sample`: + - change the storageclass from `ChangeMeStorageClass` to your correct class + - apply the claim: `kubectl apply -f sample/claim.pvc-pt.yml` You also need a postgresql server. If you know what you are doing and want to store postgres in Kubernetes, I suggest the excellent [stolon](https://github.com/helm/charts/tree/master/stable/stolon). @@ -34,7 +36,7 @@ Alternatively, a YAML file that specifies the values for the parameters can be p `$ helm install --name my-release -f values.yaml .` -See the values.yml.sample for example of values to use +See the sample/values.yml for example of values to use ## Source diff --git a/sample/claim.pvc-pt.yml b/sample/claim.pvc-pt.yml new file mode 100644 index 0000000..7d20a72 --- /dev/null +++ b/sample/claim.pvc-pt.yml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: pvc-pt-prod +spec: + accessModes: + - ReadWriteMany + storageClassName: ChangeMeStorageClass + resources: + requests: + storage: 2Ti diff --git a/sample/claim.pvc-ptconfig.yml b/sample/claim.pvc-ptconfig.yml new file mode 100644 index 0000000..caf14b7 --- /dev/null +++ b/sample/claim.pvc-ptconfig.yml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: pvc-ptconfig-prod +spec: + accessModes: + - ReadWriteMany + storageClassName: ChangeMeStorageClass + resources: + requests: + storage: 200Mi diff --git a/sample/claim.pvc-redis.yml b/sample/claim.pvc-redis.yml new file mode 100644 index 0000000..e14d51b --- /dev/null +++ b/sample/claim.pvc-redis.yml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: pvc-redis-prod +spec: + accessModes: + - ReadWriteMany + storageClassName: ChangeMeStorageClass + resources: + requests: + storage: 20Gi diff --git a/values.yml.sample b/sample/values.yml similarity index 100% rename from values.yml.sample rename to sample/values.yml -- 2.20.1 From 2cec938eedf98d68b62172f0a1db01a5e85c00e5 Mon Sep 17 00:00:00 2001 From: "victor.hery" Date: Fri, 3 Jan 2020 12:06:14 +0100 Subject: [PATCH 2/4] WIP: Add an initContainer to avoid the default entrypoint that take age to chown data directory if IO are slow (triggering ReadinessProbe in k8s) --- scripts/peertube-init.sh | 16 ++++++++++++++++ templates/deployment.yaml | 30 +++++++++++++++++++++++++++--- templates/peertube-init.yml | 6 ++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 scripts/peertube-init.sh create mode 100644 templates/peertube-init.yml diff --git a/scripts/peertube-init.sh b/scripts/peertube-init.sh new file mode 100644 index 0000000..064ea5f --- /dev/null +++ b/scripts/peertube-init.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Populate config directory +if [ -z "$(ls -A /config)" ]; then + cp /app/support/docker/production/config/* /config +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 +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 57da871..dc7bf23 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -19,6 +19,21 @@ spec: app: {{ template "peertube.name" . }} release: {{ .Release.Name }} spec: + initContainers: + - name: initPeertube + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: data + mountPath: /data + - name: config + mountPath: /config + - mountPath: /init + name: peertube-init + readOnly: true + command: + - sh + - /init/peertube-init.sh containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -31,12 +46,17 @@ spec: httpGet: path: / port: http - initialDelaySeconds: 300 + initialDelaySeconds: 60 readinessProbe: httpGet: path: / port: http - initialDelaySeconds: 300 + initialDelaySeconds: 90 + command: + - gosu + - peertube + - npm + - start env: - name: PEERTUBE_WEBSERVER_HOSTNAME value: {{ .Values.environment.hostname }} @@ -109,4 +129,8 @@ spec: {{- else }} - name: config emptyDir: {} -{{- end }} \ No newline at end of file +{{- end }} + - configMap: + defaultMode: 420 + name: peertube-init + name: peertube-init diff --git a/templates/peertube-init.yml b/templates/peertube-init.yml new file mode 100644 index 0000000..56aae31 --- /dev/null +++ b/templates/peertube-init.yml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: peertube-init +data: + {{ (.Files.Glob "scripts/peertube-init.sh").AsConfig | indent 2 }} \ No newline at end of file -- 2.20.1 From ded55372c6dfc56ef2af42c433ed82395eb732ed Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 12 Jan 2020 11:29:25 +0100 Subject: [PATCH 3/4] Patch somes values to be more helm linter compliant --- Chart.yaml | 4 ++-- templates/deployment.yaml | 4 ++-- templates/peertube-init.yml | 2 +- sample/values.yml => values.yaml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename sample/values.yml => values.yaml (91%) diff --git a/Chart.yaml b/Chart.yaml index 62c3323..7570ff3 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "1.0.x" +appVersion: "1.0.1" description: A Helm chart for Kubernetes name: peertube -version: 0.1.0 +version: 1.0.0 diff --git a/templates/deployment.yaml b/templates/deployment.yaml index dc7bf23..908d360 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -20,7 +20,7 @@ spec: release: {{ .Release.Name }} spec: initContainers: - - name: initPeertube + - name: init-peertube image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: @@ -51,7 +51,7 @@ spec: httpGet: path: / port: http - initialDelaySeconds: 90 + initialDelaySeconds: 60 command: - gosu - peertube diff --git a/templates/peertube-init.yml b/templates/peertube-init.yml index 56aae31..84f9e8b 100644 --- a/templates/peertube-init.yml +++ b/templates/peertube-init.yml @@ -3,4 +3,4 @@ kind: ConfigMap metadata: name: peertube-init data: - {{ (.Files.Glob "scripts/peertube-init.sh").AsConfig | indent 2 }} \ No newline at end of file + {{- (.Files.Glob "scripts/peertube-init.sh").AsConfig | nindent 2 }} \ No newline at end of file diff --git a/sample/values.yml b/values.yaml similarity index 91% rename from sample/values.yml rename to values.yaml index b7edc38..cccd3ef 100644 --- a/sample/values.yml +++ b/values.yaml @@ -53,7 +53,7 @@ tolerations: [] # values: # - yournodes.domain.tld -# Currently pvc are not handled by helm, you need to create both config and data volume before launching the helm +# PVC are not handled by helm, you need to create both config and data volume before launching the helm persistence: data: enabled: true @@ -87,7 +87,7 @@ redis: persistence: enabled: true path: /data - # Currently pvc are not handled by helm, you need to create redis volume before deploying helm + # PVC are not handled by helm, you need to create redis volume before deploying helm persistence: enabled: true existingClaim: pvc-redis-prod -- 2.20.1 From 350787b431713bcb57f0846c0f4b5a324a799fe8 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 12 Jan 2020 11:35:57 +0100 Subject: [PATCH 4/4] Add possibility to skip initcontainer to avoid long chown if wanted --- templates/deployment.yaml | 2 ++ values.yaml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 908d360..0c6572d 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -19,6 +19,7 @@ spec: app: {{ template "peertube.name" . }} release: {{ .Release.Name }} spec: +{{- if .Values.initcontainer.enabled }} initContainers: - name: init-peertube image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -34,6 +35,7 @@ spec: command: - sh - /init/peertube-init.sh +{{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" diff --git a/values.yaml b/values.yaml index cccd3ef..aec3d9c 100644 --- a/values.yaml +++ b/values.yaml @@ -28,6 +28,12 @@ ingress: hosts: - peertube.domain.tld +# At start initcontainer check every video files and chown it to peertube. +# 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: + enabled: true + resources: # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little -- 2.20.1