#1 Add a init container to do the chown job

Merged
LecygneNoir merged 4 commits from initContainers into master 4 years ago
  1. +2
    -2
      Chart.yaml
  2. +5
    -3
      README.md
  3. +11
    -0
      sample/claim.pvc-pt.yml
  4. +11
    -0
      sample/claim.pvc-ptconfig.yml
  5. +11
    -0
      sample/claim.pvc-redis.yml
  6. +16
    -0
      scripts/peertube-init.sh
  7. +29
    -3
      templates/deployment.yaml
  8. +6
    -0
      templates/peertube-init.yml
  9. +8
    -2
      values.yaml

+ 2
- 2
Chart.yaml View File

@ -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

+ 5
- 3
README.md View File

@ -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

+ 11
- 0
sample/claim.pvc-pt.yml View File

@ -0,0 +1,11 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-pt-prod
spec:
accessModes:
- ReadWriteMany
storageClassName: ChangeMeStorageClass
resources:
requests:
storage: 2Ti

+ 11
- 0
sample/claim.pvc-ptconfig.yml View File

@ -0,0 +1,11 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-ptconfig-prod
spec:
accessModes:
- ReadWriteMany
storageClassName: ChangeMeStorageClass
resources:
requests:
storage: 200Mi

+ 11
- 0
sample/claim.pvc-redis.yml View File

@ -0,0 +1,11 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-redis-prod
spec:
accessModes:
- ReadWriteMany
storageClassName: ChangeMeStorageClass
resources:
requests:
storage: 20Gi

+ 16
- 0
scripts/peertube-init.sh View File

@ -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

+ 29
- 3
templates/deployment.yaml View File

@ -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 }}
{{- end }}
- configMap:
defaultMode: 420
name: peertube-init
name: peertube-init

+ 6
- 0
templates/peertube-init.yml View File

@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: peertube-init
data:
{{- (.Files.Glob "scripts/peertube-init.sh").AsConfig | nindent 2 }}

values.yml.sample → values.yaml View File

@ -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

Loading…
Cancel
Save