first commit

This commit is contained in:
2025-11-15 19:53:41 +08:00
commit ec97834a55
14 changed files with 1828 additions and 0 deletions

12
templates/NOTES.txt Normal file
View File

@@ -0,0 +1,12 @@
Thank you for installing {{ .Chart.Name }}.
Your release is named {{ .Release.Name }}.
To learn more about the release, try:
$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
Mount path for remote is available at {{ .Values.rclone.path }}
You can use this as a volume within your other pods to view the file system for your remote.

123
templates/_helpers.tpl Normal file
View File

@@ -0,0 +1,123 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "pms-chart.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 "pms-chart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "pms-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
The image to use for pms
*/}}
{{- define "pms-chart.image" -}}
{{- if .Values.image.sha }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.image.repository (default ("latest") .Values.image.tag) .Values.image.sha }}
{{- else }}
{{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository (default ("latest") .Values.image.tag) .Values.image.sha }}
{{- end }}
{{- else }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.image.repository (default ( "latest") .Values.image.tag) }}
{{- else }}
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (default ( "latest") .Values.image.tag) }}
{{- end }}
{{- end }}
{{- end }}
{{/*
The image to use for the init containers
*/}}
{{- define "pms-chart.init_image" -}}
{{- if .Values.initContainer.image.sha }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.initContainer.image.repository (default ("latest") .Values.initContainer.image.tag) .Values.initContainer.image.sha }}
{{- else }}
{{- printf "%s/%s:%s@%s" .Values.initContainer.image.registry .Values.initContainer.image.repository (default ("latest") .Values.initContainer.image.tag) .Values.initContainer.image.sha }}
{{- end }}
{{- else }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.initContainer.image.repository (default ( "latest") .Values.initContainer.image.tag) }}
{{- else }}
{{- printf "%s/%s:%s" .Values.initContainer.image.registry .Values.initContainer.image.repository (default ( "latest") .Values.initContainer.image.tag) }}
{{- end }}
{{- end }}
{{- end }}
{{/*
The image to use for rclone
*/}}
{{- define "pms-chart.rclone_image" -}}
{{- if .Values.rclone.image.sha }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.rclone.image.repository (default ("latest") .Values.rclone.image.tag) .Values.rclone.image.sha }}
{{- else }}
{{- printf "%s/%s:%s@%s" .Values.rclone.image.registry .Values.rclone.image.repository (default ("latest") .Values.rclone.image.tag) .Values.rclone.image.sha }}
{{- end }}
{{- else }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.rclone.image.repository (default ( "latest") .Values.rclone.image.tag) }}
{{- else }}
{{- printf "%s/%s:%s" .Values.rclone.image.registry .Values.rclone.image.repository (default ( "latest") .Values.rclone.image.tag) }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "pms-chart.labels" -}}
app: {{ template "pms-chart.name" . }}
helm.sh/chart: {{ include "pms-chart.chart" . }}
{{ include "pms-chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels}}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "pms-chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pms-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "pms-chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "pms-chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,11 @@
{{- if .Values.initContainer.script -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "pms-chart.fullname" . }}-init-script
labels:
{{- include "pms-chart.labels" . | nindent 4 }}
data:
init.sh: |
{{ .Values.initContainer.script | indent 4 }}
{{- end -}}

40
templates/ingress.yaml Normal file
View File

@@ -0,0 +1,40 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "pms-chart.fullname" . }}-ingress
labels:
name: {{ include "pms-chart.fullname" . }}-ingress
{{ include "pms-chart.labels" . | indent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
rules:
- host: {{ trimPrefix "https://" .Values.ingress.url }}
http:
paths:
- path: '/'
pathType: Prefix
backend:
service:
name: {{ include "pms-chart.fullname" . }}
port:
number: 32400
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ tpl . $ }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

28
templates/service.yaml Normal file
View File

@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "pms-chart.fullname" . }}
labels:
{{- include "pms-chart.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: 32400
{{- if eq .Values.service.type "NodePort" }}
nodePort: {{ default "32400" .Values.service.nodePort }}
{{- end }}
protocol: TCP
name: pms
selector:
{{- include "pms-chart.selectorLabels" . | nindent 4 }}

View File

@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "pms-chart.serviceAccountName" . }}
labels:
{{- include "pms-chart.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}

243
templates/statefulset.yaml Normal file
View File

@@ -0,0 +1,243 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "pms-chart.fullname" . }}
labels:
name: {{ include "pms-chart.fullname" . }}
{{ include "pms-chart.labels" . | indent 4 }}
{{- with .Values.statefulSet.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
serviceName: {{ include "pms-chart.fullname" . }}
selector:
matchLabels:
{{- include "pms-chart.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "pms-chart.labels" . | nindent 8 }}
annotations:
{{- toYaml .Values.statefulSet.podAnnotations | nindent 8 }}
spec:
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
{{- end }}
{{- if .Values.dnsConfig }}
dnsConfig:
{{- toYaml .Values.dnsConfig | nindent 8 }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy | quote }}
{{- end }}
{{- if .Values.runtimeClassName }}
runtimeClassName: {{ .Values.runtimeClassName | quote }}
{{- end }}
serviceAccountName: {{ include "pms-chart.serviceAccountName" . }}
{{- if .Values.pms.shareProcessNamespace }}
shareProcessNamespace: {{ .Values.pms.shareProcessNamespace }}
{{- end }}
tolerations:
{{- toYaml .Values.tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}
volumes:
{{- if .Values.pms.configExistingClaim }}
- name: pms-config
persistentVolumeClaim:
claimName: {{ .Values.pms.configExistingClaim | quote }}
{{- end }}
- name: pms-transcode
emptyDir: {}
{{- if and .Values.rclone.enabled .Values.rclone.configSecret }}
{{- range .Values.rclone.remotes }}
- name: rclone-media-{{ (split ":" .)._0 }}
emptyDir: {}
{{- end }}
- name: rclone-config
emptyDir: {}
- name: rclone-config-data
secret:
secretName: {{ .Values.rclone.configSecret }}
{{- end }}
{{- if .Values.initContainer.script }}
- name: init-script-configmap
configMap:
defaultMode: 0700
name: {{ include "pms-chart.fullname" . }}-init-script
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 120
initContainers:
{{- if .Values.initContainer.script }}
- name: {{ include "pms-chart.fullname" . }}-pms-init
image: {{ include "pms-chart.init_image" . }}
command: ["/init/init.sh"]
volumeMounts:
- name: pms-config
mountPath: /config
- name: init-script-configmap
mountPath: /init
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8}}
{{- end }}
{{- end }}
{{- if and .Values.rclone.enabled .Values.rclone.configSecret }}
- name: {{ include "pms-chart.fullname" . }}-config
image: {{ include "pms-chart.init_image" . }}
command:
- sh
- -c
args:
- cp -v /in/* /out/
volumeMounts:
- name: rclone-config-data
mountPath: /in
readOnly: true
- name: rclone-config
mountPath: /out
{{- end }}
{{- with .Values.extraInitContainers }}
{{- toYaml . | nindent 6 }}
{{- end }}
containers:
- name: {{ include "pms-chart.fullname" . }}-pms
image: {{ include "pms-chart.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 32400
name: pms
env:
{{- if or .Values.ingress.enabled .Values.extraEnv.ADVERTISE_IP }}
- name: ADVERTISE_IP
value: {{ .Values.extraEnv.ADVERTISE_IP | default (printf "%s:443" .Values.ingress.url) }}
{{- end }}
{{- range $key, $value := .Values.extraEnv }}
{{- if ne $key "ADVERTISE_IP" }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if and .Values.pms.claimSecret.name .Values.pms.claimSecret.value }}
- name: PLEX_CLAIM
valueFrom:
secretKeyRef:
name: {{ .Values.pms.claimSecret.name }}
key: {{ .Values.pms.claimSecret.key }}
{{- end }}
{{- if .Values.pms.gpu.nvidia.enabled }}
- name: NVIDIA_VISIBLE_DEVICES
value: all
- name: NVIDIA_DRIVER_CAPABILITIES
value: compute,video,utility
{{- end }}
{{- with .Values.pms.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.pms.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.pms.resources }}
resources:
limits:
{{- with .limits }}
{{ toYaml . | indent 12 | trim }}
{{- end }}
{{- if and $.Values.pms.gpu.nvidia.enabled (not (hasKey .limits "nvidia.com/gpu")) }}
nvidia.com/gpu: 1
{{- end }}
{{- if .requests }}
requests:
{{ toYaml .requests | indent 12 | trim }}
{{- end }}
{{- end }}
{{- with .Values.pms.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: pms-config
mountPath: /config
- name: pms-transcode
mountPath: /transcode
{{- if and .Values.rclone.enabled .Values.rclone.configSecret }}
{{- range .Values.rclone.remotes }}
- name: rclone-media-{{ (split ":" .)._0 }}
mountPath: "/data/{{ (split ":" .)._0 }}"
mountPropagation: HostToContainer
{{- end }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if and .Values.rclone.enabled .Values.rclone.configSecret }}
{{- range .Values.rclone.remotes }}
- name: {{ include "pms-chart.fullname" $ }}-rclone-{{ (split ":" .)._0 }}
image: {{ include "pms-chart.rclone_image" $ }}
imagePullPolicy: {{ $.Values.rclone.image.pullPolicy }}
args:
- mount
- "{{ . }}"
- "/data/{{ (split ":" .)._0 }}"
- --config=/etc/rclone/rclone.conf
- --allow-non-empty
- --allow-other
{{- if $.Values.rclone.readOnly }}
- --read-only
{{- end }}
{{- range $.Values.rclone.additionalArgs }}
- {{ . }}
{{- end }}
{{- with $.Values.rclone.resources }}
resources:
{{ toYaml . | indent 10 }}
{{- end }}
lifecycle:
preStop:
exec:
command: ["/bin/sh","-c","fusermount3 -uz /data/{{ (split ":" .)._0 }}"]
securityContext:
privileged: true
capabilities:
add:
- SYS_ADMIN
volumeMounts:
- name: rclone-config
mountPath: /etc/rclone
- name: rclone-media-{{ (split ":" .)._0 }}
mountPath: "/data/{{ (split ":" .)._0 }}"
mountPropagation: Bidirectional
{{- end }}
{{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- if not .Values.pms.configExistingClaim }}
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pms-config
spec:
accessModes: [ "ReadWriteOnce" ]
{{- if .Values.pms.storageClassName }}
storageClassName: {{ .Values.pms.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ .Values.pms.configStorage }}
{{- end }}