Fixed init with metrics on

This commit is contained in:
Merlin Jehli committed 2025-04-28 00:08:38 +02:00 Unverified
1 parent 0fcf1d2206
commit 54ccfcb5b3
3 files changed
+47 -14

No files matched your search

+1 -1
View File
@@ -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,<EnableMetrics>false</EnableMetrics>,<EnableMetrics>true</EnableMetrics>,' -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 |
+45 -6
View File
@@ -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 '<EnableMetrics>true</EnableMetrics>' /config/config/system.xml; then
sed 's,<EnableMetrics>false</EnableMetrics>,<EnableMetrics>true</EnableMetrics>,' -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 }}
+1 -7
View File
@@ -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,<EnableMetrics>false</EnableMetrics>,<EnableMetrics>true</EnableMetrics>,' -i /config/config/system.xml &&
/jellyfin/jellyfin
# -- Configuration for the Prometheus ServiceMonitor
serviceMonitor:
# -- Enable or disable the creation of a ServiceMonitor resource