Browse Source

WIP: Add an initContainer to avoid the default entrypoint that take age to chown data directory if IO are slow (triggering ReadinessProbe in k8s)

pull/1/head
victor.hery 4 years ago
parent
commit
2cec938eed
3 changed files with 49 additions and 3 deletions
  1. +16
    -0
      scripts/peertube-init.sh
  2. +27
    -3
      templates/deployment.yaml
  3. +6
    -0
      templates/peertube-init.yml

+ 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

+ 27
- 3
templates/deployment.yaml View File

@ -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 }}
{{- 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 | indent 2 }}

Loading…
Cancel
Save