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/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/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..0c6572d 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -19,6 +19,23 @@ spec: app: {{ template "peertube.name" . }} release: {{ .Release.Name }} spec: +{{- if .Values.initcontainer.enabled }} + initContainers: + - name: init-peertube + 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 +{{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -31,12 +48,17 @@ spec: httpGet: path: / port: http - initialDelaySeconds: 300 + initialDelaySeconds: 60 readinessProbe: httpGet: path: / port: http - initialDelaySeconds: 300 + initialDelaySeconds: 60 + command: + - gosu + - peertube + - npm + - start env: - name: PEERTUBE_WEBSERVER_HOSTNAME value: {{ .Values.environment.hostname }} @@ -109,4 +131,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..84f9e8b --- /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 | nindent 2 }} \ No newline at end of file diff --git a/values.yml.sample b/values.yaml similarity index 83% rename from values.yml.sample rename to values.yaml index b7edc38..aec3d9c 100644 --- a/values.yml.sample +++ 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 @@ -53,7 +59,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 +93,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