Restructuring and work on funkwhale

This commit is contained in:
Alexander Olofsson 2019-05-17 20:13:16 +02:00
parent c8476d492e
commit 40534e57d2
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
29 changed files with 613 additions and 71 deletions

View file

@ -0,0 +1,106 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "funkwhale.fullname" . }}-front
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: front
data:
nginx.conf: |
upstream funkwhale-api {
server {{ include "funkwhale.fullname" . }}-api.{{ .Release.Namespace }}.svc:5000;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name ${FUNKWHALE_HOSTNAME};
root /frontend;
location / {
include /etc/nginx/funkwhale_proxy.conf;
# this is needed if you have file import via upload enabled
client_max_body_size ${NGINX_MAX_BODY_SIZE};
proxy_pass http://funkwhale-api/;
}
location /front/ {
alias /frontend/;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location /federation/ {
include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/federation/;
}
# You can comment this if you do not plan to use the Subsonic API
location /rest/ {
include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/api/subsonic/rest/;
}
location /.well-known/ {
include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/.well-known/;
}
location /media/ {
alias ${MEDIA_ROOT}/;
}
{{- if .Values.s3.enabled }}
location ~ /_protected/media/(.+) {
internal;
proxy_pass $1;
}
{{- else }}
# this is an internal location that is used to serve
# audio files once correct permission / authentication
# has been checked on API side
location /_protected/media {
internal;
alias ${MEDIA_ROOT};
}
{{- end }}
location /_protected/music {
# this is an internal location that is used to serve
# audio files once correct permission / authentication
# has been checked on API side
# Set this to the same value as your MUSIC_DIRECTORY_PATH setting
internal;
alias ${MUSIC_DIRECTORY_PATH};
}
location /staticfiles/ {
# django static files
alias ${STATIC_ROOT}/;
}
}
proxy.conf: |
real_ip_header X-Forwarded-For;
set_real_ip_from 10.0.0.0/8;
proxy_set_header Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

View file

@ -0,0 +1,42 @@
apiVersion: v1
kind: ConfigMap
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 }}
data:
DJANGO_SETTINGS_MODULE: config.settings.production
FUNKWHALE_API_IP: 0.0.0.0
FUNKWHALE_API_PORT: "5000"
FUNKWHALE_FRONTEND_PATH: /srv/funkwhale/front/dist
MEDIA_ROOT: /srv/funkwhale/data/media
NGINX_MAX_BODY_SIZE: 30M
REVERSE_PROXY_TYPE: nginx
STATIC_ROOT: /srv/funkwhale/data/static
DJANGO_ALLOWED_HOSTS: {{ .Values.ingress.host }}
FUNKWHALE_HOSTNAME: {{ .Values.ingress.host }}
FUNKWHALE_PROTOCOL: {{ .Values.ingress.protocol }}
{{- if .Values.s3.enabled }}
AWS_ACCESS_KEY_ID: {{ .Values.s3.accessKey }}
AWS_SECRET_ACCESS_KEY: {{ .Values.s3.secretKey }}
AWS_STORAGE_BUCKET_NAME: {{ .Values.s3.bucket }}
{{- if .Values.s3.region }}
AWS_S3_REGION_NAME: {{ .Values.s3.region }}
{{- end }}
{{- if .Values.s3.location }}
AWS_LOCATION: {{ .Values.s3.location }}
{{- end }}
{{- if .Values.s3.url }}
AWS_S3_ENDPOINT_URL: {{ .Values.s3.url }}
{{- end }}
PROXY_MEDIA: {{ .Values.s3.proxy | quote }}
{{- end }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 2 }}
{{- end }}

View file

@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "funkwhale.fullname" . }}-api
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: api
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: api
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: api
spec:
containers:
- name: api
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "funkwhale.fullname" . }}
- secretRef:
name: {{ include "funkwhale.fullname" . }}
ports:
- name: api
containerPort: 5000
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: http
readinessProbe:
tcpSocket:
port: http
volumeMounts:
- name: data
mountPath: /srv/funkwhale/data
{{- range .Values.api.extraVolumeMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
readOnly: {{ .readOnly }}
{{- end }}
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ include "funkwhale.fullname" . }}-data
{{- range .Values.api.extraVolumeMounts }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ .existingClaim }}
{{- end }}<Paste>

View file

@ -1,51 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "funkwhale.fullname" . }}
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
spec:
replicas: {{ .Values.replicaCount }}
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: celery-beat
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: celery-beat
spec:
containers:
- name: {{ .Chart.Name }}
initContainers:
- name: celery-beat
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
command:
- sh
- -c
- |
celery -A funkwhale_api.taskapp beat -l INFO
envFrom:
- configMapRef:
name: {{ include "funkwhale.fullname" . }}
- secretRef:
name: {{ include "funkwhale.fullname" . }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
{{- toYaml .Values.celery.beat.resources | nindent 12 }}
{{- with .Values.celery.beat.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .Values.celery.beat.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .Values.celery.beat.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
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
spec:
replicas: {{ .Values.celery.worker.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: celery-worker
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: celery-worker
spec:
containers:
- name: worker
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
commands:
- sh
- -c
- |
celery -A funkwhale_api.taskapp worder -l INFO
env:
- name: C_FORCE_ROOT
value: "true"
envFrom:
- configMapRef:
name: {{ include "funkwhale.fullname" . }}
- secretRef:
name: {{ include "funkwhale.fullname" . }}
volumeMounts:
- mountPath: /srv/funkwhale/data
name: data
resources:
{{- toYaml .Values.celery.worker.resources | nindent 12 }}
{{- with .Values.celery.worker.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.celery.worker.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.celery.worker.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ include "funkwhale.fullname" . }}-data
- name: config
configMap:
name: {{ include "funkwhale.fullname" . }}-front
{{- range .Values.celery.worker.extraVolumeMounts }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ .existingClaim }}
{{- end }}

View file

@ -0,0 +1,102 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "funkwhale.fullname" . }}-front
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: front
spec:
replicas: {{ .Values.front.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: front
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: front
spec:
initContainers:
- name: front
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sh
- -c
- |
cp -r frontend/* /frontend/
volumeMounts:
- mountPath: /frontend
name: frontend
resources:
limits:
cpu: 50m
memory: 50Mi
containers:
- name: nginx
image: "{{ .Values.front.image.repository }}:{{ .Values.front.image.tag }}"
imagePullPolicy: {{ .Values.front.image.pullPolicy }}
commands:
- sh
- -c
- |
envsubst "`env | awk -F = '{printf \" $%s\", $1}'`" < /etc/nginx/funkwhale.template > /etc/nginx/conf.d/default.conf
nginx -g 'daemon off;'
envFrom:
- configMapRef:
name: {{ include "funkwhale.fullname" . }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
volumeMounts:
- mountPath: /frontend
name: frontend
- mountPath: /srv/funkwhale/data
name: data
- mountPath: /etc/nginx/funkwhale_proxy.conf
name: config
subPath: proxy.conf
- mountPath: /etc/nginx/funkwhale.template
name: config
subPath: nginx.conf
resources:
{{- toYaml .Values.front.resources | nindent 12 }}
{{- with .Values.front.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.front.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.front.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: frontend
emptyDir: {}
- name: data
persistentVolumeClaim:
claimName: {{ include "funkwhale.fullname" . }}-data
- name: config
configMap:
name: {{ include "funkwhale.fullname" . }}-front
{{- range .Values.front.extraVolumeMounts }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ .existingClaim }}
{{- end }}

View file

@ -32,7 +32,7 @@ spec:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
serviceName: {{ $fullName }}-front
servicePort: http
{{- end }}
{{- end }}

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
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 }}
data:
CACHE_URL: {{ .Values.redisUrl | b64enc }}
DATABASE_URL: {{ .Values.dbUrl | b64enc }}
DJANGO_SECRET_KEY: {{ .Values.djangoSecret | b64enc }}

View file

@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "funkwhale.fullname" . }}-api
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 }}
spec:
type: ClusterIP
ports:
- port: 5000
targetPort: api
protocol: TCP
name: api
selector:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: api

View file

@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "funkwhale.fullname" . }}
name: {{ include "funkwhale.fullname" . }}-front
labels:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
helm.sh/chart: {{ include "funkwhale.chart" . }}
@ -17,3 +17,4 @@ spec:
selector:
app.kubernetes.io/name: {{ include "funkwhale.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
audio.funkwhale/component: front

View file

@ -0,0 +1,161 @@
# Default values for funkwhale.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
repository: funkwhale/funkwhale
tag: 0.19.0
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
host: chart-example.local
protocol: http
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
dbUrl: ''
redisUrl: ''
djangoSecret: ''
extraEnv: []
# LDAP_ENABLED: "True"
# LDAP_ROOT_DN: dc=example,dc=com
# LDAP_SEARCH_FILTER: (|(uid={0})(mail={0}))
# LDAP_SERVER_URI: ldaps://ldap.example.com
# LDAP_START_TLS: "True"
# MEDIA_ROOT: /srv/funkwhale/data/media
# MUSIC_DIRECTORY_PATH: /srv/funkwhale/data/music
# MUSIC_DIRECTORY_SERVE_PATH: /srv/funkwhale/data/music
s3:
enabled: false
proxy: false
accessKey: ''
secretKey: ''
bucket: funkwhale
# region: us-1
# location: /funkwhale
# url: http://s3.example.com
api:
# Additional mounts to add to the API pod
extraVolumeMounts: []
# - name: extra-music-data
# mountPath: /srv/funkwhale/data/music
# readOnly: true
# existingClaim: volume-claim
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
front:
replicaCount: 1
image:
repository: nginx
tag: stable
pullPolicy: IfNotPresent
# Additional mounts to add to the frontend pod
extraVolumeMounts: []
# - name: extra-music-data
# mountPath: /srv/funkwhale/data/music
# readOnly: true
# existingClaim: volume-claim
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
celery:
beat:
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
worker:
replicaCount: 1
# Additional mounts to add to the frontend pod
extraVolumeMounts: []
# - name: extra-music-data
# mountPath: /srv/funkwhale/data/music
# readOnly: true
# existingClaim: volume-claim
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}

View file

@ -1,49 +0,0 @@
# Default values for funkwhale.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
tag: stable
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}