diff --git a/charts/lms/Chart.yaml b/charts/lms/Chart.yaml index bf4315e..4ac448e 100644 --- a/charts/lms/Chart.yaml +++ b/charts/lms/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 appVersion: 9.0.0 description: Logitech Media Server name: lms -version: 0.0.3 +version: 0.0.4 keywords: - lms - logitechmediaserver diff --git a/charts/lms/templates/_helpers.tpl b/charts/lms/templates/_helpers.tpl index f0ddf12..3354dbf 100644 --- a/charts/lms/templates/_helpers.tpl +++ b/charts/lms/templates/_helpers.tpl @@ -1,6 +1,6 @@ {{/* Expand the name of the chart. */}} -{{- define "lms.name" -}} +{{- define "app.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -8,7 +8,7 @@ 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 "lms.fullname" -}} +{{- define "app.fullname" -}} {{- if .Values.fullnameOverride -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- else -}} @@ -23,16 +23,16 @@ If release name contains chart name it will be used as a full name. */}} {{/* Create chart name and version as used by the chart label. */}} -{{- define "lms.chart" -}} +{{- define "app.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end -}} {{/* Common labels */}} -{{- define "lms.labels" -}} -helm.sh/chart: {{ include "lms.chart" . }} +{{- define "app.labels" -}} +helm.sh/chart: {{ include "app.chart" . }} -{{ include "lms.selectorLabels" . }} +{{ include "app.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion }} {{- end }} @@ -41,16 +41,16 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "lms.selectorLabels" -}} -app.kubernetes.io/name: {{ include "lms.name" . }} +{{- define "app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "app.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "lms.serviceAccountName" -}} +{{- define "app.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "lms.fullname" .) .Values.serviceAccount.name }} +{{- default (include "app.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} diff --git a/charts/lms/templates/ingress.yaml b/charts/lms/templates/ingress.yaml index 0e948fa..f62bf39 100644 --- a/charts/lms/templates/ingress.yaml +++ b/charts/lms/templates/ingress.yaml @@ -1,5 +1,5 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "lms.fullname" . -}} +{{- $fullName := include "app.fullname" . -}} {{- $servicePort := .Values.service.http -}} {{- $ingressPath := .Values.ingress.path -}} {{- $new := false }} @@ -13,7 +13,7 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - {{- include "lms.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} annotations: {{- if not $new }} kubernetes.io/ingress.class: {{ required "If ingress.enabled is set to true, ingress.class is required" .Values.ingress.class }} diff --git a/charts/lms/templates/pvc.yaml b/charts/lms/templates/pvc.yaml index e9cb873..358b74c 100644 --- a/charts/lms/templates/pvc.yaml +++ b/charts/lms/templates/pvc.yaml @@ -1,21 +1,54 @@ -{{- if and .Values.persistence.pvc.enabled (not .Values.persistence.configstorage.hostPath) }} +{{- if .Values.persistence.lmsconfig.enabled -}} +{{- if not .Values.persistence.lmsconfig.existingClaim -}} kind: PersistentVolumeClaim apiVersion: v1 metadata: - name: {{ template "lms.fullname" . }} + name: {{ template "app.fullname" . }} labels: - {{- include "lms.labels" . | nindent 4 }} + app.kubernetes.io/name: {{ include "app.name" . }} + helm.sh/chart: {{ include "app.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} spec: accessModes: - - {{ .Values.persistence.pvc.accessMode }} + - {{ .Values.persistence.lmsconfig.accessMode }} resources: requests: - storage: {{ .Values.persistence.pvc.size }} - {{- if .Values.persistence.pvc.storageClass }} - {{- if (eq "-" .Values.persistence.pvc.storageClass) }} + storage: {{ .Values.persistence.lmsconfig.size }} +{{- if .Values.persistence.lmsconfig.storageClass }} +{{- if (eq "-" .Values.persistence.lmsconfig.storageClass) }} storageClassName: "" - {{- else }} - storageClassName: "{{ .Values.persistence.pvc.storageClass }}" - {{- end }} - {{- end }} -{{- end }} \ No newline at end of file +{{- else }} + storageClassName: "{{ .Values.persistence.lmsconfig.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} +{{- end -}} + +--- +{{- if .Values.persistence.musicstorage.enabled -}} +{{- if not .Values.persistence.musicstorage.existingClaim -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "app.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "app.name" . }} + helm.sh/chart: {{ include "app.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + accessModes: + - {{ .Values.persistence.musicstorage.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.musicstorage.size }} +{{- if .Values.persistence.musicstorage.storageClass }} +{{- if (eq "-" .Values.persistence.musicstorage.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.musicstorage.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/lms/templates/service.yaml b/charts/lms/templates/service.yaml index 531b3ea..6ce4711 100644 --- a/charts/lms/templates/service.yaml +++ b/charts/lms/templates/service.yaml @@ -5,9 +5,9 @@ metadata: annotations: {{- toYaml .Values.service.annotations | nindent 4 }} {{- end }} - name: {{ template "lms.fullname" . }} + name: {{ template "app.fullname" . }} labels: - {{- include "lms.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} {{- if .Values.service.labels }} {{ toYaml .Values.service.labels | indent 4 }} {{- end }} @@ -50,4 +50,4 @@ spec: protocol: TCP targetPort: metrics selector: - {{- include "lms.selectorLabels" . | nindent 4 }} \ No newline at end of file + {{- include "app.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/charts/lms/templates/serviceaccount.yaml b/charts/lms/templates/serviceaccount.yaml index 0407ade..446a8c9 100644 --- a/charts/lms/templates/serviceaccount.yaml +++ b/charts/lms/templates/serviceaccount.yaml @@ -6,9 +6,9 @@ metadata: annotations: {{- toYaml .Values.serviceAccount.annotations | nindent 4 }} {{- end }} - name: {{ template "lms.fullname" . }} + name: {{ template "app.fullname" . }} labels: -{{- include "lms.labels" . | nindent 4 }} +{{- include "app.labels" . | nindent 4 }} {{- if .Values.serviceAccount.labels }} {{ toYaml .Values.serviceAccount.labels | indent 4 }} {{- end }} diff --git a/charts/lms/templates/servicemonitor.yaml b/charts/lms/templates/servicemonitor.yaml index 37094d7..92293f3 100644 --- a/charts/lms/templates/servicemonitor.yaml +++ b/charts/lms/templates/servicemonitor.yaml @@ -2,9 +2,9 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - name: {{ template "lms.fullname" . }}-prometheus-exporter + name: {{ template "app.fullname" . }}-prometheus-exporter labels: - {{- include "lms.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} {{- with .Values.monitoring.serviceMonitor.selector }} {{- toYaml . | nindent 4 }} {{- end }} @@ -18,7 +18,7 @@ metadata: spec: selector: matchLabels: - {{- include "lms.selectorLabels" . | nindent 6 }} + {{- include "app.selectorLabels" . | nindent 6 }} {{- if .Values.podLabels }} {{- toYaml .Values.podLabels | nindent 6 }} {{- end }} @@ -63,5 +63,5 @@ spec: optional: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.optional }} {{- end }} {{- end }} - jobLabel: {{ template "lms.fullname" . }}-prometheus-exporter + jobLabel: {{ template "app.fullname" . }}-prometheus-exporter {{- end }} \ No newline at end of file diff --git a/charts/lms/templates/statefulset.yaml b/charts/lms/templates/statefulset.yaml index 043ce03..94d7a23 100644 --- a/charts/lms/templates/statefulset.yaml +++ b/charts/lms/templates/statefulset.yaml @@ -1,16 +1,17 @@ +--- apiVersion: apps/v1 kind: StatefulSet metadata: - name: {{ template "lms.fullname" . }} + name: {{ include "app.fullname" . }} labels: - {{- include "lms.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicas }} revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} selector: matchLabels: - {{- include "lms.selectorLabels" . | nindent 6 }} - serviceName: {{ include "lms.fullname" . }} + {{- include "app.selectorLabels" . | nindent 6 }} + serviceName: {{ include "app.fullname" . }} updateStrategy: {{ toYaml .Values.updateStrategy | nindent 4 }} template: metadata: @@ -19,7 +20,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "lms.selectorLabels" . | nindent 8 }} + {{- include "app.selectorLabels" . | nindent 8 }} {{- if .Values.podLabels }} {{- toYaml .Values.podLabels | nindent 8 }} {{- end }} @@ -30,7 +31,7 @@ spec: {{- end }} automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} shareProcessNamespace: {{ .Values.sidecarSingleProcessNamespace }} - serviceAccountName: {{ include "lms.serviceAccountName" . }} + serviceAccountName: {{ include "app.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} {{- if .Values.hostNetwork }} @@ -44,7 +45,7 @@ spec: command: ["sh", "-c", "mkdir -pv /config /config/playlists /config/IR; chown -Rc 1000:1000 /config"] volumeMounts: - mountPath: /config - name: config-storage + name: lms-config containers: - name: {{ .Chart.Name }} securityContext: @@ -89,36 +90,36 @@ spec: {{- if .Values.livenessProbe.enabled }} livenessProbe: httpGet: - path: / - port: {{ .Values.service.httpPort }} - scheme: {{ .Values.livenessProbe.scheme }} - periodSeconds: {{ .Values.livenessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} - successThreshold: {{ .Values.livenessProbe.successThreshold }} - failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + path: / + port: {{ .Values.service.httpPort }} + scheme: {{ .Values.livenessProbe.scheme }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds}} {{- end }} {{- if .Values.readinessProbe.enabled }} readinessProbe: httpGet: - path: / - port: {{ .Values.service.httpPort }} - scheme: {{ .Values.readinessProbe.scheme }} - periodSeconds: {{ .Values.readinessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} - successThreshold: {{ .Values.readinessProbe.successThreshold }} - failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + path: / + port: {{ .Values.service.httpPort }} + scheme: {{ .Values.readinessProbe.scheme }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds}} {{- end }} volumeMounts: - mountPath: /config - name: config-storage + name: lms-config #subPath: config - mountPath: /config/playlists - name: config-storage + name: lms-config subPath: playlists - mountPath: /config/IR - name: config-storage + name: lms-config subPath: IR - mountPath: /music name: music-storage @@ -144,26 +145,26 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: config-storage - {{- if .Values.persistence.enabled }} - {{- if .Values.persistence.configstorage.hostPath }} + - name: lms-config + {{- if .Values.persistence.lmsconfig.enabled }} + {{- if .Values.persistence.lmsconfig.hostPath }} hostPath: - path: {{.Values.persistence.configstorage.hostPath}} + path: {{.Values.persistence.lmsconfig.hostPath}} {{- else }} persistentVolumeClaim: - claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "lms.fullname" . }}{{- end }} + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "app.fullname" . }}{{- end }} {{- end }} {{- else }} emptyDir: {} {{ end }} - name: music-storage - {{- if .Values.persistence.enabled }} + {{- if .Values.persistence.musicstorage.enabled }} {{- if .Values.persistence.musicstorage.hostPath }} hostPath: path: {{.Values.persistence.musicstorage.hostPath}} {{- else }} persistentVolumeClaim: - claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "lms.fullname" . }}{{- end }} + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "app.fullname" . }}{{- end }} {{- end }} {{- else }} emptyDir: {} diff --git a/charts/lms/values.yaml b/charts/lms/values.yaml index 2c379d2..5ba3fca 100644 --- a/charts/lms/values.yaml +++ b/charts/lms/values.yaml @@ -148,19 +148,33 @@ affinity: {} tolerations: [] persistence: - enabled: false - configstorage: - hostPath: /mnt/ + lmsconfig: + enabled: true + ## esphome data Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + ## + ## If you want to reuse an existing claim, you can pass the name of the PVC using + ## the existingClaim variable + # existingClaim: your-claim + ## + ## If you want to use a volume on the host machine instead of a PVC: + # hostPath: /path/to/the/config/folder + accessMode: ReadWriteOnce + size: 4Gi + musicstorage: - hostPath: /mnt/ - pvc: enabled: false - # accessModes: - # - {} - # resources: - # requests: - # storage: 2Gi - # storageClassName: "" + # storageClass: "-" + # existingClaim: your-claim + # hostPath: /path/to/the/music/folder + accessMode: ReadWriteOnce + size: 4Gi # Mount devices or folders from the host machine. Can be used for USB device mounting. hostMounts: []