Setup persistent storage for plex chart

This commit is contained in:
Waqar Ahmed 2020-12-07 03:01:28 +05:00
parent 883fb239bd
commit a78da65326
5 changed files with 181 additions and 234 deletions

View File

@ -120,3 +120,125 @@ questions:
description: "Create new pods and then kill old ones"
- value: "Recreate"
description: "Kill existing pods before creating new ones"
# Persistence
- variable: persistence
label: "Configure Persistent Storage"
group: "Storage"
schema:
type: dict
attrs:
- variable: transcode
label: "Configure Transcode Storage"
schema:
type: dict
attrs:
- variable: hostPathEnabled
label: "Configure Host Path for Transcode"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Specify HostPath for Transcode"
schema:
type: hostPath
required: true
- variable: volume
label: "Configure iXVolume"
schema:
type: dict
show_if: [["hostPathEnabled", "=", false]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: mountPath
label: "Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
default: "/transcode"
- variable: datasetName
label: "Dataset Name"
schema:
type: string
default: "ix-plex_transcode"
editable: false
- variable: data
label: "Configure Data Storage"
schema:
type: dict
attrs:
- variable: hostPathEnabled
label: "Configure Host Path for Data"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Specify HostPath for Data"
schema:
type: hostPath
required: true
- variable: volume
label: "Configure iXVolume"
schema:
type: dict
show_if: [["hostPathEnabled", "=", false]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: mountPath
label: "Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
default: "/data"
- variable: datasetName
label: "Dataset Name"
schema:
type: string
default: "ix-plex_data"
editable: false
- variable: config
label: "Configure Config Storage"
schema:
type: dict
attrs:
- variable: hostPathEnabled
label: "Configure Host Path for Config"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Specify HostPath for Config"
schema:
type: hostPath
required: true
- variable: volume
label: "Configure iXVolume"
schema:
type: dict
show_if: [["hostPathEnabled", "=", false]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: mountPath
label: "Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
default: "/config"
- variable: datasetName
label: "Dataset Name"
schema:
type: string
default: "ix-plex_config"
editable: false

View File

@ -0,0 +1,50 @@
{{/*
Retrieve host path from ix volumes based on dataset name
*/}}
{{- define "retrieveHostPathFromiXVolume" -}}
{{- range $index, $hostPathConfiguration := $.ixVolumes }}
{{- $dsName := base $hostPathConfiguration.hostPath -}}
{{- if eq $.datasetName $dsName -}}
{{- $hostPathConfiguration.hostPath -}}
{{- end -}}
{{- end }}
{{- end -}}
{{/*
Retrieve host path for transcode
Let's please remove the redundancy
*/}}
{{- define "configuredHostPathTranscode" -}}
{{- if .Values.persistence.transcode.hostPathEnabled -}}
{{- .Values.persistence.transcode.hostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.persistence.transcode.volume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}
{{/*
Retrieve host path for data
Let's please remove the redundancy
*/}}
{{- define "configuredHostPathData" -}}
{{- if .Values.persistence.data.hostPathEnabled -}}
{{- .Values.persistence.data.hostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.persistence.data.volume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}
{{/*
Retrieve host path for transcode
Let's please remove the redundancy
*/}}
{{- define "configuredHostPathConfig" -}}
{{- if .Values.persistence.config.hostPathEnabled -}}
{{- .Values.persistence.config.hostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.persistence.config.volume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}

View File

@ -67,26 +67,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: TRANSCODE_PVC
{{- if .Values.persistence.transcode.claimName }}
value: "{{ .Values.persistence.transcode.claimName }}"
{{- else }}
value: "{{ template "plex.fullname" . }}-transcode"
{{- end }}
{{- if .Values.persistence.data.enabled }}
- name: DATA_PVC
{{- if .Values.persistence.data.claimName }}
value: "{{ .Values.persistence.data.claimName }}"
{{- else }}
value: "{{ template "plex.fullname" . }}-data"
{{- end }}
{{- end }}
- name: CONFIG_PVC
{{- if .Values.persistence.config.claimName }}
value: "{{ .Values.persistence.config.claimName }}"
{{- else }}
value: "{{ template "plex.fullname" . }}-config"
{{- end }}
{{- if .Values.proxy.enabled }}
{{- if .Values.proxy.http }}
- name: "HTTP_PROXY"
@ -146,41 +126,12 @@ spec:
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
volumeMounts:
{{- if .Values.persistence.data.enabled }}
- name: data
mountPath: /data
{{- if .Values.persistence.data.subPath }}
subPath: {{ .Values.persistence.data.subPath }}
{{ end }}
{{ end }}
- name: config
mountPath: /config
{{- if .Values.persistence.config.subPath }}
subPath: {{ .Values.persistence.config.subPath }}
{{ end }}
- name: transcode
mountPath: /transcode
{{- if .Values.persistence.transcode.subPath }}
subPath: {{ .Values.persistence.transcode.subPath }}
{{ end }}
{{- range .Values.persistence.extraData }}
- mountPath: "/data-{{ .name }}"
{{- if .subPath }}
subPath: {{ .subPath }}
{{ end }}
name: "extradata-{{ .name }}"
{{- end }}
{{- range .Values.persistence.extraMounts }}
{{- if .mountPath }}
- mountPath: /{{ .mountPath }}
{{- else }}
- mountPath: /{{ .name }}
{{- end }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{ end }}
name: {{ .name }}
{{- end }}
- name: shared
mountPath: /shared
- name: shared-logs
@ -190,63 +141,17 @@ spec:
mountPath: {{ .Values.plexPreferences.volume.mountPath }}
subPath: {{ .Values.plexPreferences.volume.subPath }}
{{- end }}
{{- if .Values.certificate.pkcsMangler.enabled }}
- name: {{ .Values.certificate.pkcsMangler.volume.name }}
mountPath: {{ .Values.certificate.pkcsMangler.volume.mountPath }}
subPath: {{ .Values.certificate.pkcsMangler.volume.subPath }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
##### VOLUMES START #####
volumes:
{{- if .Values.persistence.data.enabled }}
- name: data
persistentVolumeClaim:
{{- if .Values.persistence.data.claimName }}
claimName: "{{ .Values.persistence.data.claimName }}"
{{- else }}
claimName: "{{ template "plex.fullname" . }}-data"
{{- end }}
{{- end }}
hostPath:
path: {{ template "configuredHostPathData" }}
- name: config
persistentVolumeClaim:
{{- if .Values.persistence.config.claimName }}
claimName: "{{ .Values.persistence.config.claimName }}"
{{- else }}
claimName: "{{ template "plex.fullname" . }}-config"
{{- end }}
hostPath:
path: {{ template "configuredHostPathConfig" }}
- name: transcode
{{- if .Values.persistence.transcode.enabled }}
persistentVolumeClaim:
{{- if .Values.persistence.transcode.claimName }}
claimName: "{{ .Values.persistence.transcode.claimName }}"
{{- else }}
claimName: "{{ template "plex.fullname" . }}-transcode"
{{- end }}
{{- else }}
{{- if .Values.persistence.transcode.emptyDir.medium }}
emptyDir:
medium: "{{ .Values.persistence.transcode.emptyDir.medium }}"
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- range .Values.persistence.extraData }}
- name: "extradata-{{ .name }}"
persistentVolumeClaim:
{{- if .claimName }}
claimName: "{{ .claimName }}"
{{- else }}
claimName: "extradata-{{ .name }}"
{{- end }}
{{- end }}
{{- range .Values.persistence.extraMounts }}
{{- if .claimName }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ .claimName }}
{{- end }}
{{- end }}
hostPath:
path: {{ template "configuredHostPathTranscode" }}
- name: shared
emptyDir: {}
- name: shared-logs

View File

@ -1,57 +0,0 @@
{{- if and (not .Values.persistence.transcode.claimName) .Values.persistence.transcode.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "plex.fullname" . }}-transcode
labels:
{{- include "plex.labels" . | nindent 4 }}
component: transcode
spec:
accessModes:
- {{ .Values.persistence.config.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.transcode.size | quote }}
{{- if .Values.persistence.transcode.storageClass }}
storageClassName: {{ .Values.persistence.transcode.storageClass | quote }}
{{- end }}
---
{{- end }}
{{- if not .Values.persistence.config.claimName }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "plex.fullname" . }}-config
labels:
{{- include "plex.labels" . | nindent 4 }}
component: config
spec:
accessModes:
- {{ .Values.persistence.config.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.config.size | quote }}
{{- if .Values.persistence.config.storageClass }}
storageClassName: {{ .Values.persistence.config.storageClass | quote }}
{{- end }}
---
{{- end }}
{{- if and (not .Values.persistence.data.claimName) .Values.persistence.data.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "plex.fullname" . }}-data
labels:
{{- include "plex.labels" . | nindent 4 }}
component: data
spec:
accessModes:
- {{ .Values.persistence.data.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.data.size | quote }}
{{- if .Values.persistence.data.storageClass }}
storageClassName: {{ .Values.persistence.data.storageClass | quote }}
{{- end }}
---
{{- end }}

View File

@ -100,84 +100,11 @@ hostNetwork: false
persistence:
transcode:
# We want to enable a transcode pvc
enabled: false
# Optionally specify claimName to manually override the PVC to be used for
# the transcode directory. If claimName is specified, storageClass and size
# are ignored.
## claimName: "plex-transcode-pvc"
# Optionally specify a storage class to be used for the transcode directory.
# If not specified and claimName is not specified, the default storage
# class will be used.
storageClass: ""
# subPath: some-subpath
# The requested size of the volume to be used when creating a
# PersistentVolumeClaim.
size: 20Gi
# Access mode for this volume
accessMode: ReadWriteOnce
# If not using a transcode PVC, specify emptyDir.medium="Memory" to use a tmpfs (in-memory)
# Volume for /transcode. Warning! this will greatly increase the amount of memory the plex pod is using
# AND it will count toward any ram pod/namespace limits. Additionally all data will be lost if/when the
# pod is moved to another node. --set persistence.transcode.emptyDir.medium="Memory" `
emptyDir:
medium: ""
# medium: "Memory"
hostPathEnabled: false
data:
# We want to enable a data pvc
enabled: true
# Optionally specify claimName to manually override the PVC to be used for
# the data directory. If claimName is specified, storageClass and size are
# ignored.
## claimName: "plex-data-pvc"
# Optionally specify a storage class to be used for the data directory.
# If not specified and claimName is not specified, the default storage
# class will be used.
storageClass: ""
# subPath: some-subpath
# The requested size of the volume to be used when creating a
# PersistentVolumeClaim.
size: 40Gi
# Access mode for this volume
accessMode: ReadWriteOnce
extraData: []
# Optionally specifify additional Data mounts. These will be mounted as
# /data-${name}. This should be in the same format as the above 'data',
# with the additional field 'name'
# - claimName: "special-tv"
# name: 'foo'
# subPath: optional/sub/path
extraMounts: []
## Include additional claims that can be mounted inside the
## pod. This is useful if you wish to use different paths with categories
## Claim will me mounted as /{mountPath} if specified. If no {mountPath} is given,
## mountPath will default to {name}
# - name: video
# # if claimName is specified the a new volume will mounted, if omitted the mount will be considered to be associated with one of the standard volumes (e.g data, config, transcode).
# # This useful to mount data to a different subPath
# claimName: optional-claim
# mountPath: /mnt/path/in/pod
# subPath: optional/sub/path
hostPathEnabled: false
config:
# Optionally specify claimName to manually override the PVC to be used for
# the config directory. If claimName is specified, storageClass and size
# are ignored.
## claimName: "plex-config-pvc"
# Optionally specify a storage class to be used for the config directory.
# If not specified and claimName is not specified, the default storage
# class will be used.
# subPath: some-subpath
storageClass: ""
# The requested size of the volume to be used when creating a
# PersistentVolumeClaim.
size: 20Gi
# Access mode for this volume
accessMode: ReadWriteOnce
hostPathEnabled: false
# Probes configuration
probes: