Skip to content

Commit

Permalink
Merge pull request #236 from toanju/music-assistant
Browse files Browse the repository at this point in the history
feat: add music-assistant chart
  • Loading branch information
toanju authored Dec 15, 2024
2 parents cf7b3bf + 275efc5 commit 0b7eb3d
Show file tree
Hide file tree
Showing 12 changed files with 573 additions and 67 deletions.
23 changes: 23 additions & 0 deletions charts/music-assistant/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
33 changes: 33 additions & 0 deletions charts/music-assistant/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v2
name: music-assistant
description: A Helm chart for Kubernetes
maintainers:
- name: toanju
email: [email protected]
url: https://github.com/toanju/
home: https://github.com/toanju/helm-charts
sources:
- https://github.com/toanju/helm-charts
- https://github.com/music-assistant/server

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.3.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
# https://github.com/music-assistant/server/releases
appVersion: "2.3.3"
73 changes: 73 additions & 0 deletions charts/music-assistant/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "music-assistant.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- 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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "music-assistant.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "music-assistant.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "music-assistant.labels" -}}
helm.sh/chart: {{ include "music-assistant.chart" . }}
{{ include "music-assistant.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "music-assistant.selectorLabels" -}}
app.kubernetes.io/name: {{ include "music-assistant.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "music-assistant.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "music-assistant.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Renders a complete tree, even values that contains template.
*/}}
{{- define "music-assistant.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{ else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
87 changes: 87 additions & 0 deletions charts/music-assistant/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "music-assistant.fullname" . }}
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "music-assistant.selectorLabels" . | nindent 6 }}
{{- with .Values.strategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "music-assistant.selectorLabels" . | nindent 8 }}
spec:
hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "music-assistant.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.ma.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
{{- if not (hasKey .Values.extraPorts "http") }}
- containerPort: 8095
name: http
protocol: TCP
{{- end }}
{{- range $name, $v := .Values.extraPorts }}
- containerPort: {{ $v.containerPort }}
name: {{ $name }}
protocol: {{ $v.protocol | default "TCP" | quote }}
{{- end }}
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /data
name: data-volume
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: data-volume
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ include "music-assistant.fullname" . }}-pvc{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
4 changes: 4 additions & 0 deletions charts/music-assistant/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- range .Values.extraObjects }}
---
{{ include "music-assistant.render" (dict "value" . "context" $) }}
{{- end }}
31 changes: 31 additions & 0 deletions charts/music-assistant/templates/extraService.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.extraPorts -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "music-assistant.fullname" . }}-extra
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
{{- with .Values.extraService.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.extraService.type }}
{{- if .Values.extraService.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.extraService.ipFamilyPolicy }}
{{- end }}
{{- if .Values.extraService.ipFamilies }}
ipFamilies: {{ toYaml .Values.extraService.ipFamilies | nindent 4 }}
{{- end }}
ports:
{{- range $name, $v := .Values.extraPorts }}
{{- if not (eq $name "http") }}
- port: {{ $v.servicePort }}
name: {{ $name }}
targetPort: {{ $name }}
protocol: {{ $v.protocol | default "TCP" | quote }}
{{- end }}
{{- end }}
selector:
{{- include "music-assistant.selectorLabels" . | nindent 4 }}
{{- end }}
35 changes: 35 additions & 0 deletions charts/music-assistant/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if .Values.persistence.enabled -}}
{{- if not .Values.persistence.existingClaim -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
{{- with .Values.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "music-assistant.fullname" . }}-pvc
spec:
accessModes:
{{ toYaml .Values.persistence.accessModes | indent 4 }}
{{- if .Values.persistence.storageClassName }}
storageClassName: "{{ .Values.persistence.storageClassName }}"
{{- else }}
storageClassName: ""
{{- end }}
{{- if .Values.persistence.volumeBindingMode }}
volumeBindingMode: "{{ .Values.persistence.volumeBindingMode }}"
{{- end }}
resources:
requests:
storage: "{{ .Values.persistence.size }}"
{{- if .Values.persistence.selector }}
selector:
{{- toYaml .Values.persistence.selector | nindent 4 }}
{{- end -}}
{{- if .Values.persistence.volumeName }}
volumeName: "{{ .Values.persistence.volumeName }}"
{{- end -}}
{{- end -}}
{{- end -}}
32 changes: 32 additions & 0 deletions charts/music-assistant/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "music-assistant.fullname" . }}
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.service.ipFamilyPolicy }}
{{- end }}
{{- if .Values.service.ipFamilies }}
ipFamilies: {{ toYaml .Values.service.ipFamilies | nindent 4 }}
{{- end }}
ports:
{{- if and .Values.extraPorts .Values.extraPorts.http }}
- port: {{ .Values.extraPorts.http.servicePort | default 80 }}
name: http
targetPort: http
protocol: {{ .Values.extraPorts.http.protocol | default "TCP" | quote }}
{{- else }}
- port: 80
name: http
targetPort: http
protocol: TCP
{{- end }}
selector:
{{- include "music-assistant.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/music-assistant/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "music-assistant.serviceAccountName" . }}
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/music-assistant/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "music-assistant.fullname" . }}-test-connection"
labels:
{{- include "music-assistant.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "music-assistant.fullname" . }}:80']
restartPolicy: Never
Loading

0 comments on commit 0b7eb3d

Please sign in to comment.