From 62645909da04f2446b7c7f122075c34539b85e40 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Mon, 20 May 2019 13:37:00 +0200 Subject: [PATCH] Plenty of fixes - Adds replicaCount to api - Allows disabling persistence - Adds a working resolver to nginx front - Collects statics for nginx front correctly --- charts/funkwhale/templates/configmap.yaml | 2 +- charts/funkwhale/templates/deployment-api.yaml | 10 +++++++++- .../templates/deployment-celeryworker.yaml | 4 ++++ charts/funkwhale/templates/deployment-front.yaml | 14 ++++++++++++++ charts/funkwhale/templates/pvc.yaml | 2 ++ charts/funkwhale/values.yaml | 3 +++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/charts/funkwhale/templates/configmap.yaml b/charts/funkwhale/templates/configmap.yaml index c7911a0..b53605b 100644 --- a/charts/funkwhale/templates/configmap.yaml +++ b/charts/funkwhale/templates/configmap.yaml @@ -39,6 +39,6 @@ data: PROXY_MEDIA: {{ .Values.s3.proxy | quote }} {{- end }} -{{- with .Values.extraEnv -}} +{{- with .Values.extraEnv }} {{- toYaml . | nindent 2 }} {{- end -}} diff --git a/charts/funkwhale/templates/deployment-api.yaml b/charts/funkwhale/templates/deployment-api.yaml index 104ba1b..b8a769e 100644 --- a/charts/funkwhale/templates/deployment-api.yaml +++ b/charts/funkwhale/templates/deployment-api.yaml @@ -9,7 +9,7 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} audio.funkwhale/component: api spec: - replicas: 1 + replicas: {{ .Values.api.replicaCount }} selector: matchLabels: app.kubernetes.io/name: {{ include "funkwhale.name" . }} @@ -42,14 +42,18 @@ spec: readinessProbe: tcpSocket: port: api + {{- if or .Values.persistence.enabled .Values.api.extraVolumeMounts }} volumeMounts: + {{- if .Values.persistence.enabled }} - name: data mountPath: /srv/funkwhale/data + {{- end }} {{- range .Values.api.extraVolumeMounts }} - name: {{ .name }} mountPath: {{ .mountPath }} readOnly: {{ .readOnly }} {{- end }} + {{- end }} resources: {{- toYaml .Values.api.resources | nindent 12 }} {{- with .Values.api.nodeSelector }} @@ -64,12 +68,16 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- if or .Values.persistence.enabled .Values.api.extraVolumeMounts }} volumes: + {{- if .Values.persistence.enabled }} - name: data persistentVolumeClaim: claimName: {{ include "funkwhale.fullname" . }} + {{- end }} {{- range .Values.api.extraVolumeMounts }} - name: {{ .name }} persistentVolumeClaim: claimName: {{ .existingClaim }} {{- end }} + {{- end }} diff --git a/charts/funkwhale/templates/deployment-celeryworker.yaml b/charts/funkwhale/templates/deployment-celeryworker.yaml index 6704fcf..1c4f75c 100644 --- a/charts/funkwhale/templates/deployment-celeryworker.yaml +++ b/charts/funkwhale/templates/deployment-celeryworker.yaml @@ -39,9 +39,11 @@ spec: name: {{ include "funkwhale.fullname" . }} - secretRef: name: {{ include "funkwhale.fullname" . }} + {{- if .Values.persistence.enabled }} volumeMounts: - mountPath: /srv/funkwhale/data name: data + {{- end }} resources: {{- toYaml .Values.celery.worker.resources | nindent 12 }} {{- with .Values.celery.worker.nodeSelector }} @@ -57,9 +59,11 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: + {{- if .Values.persistence.enabled }} - name: data persistentVolumeClaim: claimName: {{ include "funkwhale.fullname" . }} + {{- end }} - name: config configMap: name: {{ include "funkwhale.fullname" . }}-front diff --git a/charts/funkwhale/templates/deployment-front.yaml b/charts/funkwhale/templates/deployment-front.yaml index 26474fb..2d94bd4 100644 --- a/charts/funkwhale/templates/deployment-front.yaml +++ b/charts/funkwhale/templates/deployment-front.yaml @@ -30,10 +30,15 @@ spec: - sh - -c - | + set -x cp -r frontend/* /frontend/ + cp -r /usr/lib/python3.6/site-packages/django/contrib/admin/static/* /static/ + cp -r /app/funkwhale_api/static/* /static/ volumeMounts: - mountPath: /frontend name: frontend + - mountPath: /static + name: static resources: limits: cpu: 50m @@ -47,6 +52,7 @@ spec: - -c - | envsubst "`env | awk -F = '{printf \" $%s\", $1}'`" < /etc/nginx/funkwhale.template > /etc/nginx/conf.d/default.conf + echo "resolver $(grep nameserver /etc/resolv.conf | head -n1 | awk '{print $2}');" > /etc/nginx/conf.d/resolver.conf nginx -g 'daemon off;' envFrom: - configMapRef: @@ -64,8 +70,12 @@ spec: volumeMounts: - mountPath: /frontend name: frontend + - mountPath: /srv/funkwhale/data/static/ + name: static + {{- if .Values.persistence.enabled }} - mountPath: /srv/funkwhale/data name: data + {{- end }} - mountPath: /etc/nginx/funkwhale_proxy.conf name: config subPath: proxy.conf @@ -89,9 +99,13 @@ spec: volumes: - name: frontend emptyDir: {} + - name: static + emptyDir: {} + {{- if .Values.persistence.enabled }} - name: data persistentVolumeClaim: claimName: {{ include "funkwhale.fullname" . }} + {{- end }} - name: config configMap: name: {{ include "funkwhale.fullname" . }}-front diff --git a/charts/funkwhale/templates/pvc.yaml b/charts/funkwhale/templates/pvc.yaml index 9b0bf41..99a8619 100644 --- a/charts/funkwhale/templates/pvc.yaml +++ b/charts/funkwhale/templates/pvc.yaml @@ -1,3 +1,4 @@ +{{- if .Values.persistence.enabled }} kind: PersistentVolumeClaim apiVersion: v1 metadata: @@ -20,3 +21,4 @@ spec: storageClassName: "{{ .Values.persistence.storageClass }}" {{- end }} {{- end }} +{{- end }} diff --git a/charts/funkwhale/values.yaml b/charts/funkwhale/values.yaml index 4a07328..48fadee 100644 --- a/charts/funkwhale/values.yaml +++ b/charts/funkwhale/values.yaml @@ -71,6 +71,7 @@ extraSecret: {} # DEFAULT_FROM_EMAIL: funkwhale@example.com persistence: + enabled: false size: 1Gi storageClass: "-" @@ -86,6 +87,8 @@ s3: # url: http://s3.example.com api: + replicaCount: 1 + # Additional mounts to add to the API pod extraVolumeMounts: [] # - name: extra-music-data