Skip to content

Commit

Permalink
Merge pull request #60 from JacekZubielik/lms
Browse files Browse the repository at this point in the history
build(lms): version: 0.0.4
  • Loading branch information
JacekZubielik authored Jul 26, 2024
2 parents c665f4e + 500c5e9 commit 1ca4906
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 76 deletions.
2 changes: 1 addition & 1 deletion charts/lms/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions charts/lms/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{/* Expand the name of the chart. */}}

{{- define "lms.name" -}}
{{- define "app.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 "lms.fullname" -}}
{{- define "app.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/lms/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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 }}
Expand Down
57 changes: 45 additions & 12 deletions charts/lms/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
{{- 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 -}}
6 changes: 3 additions & 3 deletions charts/lms/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -50,4 +50,4 @@ spec:
protocol: TCP
targetPort: metrics
selector:
{{- include "lms.selectorLabels" . | nindent 4 }}
{{- include "app.selectorLabels" . | nindent 4 }}
4 changes: 2 additions & 2 deletions charts/lms/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions charts/lms/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
63 changes: 32 additions & 31 deletions charts/lms/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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: {}
Expand Down
36 changes: 25 additions & 11 deletions charts/lms/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,33 @@ affinity: {}
tolerations: []

persistence:
enabled: false
configstorage:
hostPath: /mnt/
lmsconfig:
enabled: true
## esphome data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## 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: []
Expand Down

0 comments on commit 1ca4906

Please sign in to comment.