Merge pull request #10 from truenas/plex-chart

Add Plex chart
This commit is contained in:
Waqar Ahmed 2020-12-08 19:40:14 +05:00 committed by GitHub
commit 52704d82d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 819 additions and 0 deletions

View File

@ -14,5 +14,9 @@
"definitions/gpuConfiguration": {
"stable": {"min": "20.12-ALPHA"},
"nightlies": {"min": "20.10-MASTER-somever"}
},
"definitions/timezone": {
"stable": {"min": "20.12-ALPHA"},
"nightlies": {"min": "20.12-MASTER"}
}
}

View File

@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# OWNERS file for Kubernetes
OWNERS

View File

@ -0,0 +1,11 @@
apiVersion: v2
appVersion: 1.20.2.3402
description: Plex Media Server
name: plex
version: 2.1.0
keywords:
- plex
home: https://plex.tv/
icon: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png
sources:
- https://hub.docker.com/r/plexinc/pms-docker/

View File

@ -0,0 +1,5 @@
# Plex Media Server helm chart
## Configuration
Please refer to questions.yaml for a detailed overview on supported configurable items.

View File

@ -0,0 +1,3 @@
# Plex
Plex chart is a chart designed to deploy plex in a TrueNAS SCALE kubernetes cluster.

View File

@ -0,0 +1,273 @@
groups:
- name: "Container Images"
description: "Image to be used for container"
- name: "Container Entrypoint"
description: "Configuration of the executable that will be run when the container is started"
- name: "Container Environment Variables"
description: "Set the environment that will be visible to the container"
- name: "Networking"
description: "Configure networking for container"
- name: "Storage"
description: "Persist and share data that is separate from the lifecycle of the container"
- name: "Plex Configuration"
description: "Configure plex deployment"
- name: "Workload Details"
description: "Configure how workload should be deployed"
- name: "Scaling/Upgrade Policy"
description: "Configure how pods are replaced when configuration is upgraded"
- name: "Restart Policy"
description: "Configure when pod should be restarted in case of failure"
- name: "Resource Reservation"
description: "Specify resources to be allocated to workload"
portals:
web_portal:
protocols:
- "http"
host:
- "$node_ip"
ports:
- "$variable-plexServiceTCP.port"
questions:
# Image related
- variable: image
description: "Docker Image Details"
label: "Docker Image"
group: "Container Images"
schema:
type: dict
required: true
attrs:
- variable: repository
description: "Docker image repository"
label: "Image repository"
schema:
type: string
required: true
default: "plexinc/pms-docker"
- variable: tag
description: "Tag to use for specified image"
label: "Image Tag"
schema:
type: string
default: "1.20.2.3402-0fec14d92"
- variable: pullPolicy
description: "Docker Image Pull Policy"
label: "Image Pull Policy"
schema:
type: string
default: "IfNotPresent"
enum:
- value: "IfNotPresent"
description: "Only pull image if not present on host"
- value: "Always"
description: "Always pull image even if present on host"
- value: "Never"
description: "Never pull image even if it's not present on host"
- variable: claimToken
label: "Plex Claim Token"
group: "Plex Configuration"
schema:
type: string
default: ""
- variable: advertiseIp
label: "Plex Advertise IP"
group: "Plex Configuration"
schema:
type: string
- variable: extraEnv
label: "Environment variables for plex"
group: "Plex Configuration"
schema:
type: dict
additional_attrs: true
attrs: []
- variable: proxy
label: "Configure Proxy environment variable"
group: "Plex Configuration"
schema:
type: dict
attrs:
- variable: enabled
label: "Enable Proxy"
schema:
type: boolean
default: false
- variable: http
label: "HTTP Proxy"
schema:
type: string
- variable: https
label: "HTTPS Proxy"
schema:
type: string
- variable: hostNetwork
label: "Configure Host Network"
group: "Networking"
schema:
type: boolean
default: false
- variable: timezone
label: "Plex container timezone"
group: "Plex Configuration"
schema:
type: string
default: "Etc/UTC"
$ref:
- "definitions/timezone"
# Update strategy
- variable: strategyType
description: "Upgrade Policy"
label: "Update Strategy"
group: "Scaling/Upgrade Policy"
schema:
type: string
default: "Recreate"
enum:
- value: "RollingUpdate"
description: "Create new pods and then kill old ones"
- value: "Recreate"
description: "Kill existing pods before creating new ones"
# Port configuration
- variable: plexServiceTCP
label: "Configure Plex TCP Service"
group: "Networking"
schema:
type: dict
attrs:
- variable: port
label: "Port to expose for Plex UI"
schema:
type: int
min: 9000
max: 65535
default: 32400
- variable: transcodeHostPathEnabled
label: "Configure Host Path for Transcode"
group: "Storage"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: transcodeHostPath
label: "Specify HostPath for Transcode"
schema:
type: hostpath
required: true
- variable: transcodeVolume
label: "Configure iXVolume"
group: "Storage"
schema:
type: dict
show_if: [["transcodeHostPathEnabled", "=", 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: dataHostPathEnabled
label: "Configure Host Path for Data"
group: "Storage"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: dataHostPath
label: "Specify HostPath for Data"
schema:
type: hostpath
required: true
- variable: dataVolume
label: "Configure data iXVolume"
group: "Storage"
schema:
type: dict
show_if: [["dataHostPathEnabled", "=", 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: configHostPathEnabled
label: "Configure Host Path for Config"
group: "Storage"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: configHostPath
label: "Specify HostPath for Config"
schema:
type: hostpath
required: true
- variable: configVolume
label: "Configure iXVolume"
group: "Storage"
schema:
type: dict
show_if: [["configHostPathEnabled", "=", 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
# Specify GPU configuration
- variable: gpuConfiguration
label: "GPU Configuration"
group: "Resource Reservation"
schema:
type: dict
$ref:
- "definitions/gpuConfiguration"

View File

@ -0,0 +1,3 @@
1. Get the application URL by running these commands:
http://$node_ip:{{ .Values.plexServiceTCP.port }}/

View File

@ -0,0 +1,81 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "plex.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 "plex.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 "plex.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "plex.labels" -}}
helm.sh/chart: {{ include "plex.chart" . }}
{{ include "plex.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "plex.selectorLabels" -}}
app.kubernetes.io/name: {{ include "plex.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "plex.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "plex.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
abstract: |
Joins a list of values into a comma separated string
values: |
test:
- foo
- bar
usage: |
{{ include "joinListWithComma" .Values.test }}
return: |
foo,bar
*/}}
{{- define "joinListWithComma" -}}
{{- $local := dict "first" true -}}
{{- range $k, $v := . -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}{{- $_ := set $local "first" false -}}{{- end -}}
{{- end -}}

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.transcodeHostPathEnabled -}}
{{- .Values.transcodeHostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.transcodeVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}
{{/*
Retrieve host path for data
Let's please remove the redundancy
*/}}
{{- define "configuredHostPathData" -}}
{{- if .Values.dataHostPathEnabled -}}
{{- .Values.dataHostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.dataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}
{{/*
Retrieve host path for transcode
Let's please remove the redundancy
*/}}
{{- define "configuredHostPathConfig" -}}
{{- if .Values.configHostPathEnabled -}}
{{- .Values.configHostPath -}}
{{- else -}}
{{- $volDict := dict "datasetName" $.Values.configVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,153 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "plex.fullname" . }}
labels:
{{- include "plex.labels" . | nindent 4 }}
spec:
replicas: 1
revisionHistoryLimit: 3
strategy:
type: {{ .Values.strategyType }}
selector:
matchLabels:
{{- include "plex.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "plex.selectorLabels" . | nindent 8 }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
spec:
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: pms
protocol: TCP
containerPort: 32400
{{- if .Values.hostNetwork }}
hostPort: {{ .Values.plexServiceTCP.port }}
{{- end }}
- name: plex-dlna
protocol: TCP
containerPort: 32469
- name: plex-dlna-udp
protocol: UDP
containerPort: 1900
- name: plex-gdm1
protocol: UDP
containerPort: 32410
- name: plex-gdm2
protocol: UDP
containerPort: 32412
- name: plex-gdm3
protocol: UDP
containerPort: 32413
- name: plex-gdm4
protocol: UDP
containerPort: 32414
env:
- name: TZ
value: "{{ .Values.timezone }}"
# TODO: move this to a secret?
- name: PLEX_CLAIM
value: "{{ .Values.claimToken }}"
# plex env vars
- name: PMS_INTERNAL_ADDRESS
value: http://{{ template "plex.fullname" . }}:32400
- name: PMS_IMAGE
value: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
- name: KUBE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if .Values.proxy.enabled }}
{{- if .Values.proxy.http }}
- name: "HTTP_PROXY"
value: "{{.Values.proxy.http}}"
{{- end }}
{{- if .Values.proxy.https }}
- name: "HTTPS_PROXY"
value: "{{.Values.proxy.https}}"
{{- end }}
{{- end }}
{{- if .Values.advertiseIp }}
- name: "ADVERTISE_IP"
value: "{{.Values.advertiseIp}}"
{{- end }}
{{- if .Values.allowedNetworks }}
- name: "ALLOWED_NETWORKS"
value: "{{include "joinListWithComma" .Values.allowedNetworks}}"
{{- end }}
# Extra ENV Values supplied by user
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value }}
{{- end }}
readinessProbe:
httpGet:
path: /identity
port: 32400
failureThreshold: 5
periodSeconds: 15
livenessProbe:
httpGet:
path: /identity
port: 32400
failureThreshold: 5
periodSeconds: 15
startupProbe:
httpGet:
path: /identity
port: 32400
initialDelaySeconds: 5
failureThreshold: 40
periodSeconds: 15
volumeMounts:
- name: data
mountPath: /data
- name: config
mountPath: /config
- name: transcode
mountPath: /transcode
- name: shared
mountPath: /shared
- name: shared-logs
mountPath: "/config/Library/Application Support/Plex Media Server/Logs"
{{- if .Values.gpuConfiguration }}
resources:
limits:
{{- toYaml .Values.gpuConfiguration | nindent 14 }}
{{- end }}
volumes:
- name: data
{{- if .Values.emptyDirVolumes }}
emptyDir: {}
{{- else }}
hostPath:
path: {{ template "configuredHostPathData" . }}
{{- end }}
- name: config
{{- if .Values.emptyDirVolumes }}
emptyDir: {}
{{- else }}
hostPath:
path: {{ template "configuredHostPathConfig" . }}
{{- end }}
- name: transcode
{{- if .Values.emptyDirVolumes }}
emptyDir: {}
{{- else }}
hostPath:
path: {{ template "configuredHostPathTranscode" . }}
{{- end }}
- name: shared
emptyDir: {}
- name: shared-logs
emptyDir: {}

View File

@ -0,0 +1,35 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.hostNetwork }}
name: {{ include "plex.fullname" . }}-tcp-cluster-ip
{{- else }}
name: {{ include "plex.fullname" . }}-tcp
{{- end }}
labels:
{{- include "plex.labels" . | nindent 4 }}
spec:
{{- if .Values.hostNetwork }}
type: ClusterIP
{{- else }}
type: NodePort
{{- end }}
ports:
- name: pms
port: {{ .Values.plexServiceTCP.port }}
protocol: TCP
targetPort: pms
{{- if eq .Values.hostNetwork false }}
nodePort: {{.Values.plexServiceTCP.port}}
{{- end }}
- name: http
port: 80
targetPort: pms
- name: https
port: 443
targetPort: pms
- name: plex-dlna
port: 1900
targetPort: plex-dlna
selector:
{{- include "plex.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,31 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "plex.fullname" . }}-udp
labels:
{{- include "plex.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- name: plex-dlna-udp
port: 1900
protocol: UDP
targetPort: plex-dlna-udp
- name: plex-gdm1
port: 32410
protocol: UDP
targetPort: plex-gdm1
- name: plex-gdm2
port: 32412
protocol: UDP
targetPort: plex-gdm2
- name: plex-gdm3
port: 32413
protocol: UDP
targetPort: plex-gdm3
- name: plex-gdm4
port: 32414
protocol: UDP
targetPort: plex-gdm4
selector:
{{- include "plex.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,72 @@
# Default values
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# The Image to use for PLEX
image:
repository: plexinc/pms-docker
tag: 1.20.2.3402-0fec14d92
pullPolicy: IfNotPresent
##### START --> Official PLEX container environment variables
# Override this with the plex claim token from plex.tv/claim
claimToken: ""
# Set the timezone of the plex server
timezone: "Etc/UTC"
# add your pod network subnet to the `List of IP addresses and networks that are allowed without auth`
# This will override the manual settings, so only use this if you will not need to change it manually.
# This list will be automatically converted to a command seperated string when passed to the container.
# You would specify this when using helm CLI with --set allowedNetworks="{127.0.0.1,10.54.2.0/24}"
# allowedNetworks:
# - 127.0.0.1
# - 10.54.2.0/24
# Instruct the Plex Media Server Container to Change the Configuration Directory Ownership
# Default is true, you would only need to set this if you want to disable it.
# changeConfigDirOwnership: true
# advertiseIp This variable defines the additional IPs on which the server may be be found.
# For example: http://10.1.1.23:32400.
# This adds to the list where the server advertises that it can be found.
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# advertiseIp: "http://10.1.1.23:32400"
# Set The user id of the plex user created inside the container.
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# plexUid: 1000
# Set The group id of the plex group created inside the container
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# plexGid: 1000
##### END --> Official PLEX container environment variables
# You can add as many Additional ENV variables here
# The following is the same as --set extraEnv.TMPDIR="/transcode"
# extraEnv:
# TMPDIR: /transcode
# upgrade strategy type (e.g. Recreate or RollingUpdate)
strategyType: Recreate
plexServiceTCP:
port: 32400
hostNetwork: false
transcodeHostPathEnabled: false
dataHostPathEnabled: false
configHostPathEnabled: false
proxy:
# This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover
enabled: false
# http: "http://proxy:8080"
# https: "https://proxy:8080"
# noproxy: "localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/12"
gpuConfiguration: {}
emptyDirVolumes: true

View File

@ -0,0 +1,71 @@
# Default values
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# The Image to use for PLEX
image:
repository: plexinc/pms-docker
tag: 1.20.2.3402-0fec14d92
pullPolicy: IfNotPresent
##### START --> Official PLEX container environment variables
# Override this with the plex claim token from plex.tv/claim
claimToken: ""
# Set the timezone of the plex server
timezone: "Etc/UTC"
# add your pod network subnet to the `List of IP addresses and networks that are allowed without auth`
# This will override the manual settings, so only use this if you will not need to change it manually.
# This list will be automatically converted to a command seperated string when passed to the container.
# You would specify this when using helm CLI with --set allowedNetworks="{127.0.0.1,10.54.2.0/24}"
# allowedNetworks:
# - 127.0.0.1
# - 10.54.2.0/24
# Instruct the Plex Media Server Container to Change the Configuration Directory Ownership
# Default is true, you would only need to set this if you want to disable it.
# changeConfigDirOwnership: true
# advertiseIp This variable defines the additional IPs on which the server may be be found.
# For example: http://10.1.1.23:32400.
# This adds to the list where the server advertises that it can be found.
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# advertiseIp: "http://10.1.1.23:32400"
# Set The user id of the plex user created inside the container.
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# plexUid: 1000
# Set The group id of the plex group created inside the container
# See https://hub.docker.com/r/plexinc/pms-docker/ for details
# plexGid: 1000
##### END --> Official PLEX container environment variables
# You can add as many Additional ENV variables here
# The following is the same as --set extraEnv.TMPDIR="/transcode"
# extraEnv:
# TMPDIR: /transcode
# upgrade strategy type (e.g. Recreate or RollingUpdate)
strategyType: Recreate
plexServiceTCP:
port: 32400
hostNetwork: false
transcodeHostPathEnabled: false
dataHostPathEnabled: false
configHostPathEnabled: false
proxy:
# This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover
enabled: false
# http: "http://proxy:8080"
# https: "https://proxy:8080"
# noproxy: "localhost,127.0.0.1,10.96.0.0/12,10.244.0.0/12"
gpuConfiguration: {}

3
test/plex/item.yaml Normal file
View File

@ -0,0 +1,3 @@
categories:
- entertainment
icon_url: https://www.plex.tv/wp-content/uploads/2018/01/pmp-icon-1.png