diff --git a/charts/jellyfin/README.md b/charts/jellyfin/README.md index 4756894..d81ad8f 100644 --- a/charts/jellyfin/README.md +++ b/charts/jellyfin/README.md @@ -68,8 +68,8 @@ 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.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 | 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 | | 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 | @@ -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.accessMode | string | `"ReadWriteOnce"` | PVC specific settings, 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"` | | | 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. | | podSecurityContext | object | `{}` | Security context for the pod. | 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/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 382ad37..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 @@ -195,14 +200,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