diff --git a/charts/music-assistant/.helmignore b/charts/music-assistant/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/music-assistant/.helmignore @@ -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/ diff --git a/charts/music-assistant/Chart.yaml b/charts/music-assistant/Chart.yaml new file mode 100644 index 0000000..a360e66 --- /dev/null +++ b/charts/music-assistant/Chart.yaml @@ -0,0 +1,33 @@ +apiVersion: v2 +name: music-assistant +description: A Helm chart for Kubernetes +maintainers: + - name: toanju + email: toanju@users.noreply.github.com + 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" diff --git a/charts/music-assistant/templates/_helpers.tpl b/charts/music-assistant/templates/_helpers.tpl new file mode 100644 index 0000000..8329e9b --- /dev/null +++ b/charts/music-assistant/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/music-assistant/templates/deployment.yaml b/charts/music-assistant/templates/deployment.yaml new file mode 100644 index 0000000..5354044 --- /dev/null +++ b/charts/music-assistant/templates/deployment.yaml @@ -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 }} diff --git a/charts/music-assistant/templates/extra-objects.yaml b/charts/music-assistant/templates/extra-objects.yaml new file mode 100644 index 0000000..79fcdc8 --- /dev/null +++ b/charts/music-assistant/templates/extra-objects.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraObjects }} +--- +{{ include "music-assistant.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/charts/music-assistant/templates/extraService.yaml b/charts/music-assistant/templates/extraService.yaml new file mode 100644 index 0000000..dce5e52 --- /dev/null +++ b/charts/music-assistant/templates/extraService.yaml @@ -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 }} diff --git a/charts/music-assistant/templates/pvc.yaml b/charts/music-assistant/templates/pvc.yaml new file mode 100644 index 0000000..723cb02 --- /dev/null +++ b/charts/music-assistant/templates/pvc.yaml @@ -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 -}} diff --git a/charts/music-assistant/templates/service.yaml b/charts/music-assistant/templates/service.yaml new file mode 100644 index 0000000..5cc83c1 --- /dev/null +++ b/charts/music-assistant/templates/service.yaml @@ -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 }} diff --git a/charts/music-assistant/templates/serviceaccount.yaml b/charts/music-assistant/templates/serviceaccount.yaml new file mode 100644 index 0000000..da84a35 --- /dev/null +++ b/charts/music-assistant/templates/serviceaccount.yaml @@ -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 }} diff --git a/charts/music-assistant/templates/tests/test-connection.yaml b/charts/music-assistant/templates/tests/test-connection.yaml new file mode 100644 index 0000000..04fadbc --- /dev/null +++ b/charts/music-assistant/templates/tests/test-connection.yaml @@ -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 diff --git a/charts/music-assistant/values.yaml b/charts/music-assistant/values.yaml new file mode 100644 index 0000000..66d3acf --- /dev/null +++ b/charts/music-assistant/values.yaml @@ -0,0 +1,148 @@ +# Default values for music-assistant. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: ghcr.io/music-assistant/server + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +extraPorts: + {} + # service and deployment ports + # + ### naming a port http will override the default port 8095, e.g. + # + # http: + # servicePort: 80 + # containerPort: 8888 + # protocol: TCP + # + ### expos port for streaming + # sonos: + # servicePort: 8097 + # containerPort: 8097 + # protocol: TCP + +service: + # main service for http only + type: ClusterIP + # see https://kubernetes.io/docs/concepts/services-networking/dual-stack/ + ipFamilyPolicy: "SingleStack" + # see https://kubernetes.io/docs/concepts/services-networking/dual-stack/ + ipFamilies: + - IPv4 + annotations: {} + +extraService: + # extra service in case additional ports are exposed + type: ClusterIP + # see https://kubernetes.io/docs/concepts/services-networking/dual-stack/ + ipFamilyPolicy: "SingleStack" + # see https://kubernetes.io/docs/concepts/services-networking/dual-stack/ + ipFamilies: + - IPv4 + annotations: {} + +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: {} + +# Set to true to enable services like UPnP/SSDP +hostNetwork: false + +dnsPolicy: ClusterFirst + +persistence: + # persistence.enabled If true, use a Persistent Volume Claim. If false, use emptyDir. + enabled: false + + # Must match those of existing PV or dynamic provisioner + # Ref: https://kubernetes.io/docs/concepts/storage/persistent-volumes/ + accessModes: + - ReadWriteOncePod + + # Persistent Volume Claim annotations + annotations: {} + + # PVC must be created manually before volume will be bound + existingClaim: "" + + # Persistent Volume size + # + size: 1Gi + + ## Persistent Volume Storage Class Name + storageClassName: "" + + # Persistent Volume Binding Mode + volumeBindingMode: "" + + # Persistent Volume Claim Selector + # Useful if Persistent Volumes have been provisioned in advance + # Ref: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#selector + # e.g.: + # selector: + # matchLabels: + # release: "stable" + # matchExpressions: + # - { key: environment, operator: In, values: [ dev ] } + selector: {} + + # Persistent Volume Name + volumeName: "" + +strategy: + {} + # Deployment strategy + # e.g. + # type: Recreate + +exrtaObjects: [] + +ma: + env: [] diff --git a/renovate.json b/renovate.json index fc32c00..a2c084d 100644 --- a/renovate.json +++ b/renovate.json @@ -1,69 +1,82 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "github>toanju/renovate-config" - ], - "packageRules": [ - { - "matchDepNames": "ghcr.io/pi-hole/pihole", - "matchUpdateTypes": [ - "major", - "minor", - "patch", - "pin", - "digest" - ], - "automerge": false - } - ], - "customManagers": [ - { - "customType": "regex", - "description": "Update home-assistant container image references", - "fileMatch": [ - "^charts\\/home-assistant\\/Chart\\.yaml$" - ], - "matchStrings": [ - "appVersion: \"(?.*?)\"\\s+", - "version: (?.*?)\\s+" - ], - "depNameTemplate": "ghcr.io/home-assistant/home-assistant", - "datasourceTemplate": "docker" - }, - { - "customType": "regex", - "description": "Update mosquitto container image references", - "fileMatch": [ - "^charts\\/mosquitto\\/Chart\\.yaml$" - ], - "matchStrings": [ - "appVersion: \"(?.*?)\"\\s+", - "version: (?.*?)\\s+" - ], - "depNameTemplate": "eclipse-mosquitto", - "datasourceTemplate": "docker" - }, - { - "customType": "regex", - "description": "Update zigbee2mqtt container image references", - "fileMatch": [ - "^charts\\/zigbee2mqtt\\/Chart\\.yaml$" - ], - "matchStrings": [ - "appVersion: \"(?.*?)\"\\s+", - "version: (?.*?)\\s+" - ], - "depNameTemplate": "ghcr.io/koenkk/zigbee2mqtt", - "datasourceTemplate": "docker" - }, - { - "customType": "regex", - "fileMatch": [ - "(^|/)Chart\\.yaml$" - ], - "matchStrings": [ - "# renovate: datasource=(?[a-z-.]+?) depName=(?[^\\s]+?)(?: (lookupName|packageName)=(?[^\\s]+?))?(?: versioning=(?[^\\s]+?))?(?: extractVersion=(?[^\\s]+?))?(?: registryUrl=(?[^\\s]+?))?\\s(?:appVersion|version): \\\"?(?.+?)\\\"?\\s" - ] - } - ] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>toanju/renovate-config" + ], + "packageRules": [ + { + "matchDepNames": "ghcr.io/pi-hole/pihole", + "matchUpdateTypes": [ + "major", + "minor", + "patch", + "pin", + "digest" + ], + "automerge": false + } + ], + "customManagers": [ + { + "customType": "regex", + "description": "Update home-assistant container image references", + "fileMatch": [ + "^charts\\/home-assistant\\/Chart\\.yaml$" + ], + "matchStrings": [ + "appVersion: \"(?.*?)\"\\s+", + "version: (?.*?)\\s+" + ], + "depNameTemplate": "ghcr.io/home-assistant/home-assistant", + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Update music-assistant container image references", + "fileMatch": [ + "^charts\\/music-assistant\\/Chart\\.yaml$" + ], + "matchStrings": [ + "appVersion: \"(?.*?)\"\\s+", + "version: (?.*?)\\s+" + ], + "depNameTemplate": "ghcr.io/music-assistant/server", + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Update mosquitto container image references", + "fileMatch": [ + "^charts\\/mosquitto\\/Chart\\.yaml$" + ], + "matchStrings": [ + "appVersion: \"(?.*?)\"\\s+", + "version: (?.*?)\\s+" + ], + "depNameTemplate": "eclipse-mosquitto", + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Update zigbee2mqtt container image references", + "fileMatch": [ + "^charts\\/zigbee2mqtt\\/Chart\\.yaml$" + ], + "matchStrings": [ + "appVersion: \"(?.*?)\"\\s+", + "version: (?.*?)\\s+" + ], + "depNameTemplate": "ghcr.io/koenkk/zigbee2mqtt", + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "fileMatch": [ + "(^|/)Chart\\.yaml$" + ], + "matchStrings": [ + "# renovate: datasource=(?[a-z-.]+?) depName=(?[^\\s]+?)(?: (lookupName|packageName)=(?[^\\s]+?))?(?: versioning=(?[^\\s]+?))?(?: extractVersion=(?[^\\s]+?))?(?: registryUrl=(?[^\\s]+?))?\\s(?:appVersion|version): \\\"?(?.+?)\\\"?\\s" + ] + } + ] }