From 221330626fbdbe821ba3586ffc3147c8088359a7 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Sun, 26 Sep 2021 21:57:52 +0200 Subject: [PATCH] funkwhale: Clean up and drop UNIX-socketification To bring the chart up to scratch for a 0.major bump If things work out well then this will be what's promoted to a 1.0 --- charts/funkwhale/templates/_helpers.tpl | 10 +-- .../funkwhale/templates/configmap-front.yaml | 2 +- .../templates/deployment-celerybeat.yaml | 2 +- .../templates/deployment-celeryworker.yaml | 2 +- charts/funkwhale/templates/deployment.yaml | 20 ++--- charts/funkwhale/values.yaml | 79 +++++++++++-------- 6 files changed, 61 insertions(+), 54 deletions(-) diff --git a/charts/funkwhale/templates/_helpers.tpl b/charts/funkwhale/templates/_helpers.tpl index ed5479f..3ab755b 100644 --- a/charts/funkwhale/templates/_helpers.tpl +++ b/charts/funkwhale/templates/_helpers.tpl @@ -7,8 +7,10 @@ Expand the name of the chart. {{- end -}} {{- define "funkwhale.dbUrl" -}} -{{- if and .Values.postgresql.enabled .Values.postgresql.host -}} -{{ fail "Setting both postgresql.enabled and postgresql.host will deploy an internal Postgres service and attempt to use an external one - please set only one of the two!" }} +{{- if .Values.database -}} +{{ fail "You are using the old database config key - please update your values to the new postgresql config key" }} +{{- else if and .Values.postgresql.enabled .Values.postgresql.host -}} +{{ fail "Both postgresql.enabled and postgresql.host have been specified - you may want to set postgresql.enabled=false if you want to use an external database" }} {{- else if .Values.postgresql.enabled -}} postgres://{{ .Values.postgresql.postgresqlUsername }}:{{ .Values.postgresql.postgresqlPassword }}@{{ template "funkwhale.fullname" . }}-postgresql:{{ .Values.postgresql.service.port }}/{{ .Values.postgresql.postgresqlDatabase }} {{- else if .Values.postgresql.host -}} @@ -18,10 +20,6 @@ postgres://{{ .Values.postgresql.postgresqlUsername }}:{{ .Values.postgresql.pos {{- end -}} {{- end -}} -{{- if .Values.database.user -}} -{{ fail "You are using the old database config key - please migrate to the new postgresql config key" }} -{{- end -}} - {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/charts/funkwhale/templates/configmap-front.yaml b/charts/funkwhale/templates/configmap-front.yaml index acdb9e5..cbd0445 100644 --- a/charts/funkwhale/templates/configmap-front.yaml +++ b/charts/funkwhale/templates/configmap-front.yaml @@ -12,7 +12,7 @@ metadata: data: nginx.conf: | upstream funkwhale-api { - server unix:/run/funkwhale/funkwhale.sock; + server localhost:5000; } map $http_upgrade $connection_upgrade { diff --git a/charts/funkwhale/templates/deployment-celerybeat.yaml b/charts/funkwhale/templates/deployment-celerybeat.yaml index 2ee8e25..9b438fc 100644 --- a/charts/funkwhale/templates/deployment-celerybeat.yaml +++ b/charts/funkwhale/templates/deployment-celerybeat.yaml @@ -5,10 +5,10 @@ metadata: name: {{ include "funkwhale.fullname" . }}-beat labels: app.kubernetes.io/name: {{ include "funkwhale.name" . }} - helm.sh/chart: {{ include "funkwhale.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} audio.funkwhale/component: celery-beat + helm.sh/chart: {{ include "funkwhale.chart" . }} spec: replicas: 1 selector: diff --git a/charts/funkwhale/templates/deployment-celeryworker.yaml b/charts/funkwhale/templates/deployment-celeryworker.yaml index f646b2e..e7b557c 100644 --- a/charts/funkwhale/templates/deployment-celeryworker.yaml +++ b/charts/funkwhale/templates/deployment-celeryworker.yaml @@ -5,10 +5,10 @@ metadata: name: {{ include "funkwhale.fullname" . }}-worker labels: app.kubernetes.io/name: {{ include "funkwhale.name" . }} - helm.sh/chart: {{ include "funkwhale.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} audio.funkwhale/component: celery-worker + helm.sh/chart: {{ include "funkwhale.chart" . }} spec: replicas: {{ .Values.celery.worker.replicaCount }} selector: diff --git a/charts/funkwhale/templates/deployment.yaml b/charts/funkwhale/templates/deployment.yaml index 35f7e44..0816f18 100644 --- a/charts/funkwhale/templates/deployment.yaml +++ b/charts/funkwhale/templates/deployment.yaml @@ -1,3 +1,6 @@ +{{- if .Values.api.readinessProbe.exec -}} +{{ fail "Your values are still using the old readinessProbe values, this will no longer work as expected" }} +{{- end -}} --- apiVersion: apps/v1 kind: Deployment @@ -5,10 +8,10 @@ metadata: name: {{ include "funkwhale.fullname" . }} labels: app.kubernetes.io/name: {{ include "funkwhale.name" . }} - helm.sh/chart: {{ include "funkwhale.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} audio.funkwhale/component: app + helm.sh/chart: {{ include "funkwhale.chart" . }} spec: replicas: {{ .Values.replicaCount }} selector: @@ -34,20 +37,15 @@ spec: - sh - -c - |- - set -x - # Copy frontend files for the front pod cp -r frontend/* /srv/funkwhale/frontend/ # Apply any waiting migrations /app/manage.py migrate - # Make the server bind to a unix socket if [ -e compose/django/daphne.sh ]; then - sed -e 's!-b 0.0.0.0 -p 5000!-u /run/funkwhale/funkwhale.sock!' -i compose/django/daphne.sh compose/django/entrypoint.sh compose/django/daphne.sh else - sed -e 's!0.0.0.0:5000!unix:/run/funkwhale/funkwhale.sock!' -i compose/django/server.sh compose/django/entrypoint.sh compose/django/server.sh fi readinessProbe: @@ -62,8 +60,6 @@ spec: - secretRef: name: {{ include "funkwhale.fullname" . }} volumeMounts: - - mountPath: /run/funkwhale - name: funkwhale-sock - mountPath: /srv/funkwhale/data/static/ name: static - mountPath: /srv/funkwhale/frontend @@ -73,6 +69,10 @@ spec: {{- with .Values.api.extraVolumeMounts }} {{ toYaml . | nindent 12 }} {{- end }} + ports: + - name: api + containerPort: 5000 + protocol: TCP resources: {{- toYaml .Values.api.resources | nindent 12 }} - name: nginx @@ -104,8 +104,6 @@ spec: startupProbe: {{ toYaml .Values.front.startupProbe | nindent 12 }} volumeMounts: - - mountPath: /run/funkwhale - name: funkwhale-sock - mountPath: /srv/funkwhale/data name: data - mountPath: /frontend @@ -135,8 +133,6 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: funkwhale-sock - emptyDir: {} - name: frontend emptyDir: {} - name: static diff --git a/charts/funkwhale/values.yaml b/charts/funkwhale/values.yaml index 80ffe6a..5e18d8e 100644 --- a/charts/funkwhale/values.yaml +++ b/charts/funkwhale/values.yaml @@ -31,39 +31,41 @@ ingress: # - chart-example.local postgresql: - # If you already have a Postgresql service you'd like to use, set - # this to false and adjust the host to use your existing service. + ## If you already have a Postgresql service you'd like to use, set + ## this to false and adjust the host to use your existing service. enabled: true - - ## Database host - host: "" + + ## External Postgresql hostname or IP + # host: postgresql.example.com ## Database user - postgresqlUsername: postgres + postgresqlUsername: funkwhale ## Database password postgresqlPassword: funkwhale - + ## Database password postgresqlDatabase: funkwhale - + ## Database port service: port: 5432 + ## Database storage configuration persistence: enabled: true # storageClass: "" # size: 8Gi redis: - # If you already have a Redis service you'd like to use, set - # this to false and adjust the host to use your existing service. + ## If you already have a Redis service you'd like to use, set + ## this to false and adjust the host to use your existing service. enabled: true - host: '' + ## External Redis hostname or IP + # host: redis.example.com redisPort: 6379 - password: 'funkwhale' + password: funkwhale cluster: enabled: false @@ -74,8 +76,10 @@ redis: persistence: enabled: false +## Django secret to use for encoding cookies/macaroons djangoSecret: '' +## Additional environment variables to set extraEnv: {} # LDAP_ENABLED: "True" # LDAP_ROOT_DN: dc=example,dc=com @@ -84,23 +88,26 @@ extraEnv: {} # LDAP_START_TLS: "True" # MEDIA_ROOT: /srv/funkwhale/data/media +## Additional secret environment variables to set extraSecret: {} # EMAIL_CONFIG: smtp:// # DEFAULT_FROM_EMAIL: funkwhale@example.com +## PVC-based data storage configuration persistence: enabled: false # existingClaim: netbox-data # storageClass: "-" - # Note; Using ReadWriteOnce for persistence will require the addition of - # a required affinity for the celery worker, as well as the use of only a - # single api replica. - # - # An example is provided for the worker affinity + ## Note; Using ReadWriteOnce for persistence will require the addition of + ## a required affinity for the celery worker, as well as the use of only a + ## single api replica. + ## + ## An example is provided for the worker affinity accessMode: ReadWriteMany size: 1Gi +## S3-based data storage configuration s3: enabled: false proxy: true @@ -112,13 +119,16 @@ s3: # location: /funkwhale # url: http://s3.example.com +## API server configuration api: - # Additional mounts to add to the API container + ## Additional mounts to add to the API container + ## If using an external media mount it needs to be attached to both API and Front extraVolumeMounts: [] # - name: extra-music-data # mountPath: /srv/funkwhale/data/music # readOnly: true + ## Additional volumes to add to the API container extraVolumes: [] # - name: extra-music-data # persistentVolumeClaim: @@ -137,36 +147,37 @@ api: tolerations: [] affinity: {} + readinessProbe: - exec: - command: - - stat - - /run/funkwhale/funkwhale.sock + httpGet: + path: / + port: api + scheme: HTTP livenessProbe: - exec: - command: - - stat - - /run/funkwhale/funkwhale.sock - - startupProbe: - exec: - command: - - stat - - /run/funkwhale/funkwhale.sock + httpGet: + path: / + port: api + scheme: HTTP + startupProbe: + tcpSocket: + port: api + +## Web frontend and proxy front: image: repository: nginx tag: stable pullPolicy: IfNotPresent - # Additional mounts to add to the frontend container + ## Additional mounts to add to the frontend container extraVolumeMounts: [] # - name: extra-music-data # mountPath: /srv/funkwhale/data/music # readOnly: true + ## Additional volumes to add to the frontend container extraVolumes: [] # - name: extra-music-data # persistentVolumeClaim: @@ -188,11 +199,13 @@ front: httpGet: path: / port: http + scheme: HTTP livenessProbe: httpGet: path: / port: http + scheme: HTTP startupProbe: tcpSocket: