From 54ccfcb5b34b5eee5a8b628c6afdbaa2b7880a57 Mon Sep 17 00:00:00 2001 From: Merlin Jehli Date: Mon, 28 Apr 2025 00:07:05 +0200 Subject: [PATCH 1/4] Fixed init with metrics on --- charts/jellyfin/README.md | 2 +- charts/jellyfin/templates/deployment.yaml | 51 ++++++++++++++++++++--- charts/jellyfin/values.yaml | 8 +--- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/charts/jellyfin/README.md b/charts/jellyfin/README.md index ebe5a24..e548b24 100644 --- a/charts/jellyfin/README.md +++ b/charts/jellyfin/README.md @@ -68,7 +68,7 @@ helm install my-jellyfin jellyfin/jellyfin -f values.yaml | jellyfin.enableDLNA | bool | `false` | Enable DLNA. Requires host network. See: https://jellyfin.org/docs/general/networking/dlna.html | | jellyfin.env | list | `[]` | Additional environment variables for the container. | | livenessProbe | object | `{"initialDelaySeconds":10,"tcpSocket":{"port":"http"}}` | Configure liveness probe for Jellyfin. | -| metrics | object | `{"command":["bash","-c","sed 's,false,true,' -i /config/config/system.xml && /jellyfin/jellyfin"],"enabled":false,"serviceMonitor":{"enabled":false,"interval":"30s","labels":{},"metricRelabelings":[],"namespace":"","path":"/metrics","port":8096,"relabelings":[],"scheme":"http","scrapeTimeout":"30s","targetLabels":[],"tlsConfig":{}}}` | Configuration for metrics collection and monitoring | +| metrics | object | `{"enabled":false,"serviceMonitor":{"enabled":false,"interval":"30s","labels":{},"metricRelabelings":[],"namespace":"","path":"/metrics","port":8096,"relabelings":[],"scheme":"http","scrapeTimeout":"30s","targetLabels":[],"tlsConfig":{}}}` | Configuration for metrics collection and monitoring | | metrics.enabled | bool | `false` | Enable or disable metrics collection - Ensure you have started and configured your Jellyfin instance first as this will fail if system.xml does not exist yet. | | metrics.serviceMonitor | object | `{"enabled":false,"interval":"30s","labels":{},"metricRelabelings":[],"namespace":"","path":"/metrics","port":8096,"relabelings":[],"scheme":"http","scrapeTimeout":"30s","targetLabels":[],"tlsConfig":{}}` | Configuration for the Prometheus ServiceMonitor | | metrics.serviceMonitor.enabled | bool | `false` | Enable or disable the creation of a ServiceMonitor resource | diff --git a/charts/jellyfin/templates/deployment.yaml b/charts/jellyfin/templates/deployment.yaml index 188540e..d458d87 100644 --- a/charts/jellyfin/templates/deployment.yaml +++ b/charts/jellyfin/templates/deployment.yaml @@ -45,13 +45,9 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - {{- if and .Values.image.command (not .Values.metrics.enabled) }} + {{- with .Values.jellyfin.command }} command: - {{- toYaml .Values.jellyfin.command | nindent 12 }} - {{- end }} - {{- if .Values.metrics.enabled }} - command: - {{- toYaml .Values.metrics.command | nindent 12 }} + {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.jellyfin.args }} args: @@ -61,6 +57,41 @@ spec: env: {{- toYaml . | nindent 12 }} {{- end }} + {{- if .Values.metrics.enabled }} + lifecycle: + postStart: + exec: + command: + - /bin/sh + - -c + - | + echo "Waiting for system.xml to enable metrics..." + timeout=300 # 5 minutes timeout + interval=5 # Check every 5 seconds + elapsed=0 + while [ ! -f /config/config/system.xml ]; do + if [ $elapsed -ge $timeout ]; then + echo "ERROR: Timed out waiting for /config/config/system.xml" >&2 + exit 1 + fi + sleep $interval + elapsed=$((elapsed + interval)) + done + echo "Found /config/config/system.xml, enabling metrics..." + # Check if metrics are already enabled before running sed + if ! grep -q 'true' /config/config/system.xml; then + sed 's,false,true,' -i /config/config/system.xml + if [ $? -eq 0 ]; then + echo "Metrics enabled successfully." + else + echo "ERROR: Failed to enable metrics in /config/config/system.xml" >&2 + exit 1 + fi + else + echo "Metrics already enabled." + fi + exit 0 + {{- end }} ports: - name: http containerPort: 8096 @@ -102,8 +133,16 @@ spec: {{- end }} - name: media {{- if .Values.persistence.media.enabled }} + {{- if eq .Values.persistence.media.type "pvc" }} persistentVolumeClaim: claimName: {{ if .Values.persistence.media.existingClaim }}{{ .Values.persistence.media.existingClaim }}{{- else }}{{ template "jellyfin.fullname" . }}-media{{- end }} + {{- else if eq .Values.persistence.media.type "hostPath" }} + hostPath: + path: {{ .Values.persistence.media.hostPath }} + type: Directory + {{- else }} + emptyDir: {} + {{- end }} {{- else }} emptyDir: {} {{- end }} diff --git a/charts/jellyfin/values.yaml b/charts/jellyfin/values.yaml index 382ad37..7422337 100644 --- a/charts/jellyfin/values.yaml +++ b/charts/jellyfin/values.yaml @@ -195,14 +195,8 @@ persistence: # -- Configuration for metrics collection and monitoring metrics: - # -- Enable or disable metrics collection - Ensure you have started and configured your Jellyfin instance first as this will fail if system.xml does not exist yet. + # -- Enable or disable metrics collection enabled: false - command: - - bash - - '-c' - - >- - sed 's,false,true,' -i /config/config/system.xml && - /jellyfin/jellyfin # -- Configuration for the Prometheus ServiceMonitor serviceMonitor: # -- Enable or disable the creation of a ServiceMonitor resource From e92576240cb34b45210956dda34f2bfee2d56d42 Mon Sep 17 00:00:00 2001 From: Merlin Jehli Date: Mon, 28 Apr 2025 00:09:20 +0200 Subject: [PATCH 2/4] Added option for media mount to be a hostpath --- charts/jellyfin/README.md | 10 ++++++---- charts/jellyfin/templates/persistentVolumeClaim.yaml | 2 +- charts/jellyfin/values.yaml | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/charts/jellyfin/README.md b/charts/jellyfin/README.md index e548b24..d402d83 100644 --- a/charts/jellyfin/README.md +++ b/charts/jellyfin/README.md @@ -90,11 +90,13 @@ helm install my-jellyfin jellyfin/jellyfin -f values.yaml | persistence.config.enabled | bool | `true` | set to false to use emptyDir | | persistence.config.size | string | `"5Gi"` | | | persistence.config.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | -| persistence.media.accessMode | string | `"ReadWriteOnce"` | | -| persistence.media.annotations | object | `{}` | Custom annotations to be added to the PVC | +| persistence.media.accessMode | string | `"ReadWriteOnce"` | PVC specific settings, only used if type is 'pvc'. | +| persistence.media.annotations | object | `{}` | Custom annotations to be added to the PVC, only used if type is 'pvc'. | | persistence.media.enabled | bool | `true` | set to false to use emptyDir | -| persistence.media.size | string | `"25Gi"` | | -| persistence.media.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | +| persistence.media.hostPath | string | `""` | Path on the host node for media storage, only used if type is 'hostPath'. | +| persistence.media.size | string | `"25Gi"` | PVC specific settings, only used if type is 'pvc'. | +| persistence.media.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. Only used if type is 'pvc'. | +| persistence.media.type | string | `"pvc"` | Type of volume for media storage (pvc, hostPath, emptyDir). If 'enabled' is false, 'emptyDir' is used regardless of this setting. | | podAnnotations | object | `{}` | Annotations to add to the pod. | | podLabels | object | `{}` | Additional labels to add to the pod. | | podSecurityContext | object | `{}` | Security context for the pod. | diff --git a/charts/jellyfin/templates/persistentVolumeClaim.yaml b/charts/jellyfin/templates/persistentVolumeClaim.yaml index c2abd23..709436d 100644 --- a/charts/jellyfin/templates/persistentVolumeClaim.yaml +++ b/charts/jellyfin/templates/persistentVolumeClaim.yaml @@ -21,7 +21,7 @@ spec: {{- end }} {{- end }} -{{- if and .Values.persistence.media.enabled (not .Values.persistence.media.existingClaim) }} +{{- if and .Values.persistence.media.enabled (eq .Values.persistence.media.type "pvc") (not .Values.persistence.media.existingClaim) }} --- apiVersion: v1 kind: PersistentVolumeClaim diff --git a/charts/jellyfin/values.yaml b/charts/jellyfin/values.yaml index 7422337..0d71148 100644 --- a/charts/jellyfin/values.yaml +++ b/charts/jellyfin/values.yaml @@ -184,6 +184,11 @@ persistence: media: # -- set to false to use emptyDir enabled: true + # -- Type of volume for media storage (pvc, hostPath, emptyDir). If 'enabled' is false, 'emptyDir' is used regardless of this setting. + type: pvc + # -- Path on the host node for media storage, only used if type is 'hostPath'. + hostPath: "" + # -- PVC specific settings, only used if type is 'pvc'. accessMode: ReadWriteOnce size: 25Gi # -- Custom annotations to be added to the PVC From d056210a1ea1291df386ab07a2800b68c1801e08 Mon Sep 17 00:00:00 2001 From: Merlin Jehli Date: Mon, 28 Apr 2025 00:09:47 +0200 Subject: [PATCH 3/4] Fixed README to be consistant with Values --- charts/jellyfin/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/jellyfin/README.md b/charts/jellyfin/README.md index d402d83..2f84e08 100644 --- a/charts/jellyfin/README.md +++ b/charts/jellyfin/README.md @@ -145,12 +145,12 @@ securityContext: - "ALL" privileged: false -extraVolumes: +volumes: - name: hwa hostPath: path: /dev/dri -extraVolumeMounts: +volumeMounts: - name: hwa mountPath: /dev/dri ``` From 2d884535f475ef96eae25f0b5eaa9c08b72591bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 27 Apr 2025 22:10:07 +0000 Subject: [PATCH 4/4] docs(charts): :memo: write updated reademe --- charts/jellyfin/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/jellyfin/README.md b/charts/jellyfin/README.md index 2f84e08..f695fa1 100644 --- a/charts/jellyfin/README.md +++ b/charts/jellyfin/README.md @@ -69,7 +69,7 @@ helm install my-jellyfin jellyfin/jellyfin -f values.yaml | jellyfin.env | list | `[]` | Additional environment variables for the container. | | livenessProbe | object | `{"initialDelaySeconds":10,"tcpSocket":{"port":"http"}}` | Configure liveness probe for Jellyfin. | | metrics | object | `{"enabled":false,"serviceMonitor":{"enabled":false,"interval":"30s","labels":{},"metricRelabelings":[],"namespace":"","path":"/metrics","port":8096,"relabelings":[],"scheme":"http","scrapeTimeout":"30s","targetLabels":[],"tlsConfig":{}}}` | Configuration for metrics collection and monitoring | -| metrics.enabled | bool | `false` | Enable or disable metrics collection - Ensure you have started and configured your Jellyfin instance first as this will fail if system.xml does not exist yet. | +| metrics.enabled | bool | `false` | Enable or disable metrics collection | | metrics.serviceMonitor | object | `{"enabled":false,"interval":"30s","labels":{},"metricRelabelings":[],"namespace":"","path":"/metrics","port":8096,"relabelings":[],"scheme":"http","scrapeTimeout":"30s","targetLabels":[],"tlsConfig":{}}` | Configuration for the Prometheus ServiceMonitor | | metrics.serviceMonitor.enabled | bool | `false` | Enable or disable the creation of a ServiceMonitor resource | | metrics.serviceMonitor.interval | string | `"30s"` | Interval at which metrics should be scraped | @@ -91,11 +91,11 @@ helm install my-jellyfin jellyfin/jellyfin -f values.yaml | persistence.config.size | string | `"5Gi"` | | | persistence.config.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | | persistence.media.accessMode | string | `"ReadWriteOnce"` | PVC specific settings, only used if type is 'pvc'. | -| persistence.media.annotations | object | `{}` | Custom annotations to be added to the PVC, only used if type is 'pvc'. | +| persistence.media.annotations | object | `{}` | Custom annotations to be added to the PVC | | persistence.media.enabled | bool | `true` | set to false to use emptyDir | | persistence.media.hostPath | string | `""` | Path on the host node for media storage, only used if type is 'hostPath'. | -| persistence.media.size | string | `"25Gi"` | PVC specific settings, only used if type is 'pvc'. | -| persistence.media.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. Only used if type is 'pvc'. | +| persistence.media.size | string | `"25Gi"` | | +| persistence.media.storageClass | string | `""` | If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | | persistence.media.type | string | `"pvc"` | Type of volume for media storage (pvc, hostPath, emptyDir). If 'enabled' is false, 'emptyDir' is used regardless of this setting. | | podAnnotations | object | `{}` | Annotations to add to the pod. | | podLabels | object | `{}` | Additional labels to add to the pod. | @@ -145,12 +145,12 @@ securityContext: - "ALL" privileged: false -volumes: +extraVolumes: - name: hwa hostPath: path: /dev/dri -volumeMounts: +extraVolumeMounts: - name: hwa mountPath: /dev/dri ```