jellyfin: prepare titan-22 media host

This commit is contained in:
jenkins 2026-08-22 22:06:39 -03:00
parent 76fe550871
commit 5430c9ac01
5 changed files with 83 additions and 1 deletions

View File

@ -61,7 +61,12 @@ spec:
clear_worker titan-22 amd64
if k get node titan-22 >/dev/null 2>&1; then
k label node titan-22 atlas.bstein.dev/general-compute=last-resort --overwrite=true || true
k label node titan-22 \
atlas.bstein.dev/general-compute=last-resort \
atlas.bstein.dev/media-primary=true \
--overwrite=true || true
# Keep spare capacity available without letting routine pods displace media service.
k taint node titan-22 atlas.bstein.dev/media-primary=true:PreferNoSchedule --overwrite=true || true
fi
if k get node titan-23 >/dev/null 2>&1; then

View File

@ -0,0 +1,67 @@
# infrastructure/longhorn/core/jellyfin-volume-policy-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: jellyfin-volume-policy
namespace: longhorn-system
spec:
schedule: "* * * * *"
concurrencyPolicy: Forbid
startingDeadlineSeconds: 30
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 3
jobTemplate:
spec:
activeDeadlineSeconds: 120
backoffLimit: 1
ttlSecondsAfterFinished: 600
template:
spec:
serviceAccountName: longhorn-service-account
restartPolicy: Never
containers:
- name: ensure
image: bitnami/kubectl@sha256:554ab88b1858e8424c55de37ad417b16f2a0e65d1607aa0f3fe3ce9b9f10b131
command:
- /usr/bin/env
- bash
- -ceu
- |
ensure_volume() {
local pvc_name="${1}"
local replicas="${2}"
local disk_selector="${3}"
local pv_name
local volume_name
local current_replicas
local current_selector
pv_name="$(kubectl -n jellyfin get pvc "${pvc_name}" -o jsonpath='{.spec.volumeName}')"
test -n "${pv_name}"
volume_name="$(kubectl get pv "${pv_name}" -o jsonpath='{.spec.csi.volumeHandle}')"
test -n "${volume_name}"
current_replicas="$(kubectl -n longhorn-system get volumes.longhorn.io "${volume_name}" -o jsonpath='{.spec.numberOfReplicas}')"
current_selector="$(kubectl -n longhorn-system get volumes.longhorn.io "${volume_name}" -o jsonpath='{.spec.diskSelector[0]}')"
if [[ "${current_replicas}" != "${replicas}" || "${current_selector}" != "${disk_selector}" ]]; then
kubectl -n longhorn-system patch volumes.longhorn.io "${volume_name}" \
--type=merge \
--patch="{\"spec\":{\"numberOfReplicas\":${replicas},\"diskSelector\":[\"${disk_selector}\"]}}"
else
echo "${pvc_name}: ${replicas} replicas remain on ${disk_selector}"
fi
}
ensure_volume jellyfin-config-astreae 3 astreae
ensure_volume jellyfin-media-asteria-new 2 asteria
if kubectl -n longhorn-system get nodes.longhorn.io titan-22 >/dev/null 2>&1; then
allow_scheduling="$(kubectl -n longhorn-system get nodes.longhorn.io titan-22 -o jsonpath='{.spec.allowScheduling}')"
if [[ "${allow_scheduling}" != "false" ]]; then
kubectl -n longhorn-system patch nodes.longhorn.io titan-22 \
--type=merge \
--patch='{"spec":{"allowScheduling":false}}'
else
echo "titan-22: Longhorn replica scheduling remains disabled"
fi
fi

View File

@ -12,6 +12,7 @@ resources:
- longhorn-settings-ensure-job.yaml
- longhorn-csi-toleration-ensure-job.yaml
- longhorn-disk-tags-ensure-job.yaml
- jellyfin-volume-policy-cronjob.yaml
configMapGenerator:
- name: longhorn-settings-ensure-script

View File

@ -4,4 +4,5 @@ kind: Kustomization
resources:
- scavenger.yaml
- cassandra.yaml
- media.yaml
- veles.yaml

View File

@ -0,0 +1,8 @@
# infrastructure/modules/base/priorityclass/media.yaml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: media-core
value: 400
globalDefault: false
description: "For interactive media workloads; below stateful database services"