plex - migrate library (#2076)

* plex - migrate library

* temp

* add migration

* fix typo

* cleanup

* capabilties

* typo

* update version

* fix condition

* claim -> claimToken

* cleanup key in migration

* keep versions

* correct section

* token is not required

* keep default port

* typo
This commit is contained in:
Stavros Kois
2024-01-29 14:14:45 +02:00
committed by GitHub
parent 53e9136512
commit 88ba8d83af
27 changed files with 1042 additions and 588 deletions

View File

@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../../../common/2304.0.1
version: 2304.0.1
digest: sha256:1ed155c6760e1166e2cb75b52bc5e81c6bdf0252c16ff5ede001157077c41670
generated: "2023-04-24T13:41:19.019752841+03:00"
repository: file://../../../common
version: 1.2.9
digest: sha256:af1a9a1f87e3e48453c9f25f909f5ebcd7fa6e25162b7b425448ba752bcdbc5c
generated: "2024-01-24T18:30:03.937048323+02:00"

View File

@@ -1,9 +1,9 @@
name: plex
description: Plex Media Server
description: Plex is a media server that allows you to stream your media to any Plex client.
annotations:
title: Plex
type: application
version: 1.7.60
version: 2.0.0
apiVersion: v2
appVersion: 1.32.8.7639
kubeVersion: '>=1.16.0-0'
@@ -13,12 +13,13 @@ maintainers:
email: dev@ixsystems.com
dependencies:
- name: common
repository: file://../../../common/2304.0.1
version: 2304.0.1
repository: file://../../../common
version: 1.2.9
home: https://plex.tv/
icon: https://media.sys.truenas.net/apps/plex/icons/icon.png
sources:
- https://plex.tv/
- https://github.com/truenas/charts/tree/master/charts/plex
- https://hub.docker.com/r/plexinc/pms-docker/
- https://github.com/k8s-at-home/charts/tree/master/charts/plex
keywords:
- plex

View File

@@ -1,5 +1,3 @@
# Plex Media Server helm chart
# Plex
## Configuration
Please refer to questions.yaml for a detailed overview on supported configurable items.
[Plex](https://plex.tv) is a media server that allows you to stream your media to any Plex client.

View File

@@ -1,3 +1,3 @@
# Plex
Plex chart is a chart designed to deploy plex in a TrueNAS SCALE kubernetes cluster.
[Plex](https://plex.tv) is a media server that allows you to stream your media to any Plex client.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
plexNetwork:
webPort: 31000
plexID:
user: 1000
group: 1000
plexStorage:
data:
type: pvc
config:
type: pvc
transcode:
type: emptyDir
emptyDirConfig:
medium: ""
size: ""

View File

@@ -0,0 +1,18 @@
plexNetwork:
webPort: 31000
plexStorage:
data:
type: pvc
config:
type: pvc
transcode:
type: emptyDir
emptyDirConfig:
medium: ""
size: ""
additionalStorages:
- type: pvc
mountPath: /action_movies
- type: pvc
mountPath: /adventure_movies

View File

@@ -0,0 +1,14 @@
plexNetwork:
webPort: 31000
hostNetwork: true
plexStorage:
data:
type: pvc
config:
type: pvc
transcode:
type: emptyDir
emptyDirConfig:
medium: ""
size: ""

View File

@@ -1,33 +0,0 @@
appVolumeMounts:
config:
emptyDir: true
mountPath: /config
data:
emptyDir: true
mountPath: /data
shared:
emptyDir: true
mountPath: shared
shared-logs:
emptyDir: true
mountPath: /config/Library/Application Support/Plex Media Server/Logs
transcode:
emptyDir: true
mountPath: /transcode
claimToken: ''
dnsConfig:
options: []
emptyDirVolumes: true
enablePlexPass: false
environmentVariables: []
extraAppVolumeMounts:
- hostPath: /mnt/extras/hello
mountPath: /mnt/extras
readOnly: true
gpuConfiguration: {}
hostNetwork: false
plexServiceTCP:
port: 32400
timezone: Etc/UTC
updateStrategy: Recreate
global: {}

View File

@@ -9,28 +9,12 @@ capabilities:
description: Plex is able to chown files.
- name: FOWNER
description: Plex is able to bypass permission checks for it's sub-processes.
- name: SYS_CHROOT
description: Plex is able to use chroot.
- name: MKNOD
description: Plex is able to create device nodes.
- name: DAC_OVERRIDE
description: Plex is able to bypass permission checks.
- name: FSETID
description: Plex is able to set file capabilities.
- name: KILL
description: Plex is able to kill processes.
- name: SETGID
description: Plex is able to set group ID for it's sub-processes.
- name: SETUID
description: Plex is able to set user ID for it's sub-processes.
- name: SETPCAP
description: Plex is able to set process capabilities.
- name: NET_BIND_SERVICE
description: Plex is able to bind to privileged ports.
- name: SETFCAP
description: Plex is able to set file capabilities.
- name: NET_RAW
description: Plex is able to use raw sockets.
- name: AUDIT_WRITE
description: Plex is able to write to audit log.
- name: KILL
description: Plex is able to kill processes.
hostMounts: []

View File

@@ -0,0 +1,100 @@
#!/usr/bin/python3
import json
import os
import sys
def migrate_volume(volume):
return {
'type': 'hostPath',
'hostPathConfig': {
'hostPath': volume['hostPath']
},
} if volume.get('hostPathEnabled', False) else {
'type': 'ixVolume',
'ixVolumeConfig': {
'datasetName': volume['datasetName'],
},
}
def migrate_common_lib(values):
delete_keys = [
'hostNetwork', 'plexServiceTCP', 'updateStrategy', 'timezone', 'claimToken',
'environmentVariables', 'gpuConfiguration', 'enableResourceLimits', 'cpuLimit',
'memLimit', 'dnsConfig', 'extraAppVolumeMounts', 'appVolumeMounts', 'enablePlexPass'
]
values.update({
# Migrate Network
'plexNetwork': {
'webPort': values['plexServiceTCP']['port'],
'hostNetwork': values['hostNetwork'],
},
# Migrate Resources
'resources': {
'limits': {
'cpu': values.get('cpuLimit', '4000m'),
'memory': values.get('memLimit', '8Gi'),
}
},
# Migrate DNS
'podOptions': {
'dnsConfig': {
'options': [
{'name': opt['name'], 'value': opt['value']}
for opt in values.get('dnsConfig', {}).get('options', [])
]
}
},
# Migrate ID
'plexID': {
# We didn't have exposed this on UI the default
# set by the container is 1000, so we will use that
'user': 1000,
'group': 1000,
},
# Migrate Config
'TZ': values['timezone'],
'plexConfig': {
'imageSelector': 'plexPassImage' if values['enablePlexPass'] else 'image',
'claimToken': values['claimToken'],
'additionalEnvs': values.get('environmentVariables', []),
},
'plexGPU': values.get('gpuConfiguration', {}),
# Migrate Storage
'plexStorage': {
'config': migrate_volume(values['appVolumeMounts']['config']),
'data': migrate_volume(values['appVolumeMounts']['data']),
'transcode': migrate_volume(values['appVolumeMounts']['transcode']),
'additionalStorages': [
{
'type': 'hostPath',
'hostPathConfig': {'hostPath': e['hostPath']},
'mountPath': e['mountPath'],
'readOnly': e['readOnly'],
}
for e in values.get('extraAppVolumeMounts', [])
],
},
})
for k in delete_keys:
values.pop(k, None)
return values
def migrate(values):
# If this missing, we have already migrated
if not 'appVolumeMounts' in values.keys():
return values
return migrate_common_lib(values)
if __name__ == '__main__':
if len(sys.argv) != 2:
exit(1)
if os.path.exists(sys.argv[1]):
with open(sys.argv[1], 'r') as f:
print(json.dumps(migrate(json.loads(f.read()))))

View File

@@ -1,34 +0,0 @@
#!/usr/bin/python3
import json
import os
import sys
def migrate(values):
values.update({
'appVolumeMounts': {
'transcode': {
'hostPathEnabled': values['transcodeHostPathEnabled'],
**({'hostPath': values['transcodeHostPath']} if values.get('transcodeHostPath') else {})
},
'config': {
'hostPathEnabled': values['configHostPathEnabled'],
**({'hostPath': values['configHostPath']} if values.get('configHostPath') else {})
},
'data': {
'hostPathEnabled': values['dataHostPathEnabled'],
**({'hostPath': values['dataHostPath']} if values.get('dataHostPath') else {})
},
},
'updateStrategy': values.get('strategyType', 'Recreate'),
})
return values
if __name__ == '__main__':
if len(sys.argv) != 2:
exit(1)
if os.path.exists(sys.argv[1]):
with open(sys.argv[1], 'r') as f:
print(json.dumps(migrate(json.loads(f.read()))))

View File

@@ -1,361 +1,632 @@
groups:
- name: "Plex Configuration"
description: "Configure plex deployment"
- name: "Networking"
description: "Configure networking for container"
- name: "Storage"
description: "Persist and share data that is separate from the lifecycle of the container"
- 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"
- name: "Advanced DNS Settings"
description: "Configure DNS settings"
- name: "Resource Limits"
description: "Set CPU/memory limits for Kubernetes Pod"
- name: Plex Configuration
description: Configure Plex
- name: User and Group Configuration
description: Configure User and Group for Plex
- name: Advanced Pod Configuration
description: Configure Advanced Pod Options for Plex
- name: Network Configuration
description: Configure Network for Plex
- name: Storage Configuration
description: Configure Storage for Plex
- name: Resources Configuration
description: Configure Resources for Plex
portals:
web_portal:
protocols:
- "http"
- "$kubernetes-resource_configmap_portal_protocol"
host:
- "$node_ip"
- "$kubernetes-resource_configmap_portal_host"
ports:
- "$variable-plexServiceTCP.port"
path: "/web"
- "$kubernetes-resource_configmap_portal_port"
path: "$kubernetes-resource_configmap_portal_path"
questions:
- variable: enablePlexPass
label: "Use PlexPass"
group: "Plex Configuration"
- variable: TZ
group: Plex Configuration
label: Timezone
schema:
type: boolean
default: false
- variable: dnsConfig
label: "DNS Configuration"
group: "Advanced DNS Settings"
type: string
default: Etc/UTC
required: true
$ref:
- definitions/timezone
- variable: plexConfig
label: ""
group: Plex Configuration
schema:
type: dict
attrs:
- variable: options
label: "DNS Options"
- variable: claimToken
label: Claim Token
description: |
The claim token for the server to obtain a real server token.
If not provided, server is will not be automatically logged in.
If server is already logged in, this parameter is ignored.
You can obtain a claim token to login your server to your plex account
by visiting https://www.plex.tv/claim.
schema:
type: string
default: ""
private: true
- variable: imageSelector
label: Image
description: |
The image to use for Plex.
schema:
type: string
default: "image"
required: true
enum:
- value: "image"
description: Plex Official Image
- value: "plexPassImage"
description: Plex Pass Image
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Plex.
schema:
type: list
default: []
items:
- variable: optionsEntry
label: "Option Entry Configuration"
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: "Option Name"
label: Name
schema:
type: string
required: true
- variable: value
label: "Option Value"
label: Value
schema:
type: string
required: true
- variable: claimToken
label: "Plex Claim Token"
group: "Plex Configuration"
description: "The claim token for the server to obtain a real server token. If not provided, server is will not be automatically logged in. If server is already logged in, this parameter is ignored. You can obtain a claim token to login your server to your plex account by visiting https://www.plex.tv/claim."
schema:
type: string
default: ""
- variable: hostNetwork
label: "Configure Host Network"
group: "Networking"
schema:
type: boolean
default: false
- variable: environmentVariables
label: "Environment Variables for Plex"
group: "Plex Configuration"
schema:
type: list
default: []
items:
- variable: environmentVariable
label: "Environment Variable"
schema:
type: dict
attrs:
- variable: name
label: "Name"
schema:
type: string
- variable: value
label: "Value"
schema:
type: string
- variable: timezone
label: "Plex container timezone"
group: "Plex Configuration"
schema:
type: string
default: "Etc/UTC"
$ref:
- "definitions/timezone"
# Update strategy
- variable: updateStrategy
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"
- variable: plexID
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: port
label: "Port to expose for Plex UI"
- variable: user
label: User ID
description: The user id that Plex files will be owned by.
schema:
type: int
min: 568
default: 568
required: true
- variable: group
label: Group ID
description: The group id that Plex files will be owned by.
schema:
type: int
min: 568
default: 568
required: true
- variable: podOptions
label: ""
group: Advanced Pod Configuration
schema:
type: dict
attrs:
- variable: dnsConfig
label: Advanced DNS Configuration
schema:
type: dict
attrs:
- variable: options
label: DNS Options
schema:
type: list
items:
- variable: optionsEntry
label: DNS Option Entry
schema:
type: dict
attrs:
- variable: name
label: Option Name
schema:
type: string
required: true
- variable: value
label: Option Value
schema:
type: string
required: true
- variable: plexNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: webPort
label: WebUI Port
description: The port for Plex WebUI
schema:
type: int
default: 32400
min: 9000
max: 65535
default: 32400
required: true
- variable: hostNetwork
label: Host Network
description: |
Bind to the host network. It's recommended to keep this disabled.
schema:
type: boolean
default: false
# Specify GPU configuration
- variable: gpuConfiguration
label: "GPU Configuration"
group: "Resource Reservation"
- variable: plexStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: data
label: Plex Data Storage
description: The path to store Plex Data.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
immutable: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
hidden: true
default: "data"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: hostPathConfig
label: Host Path Configuration
schema:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: config
label: Plex Configuration Storage
description: The path to store Plex Configuration.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
immutable: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
hidden: true
default: "config"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: hostPathConfig
label: Host Path Configuration
schema:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: transcode
label: Plex Transcode Storage
description: The path to store Plex Transcode.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.</br>
emptyDir: Is a temporary directory that will be created on the disk or in memory.
schema:
type: string
required: true
immutable: true
default: "ixVolume"
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- value: "emptyDir"
description: emptyDir (Temporary directory created on the disk or in memory)
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
hidden: true
default: "transcode"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: emptyDirConfig
label: emptyDir Configuration
schema:
type: dict
show_if: [["type", "=", "emptyDir"]]
attrs:
- variable: medium
label: emptyDir Medium
description: |
Disk: Creates a temporary directory on the disk.</br>
Memory: Creates a temporary directory in memory.
schema:
type: string
default: ""
enum:
- value: ""
description: Disk (Temporary directory created on the disk)
- value: "Memory"
description: Memory (Temporary directory created in memory)
- variable: size
label: emptyDir Size Limit (in Gi)
description: |
The maximum size (in Gi) of the temporary directory.</br>
For example: 2
schema:
type: int
"null": true
default: 2
- variable: hostPathConfig
label: Host Path Configuration
schema:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: additionalStorages
label: Additional Storage
description: Additional storage for Plex.
schema:
type: list
default: []
items:
- variable: storageEntry
label: Storage Entry
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.</br>
SMB Share: Is a SMB share that is mounted to a persistent volume claim.
schema:
type: string
required: true
default: "ixVolume"
immutable: true
enum:
- value: "hostPath"
description: Host Path (Path that already exists on the system)
- value: "ixVolume"
description: ixVolume (Dataset created automatically by the system)
- value: "smb-pv-pvc"
description: SMB Share (Mounts a persistent volume claim to a SMB share)
- variable: readOnly
label: Read Only
description: Mount the volume as read only.
schema:
type: boolean
default: false
- variable: mountPath
label: Mount Path
description: The path inside the container to mount the storage.
schema:
type: path
required: true
- variable: hostPathConfig
label: Host Path Configuration
schema:
type: dict
show_if: [["type", "=", "hostPath"]]
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: acl
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
$ref:
- "normalize/acl"
- variable: hostPath
label: Host Path
description: The host path to use for storage.
schema:
type: hostpath
show_if: [["aclEnable", "=", false]]
required: true
- variable: ixVolumeConfig
label: ixVolume Configuration
description: The configuration for the ixVolume dataset.
schema:
type: dict
show_if: [["type", "=", "ixVolume"]]
$ref:
- "normalize/ixVolume"
attrs:
- variable: aclEnable
label: Enable ACL
description: Enable ACL for the dataset.
schema:
type: boolean
default: false
- variable: datasetName
label: Dataset Name
description: The name of the dataset to use for storage.
schema:
type: string
required: true
immutable: true
default: "storage_entry"
- variable: aclEntries
label: ACL Configuration
schema:
type: dict
show_if: [["aclEnable", "=", true]]
attrs: []
- variable: smbConfig
label: SMB Share Configuration
description: The configuration for the SMB Share.
schema:
type: dict
show_if: [["type", "=", "smb-pv-pvc"]]
attrs:
- variable: server
label: Server
description: The server for the SMB share.
schema:
type: string
required: true
- variable: share
label: Share
description: The share name for the SMB share.
schema:
type: string
required: true
- variable: domain
label: Domain (Optional)
description: The domain for the SMB share.
schema:
type: string
- variable: username
label: Username
description: The username for the SMB share.
schema:
type: string
required: true
- variable: password
label: Password
description: The password for the SMB share.
schema:
type: string
required: true
private: true
- variable: size
label: Size (in Gi)
description: The size of the volume quota.
schema:
type: int
required: true
min: 1
default: 1
- variable: resources
label: Resources Configuration
group: Resources Configuration
schema:
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: cpu
label: CPU
description: CPU limit for Plex.
schema:
type: string
max_length: 6
valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$'
valid_chars_error: |
Valid CPU limit formats are</br>
- Plain Integer - eg. 1</br>
- Float - eg. 0.5</br>
- Milicpu - eg. 500m
default: "4000m"
required: true
- variable: memory
label: Memory
description: Memory limit for Plex.
schema:
type: string
max_length: 12
valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$'
valid_chars_error: |
Valid Memory limit formats are</br>
- Suffixed with E/P/T/G/M/K - eg. 1G</br>
- Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
- Plain Integer in bytes - eg. 1024</br>
- Exponent - eg. 134e6
default: "8Gi"
required: true
- variable: plexGPU
group: Resources Configuration
label: GPU Configuration
schema:
type: dict
$ref:
- "definitions/gpuConfiguration"
attrs: []
- variable: appVolumeMounts
label: "Plex Storage"
group: "Storage"
schema:
type: dict
attrs:
- variable: transcode
label: "Transcode Volume"
schema:
type: dict
attrs:
- variable: datasetName
label: "Plex Transcode Volume Name"
schema:
type: string
$ref:
- "normalize/ixVolume"
show_if: [["hostPathEnabled", "=", false]]
default: "ix-plex_transcode"
hidden: true
editable: false
- variable: mountPath
label: "Plex Transcode Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
hidden: true
editable: false
default: "/transcode"
- variable: hostPathEnabled
label: "Enable Host Path for Plex Transcode Volume"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Host Path for Plex Transcode Volume"
schema:
type: hostpath
required: true
$ref:
- "validations/lockedHostPath"
- variable: data
label: "Data Volume"
schema:
type: dict
attrs:
- variable: datasetName
label: "Plex Data Volume Name"
schema:
type: string
$ref:
- "normalize/ixVolume"
show_if: [["hostPathEnabled", "=", false]]
default: "ix-plex_data"
editable: false
hidden: true
- variable: mountPath
label: "Plex Data Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
hidden: true
editable: false
default: "/data"
- variable: hostPathEnabled
label: "Enable Host Path for Plex Data Volume"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Host Path for Plex Data Volume"
schema:
type: hostpath
required: true
$ref:
- "validations/lockedHostPath"
- variable: config
label: "Config Volume"
schema:
type: dict
attrs:
- variable: datasetName
label: "Plex Config Volume Name"
schema:
type: string
$ref:
- "normalize/ixVolume"
show_if: [["hostPathEnabled", "=", false]]
default: "ix-plex_config"
editable: false
hidden: true
- variable: mountPath
label: "Plex Config Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
hidden: true
default: "/config"
- variable: hostPathEnabled
label: "Enable Host Path for Plex Config Volume"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: hostPath
label: "Host Path for Plex Config Volume"
schema:
type: hostpath
required: true
$ref:
- "validations/lockedHostPath"
- variable: shared
label: "Shared Volume"
schema:
type: dict
hidden: true
attrs:
- variable: emptyDir
label: "Temporary Volume"
schema:
type: boolean
default: true
editable: false
- variable: mountPath
label: "Plex Shared Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
default: "/shared"
- variable: shared-logs
label: "Shared Logs Volume"
schema:
type: dict
hidden: true
attrs:
- variable: emptyDir
label: "Temporary Volume"
schema:
type: boolean
default: true
editable: false
- variable: mountPath
label: "Plex Shared Logs Mount Path"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
editable: false
default: "/config/Library/Application Support/Plex Media Server/Logs"
- variable: extraAppVolumeMounts
label: "Plex Extra Host Path Volumes"
group: "Storage"
schema:
type: list
items:
- variable: extraAppVolume
label: "Plex Host Path Volume"
description: "Add an extra host path volume for plex application"
schema:
type: dict
attrs:
- variable: mountPath
label: "Mount Path in Pod"
description: "Path where the volume will be mounted inside the pod"
schema:
type: path
required: true
- variable: hostPath
label: "Host Path"
description: "Host path"
schema:
type: hostpath
required: true
$ref:
- "validations/lockedHostPath"
- variable: readOnly
label: "Read Only"
description: "Mount hostpath in read-only mode"
schema:
type: boolean
default: false
- variable: enableResourceLimits
label: "Enable Pod resource limits"
group: "Resource Limits"
schema:
type: boolean
default: false
- variable: cpuLimit
label: "CPU Limit"
description: "CPU resource limit allow plain integer values with suffix m(milli) e.g 1000m, 100."
group: "Resource Limits"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^\\d+(?:\\.\\d+(?!.*m$)|m?$)"
default: "4000m"
- variable: memLimit
label: "Memory Limit"
group: "Resource Limits"
description: "Memory limits is specified by number of bytes. Followed by quantity suffix like E,P,T,G,M,k and Ei,Pi,Ti,Mi,Gi,Ki can also be used. e.g 129e6, 129M, 128974848000m, 123Mi"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
default: "8Gi"

View File

@@ -1,3 +1 @@
1. Get the application URL by running these commands:
http://$node_ip:{{ .Values.plexServiceTCP.port }}/
{{ include "ix.v1.common.lib.chart.notes" $ }}

View File

@@ -0,0 +1,35 @@
{{- define "plex.get-versions" -}}
{{- $oldChartVersion := "" -}}
{{- $newChartVersion := "" -}}
{{/* Safely access the context, so it wont block CI */}}
{{- if hasKey .Values.global "ixChartContext" -}}
{{- if .Values.global.ixChartContext.upgradeMetadata -}}
{{- $oldChartVersion = .Values.global.ixChartContext.upgradeMetadata.oldChartVersion -}}
{{- $newChartVersion = .Values.global.ixChartContext.upgradeMetadata.newChartVersion -}}
{{- if and (not $oldChartVersion) (not $newChartVersion) -}}
{{- fail "Upgrade Metadata is missing. Cannot proceed" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "old" $oldChartVersion "new" $newChartVersion) -}}
{{- end -}}
{{- define "plex.migration" -}}
{{- $versions := (fromYaml (include "plex.get-versions" $)) -}}
{{- if and $versions.old $versions.new -}}
{{- $oldV := semver $versions.old -}}
{{- $newV := semver $versions.new -}}
{{/* If new is v2.x.x */}}
{{- if eq ($newV.Major | int) 2 -}}
{{/* And old is v1.x.x, but lower than .7.60 */}}
{{- if and (eq $oldV.Major 1) (or (ne $oldV.Minor 7) (lt ($oldV.Patch | int) 60)) -}}
{{/* Block the upgrade */}}
{{- fail "Migration to 2.x.x is only allowed from 1.7.60 or higher" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,54 @@
{{- define "plex.persistence" -}}
persistence:
data:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.plexStorage.data) | nindent 4 }}
targetSelector:
plex:
plex:
mountPath: /data
config:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.plexStorage.config) | nindent 4 }}
targetSelector:
plex:
plex:
mountPath: /config
transcode:
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.plexStorage.transcode) | nindent 4 }}
targetSelector:
plex:
plex:
mountPath: /transcode
shared:
enabled: true
type: emptyDir
targetSelector:
plex:
plex:
mountPath: /shared
logs:
enabled: true
type: emptyDir
targetSelector:
plex:
plex:
mountPath: "/config/Library/Application Support/Plex Media Server/Logs"
tmp:
enabled: true
type: emptyDir
targetSelector:
plex:
plex:
mountPath: /tmp
{{- range $idx, $storage := .Values.plexStorage.additionalStorages }}
{{ printf "plex-%v:" (int $idx) }}
enabled: true
{{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
targetSelector:
plex:
plex:
mountPath: {{ $storage.mountPath }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,66 @@
{{- define "plex.workload" -}}
workload:
plex:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.plexNetwork.hostNetwork }}
securityContext:
fsGroup: {{ .Values.plexID.group }}
containers:
plex:
enabled: true
primary: true
imageSelector: {{ .Values.plexConfig.imageSelector }}
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
capabilities:
add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
- SETGID
- SETUID
- KILL
env:
PLEX_CLAIM: {{ .Values.plexConfig.claimToken }}
PLEX_UID: {{ .Values.plexID.user }}
PLEX_GID: {{ .Values.plexID.group }}
fixedEnv:
PUID: {{ .Values.plexID.user }}
{{ with .Values.plexConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: tcp
port: 32400
readiness:
enabled: true
type: tcp
port: 32400
startup:
enabled: true
type: tcp
port: 32400
{{ with .Values.plexGPU }}
scaleGPU:
{{ range $key, $value := . }}
- gpu:
{{ $key }}: {{ $value }}
targetSelector:
plex:
- plex
{{ end }}
{{ end }}
{{- end -}}

View File

@@ -0,0 +1,16 @@
{{- define "plex.portal" -}}
{{- $port := .Values.plexNetwork.webPort -}}
{{- if .Values.plexNetwork.hostNetwork -}}
{{- $port = 32400 -}}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: portal
data:
port: {{ $port | quote }}
path: "/"
protocol: "http"
host: $node_ip
{{- end -}}

View File

@@ -0,0 +1,61 @@
{{- define "plex.service" -}}
service:
plex:
enabled: true
primary: true
type: NodePort
targetSelector: plex
ports:
webui:
enabled: true
primary: true
port: {{ .Values.plexNetwork.webPort }}
nodePort: {{ .Values.plexNetwork.webPort }}
targetPort: 32400
targetSelector: plex
discovery:
enabled: true
# This service is added only to provide
# a way for in-cluster apps to discovery plex
# For LAN discovery, host networking is required
type: ClusterIP
targetSelector: plex
ports:
dlna-tcp:
enabled: true
primary: true
port: 32469
targetPort: 32469
protocol: tcp
targetSelector: plex
dlna-udp:
enabled: true
port: 1900
targetPort: 1900
protocol: udp
targetSelector: plex
gdm1:
enabled: true
port: 32410
targetPort: 32410
protocol: udp
targetSelector: plex
gdm2:
enabled: true
port: 32412
targetPort: 32412
protocol: udp
targetSelector: plex
gdm3:
enabled: true
port: 32413
targetPort: 32413
protocol: udp
targetSelector: plex
gdm4:
enabled: true
port: 32414
targetPort: 32414
protocol: udp
targetSelector: plex
{{- end -}}

View File

@@ -0,0 +1,13 @@
{{- include "ix.v1.common.loader.init" . -}}
{{- include "plex.migration" $ -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "plex.workload" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "plex.service" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "plex.persistence" $ | fromYaml) -}}
{{/* Create the configmap for portal manually*/}}
{{- include "plex.portal" $ -}}
{{- include "ix.v1.common.loader.apply" . -}}

View File

@@ -1,140 +0,0 @@
{{ include "common.storage.hostPathValidate" .Values }}
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}-plex
labels:
app.kubernetes.io/name: {{ template "common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
replicas: {{ (default 1 .Values.replicas) }}
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: {{ template "common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template: {{ include "common.deployment.pod.metadata" . | nindent 4 }}
spec:
hostNetwork: {{ .Values.hostNetwork }}
{{- if .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
hostname: {{ template "common.names.fullname" . }}
{{- if hasKey .Values "global" }}
{{- if hasKey .Values.global "ixChartContext" }}
{{- if .Values.global.ixChartContext.addNvidiaRuntimeClass }}
runtimeClassName: {{ .Values.global.ixChartContext.nvidiaRuntimeClassName }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{ include "common.resources.limitation" . | nindent 10 }}
{{ if .Values.enablePlexPass }}
{{ include "common.containers.imageConfig" .Values.plexpassImage | nindent 10 }}
{{ else }}
{{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
{{ end }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
mountPath: {{ $hostPathConfiguration.mountPath }}
{{ if $hostPathConfiguration.readOnly }}
readOnly: {{ $hostPathConfiguration.readOnly }}
{{ end }}
{{ end }}
ports:
- name: pms
protocol: TCP
containerPort: 32400
{{- if .Values.hostNetwork }}
hostPort: {{ .Values.plexServiceTCP.port }}
{{- else }}
hostPort: null
{{- end }}
- name: plex-dlna
protocol: TCP
containerPort: 32469
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
- name: plex-dlna-udp
protocol: UDP
containerPort: 1900
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
- name: plex-gdm1
protocol: UDP
containerPort: 32410
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
- name: plex-gdm2
protocol: UDP
containerPort: 32412
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
- name: plex-gdm3
protocol: UDP
containerPort: 32413
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
- name: plex-gdm4
protocol: UDP
containerPort: 32414
{{- if not .Values.hostNetwork }}
hostPort: null
{{- end }}
env:
- name: KUBE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
{{ $envList := (default list .Values.environmentVariables) }}
{{ if and .Values.gpuConfiguration (hasKey .Values.gpuConfiguration "nvidia.com/gpu") (gt (get .Values.gpuConfiguration "nvidia.com/gpu" | toDecimal) 0) }}
{{ $envList = mustAppend $envList (dict "name" "NVIDIA_DRIVER_CAPABILITIES" "value" "all") }}
{{ end }}
{{ $envList = mustAppend $envList (dict "name" "TZ" "value" .Values.timezone) }}
{{ $envList = mustAppend $envList (dict "name" "PLEX_CLAIM" "value" .Values.claimToken) }}
{{ $envList = mustAppend $envList (dict "name" "PMS_INTERNAL_ADDRESS" "value" (printf "http://%s:32400" (include "common.names.fullname" .))) }}
{{ $envList = mustAppend $envList (dict "name" "PMS_IMAGE" "value" (printf "%s:%s" .Values.image.repository .Values.image.tag))}}
{{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }}
readinessProbe:
tcpSocket:
port: 32400
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 2
livenessProbe:
tcpSocket:
port: 32400
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 1
startupProbe:
tcpSocket:
port: 32400
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 60
successThreshold: 1
{{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
hostPath:
path: {{ $hostPathConfiguration.hostPath }}
{{ end }}

View File

@@ -1,16 +0,0 @@
{{ $svc := .Values.plexServiceTCP }}
{{ $ports := list }}
{{ $ports = mustAppend $ports (dict "name" "pms" "port" $svc.port "nodePort" $svc.port "targetPort" "pms") }}
{{ $ports = mustAppend $ports (dict "name" "http" "port" 80 "targetPort" "pms") }}
{{ $ports = mustAppend $ports (dict "name" "https" "port" 443 "targetPort" "pms") }}
{{ $ports = mustAppend $ports (dict "name" "plex-dlna" "port" 1900 "targetPort" "plex-dlna") }}
{{ $params := . }}
{{ $_ := set $params "commonService" (dict "ports" $ports ) }}
{{ if .Values.hostNetwork }}
{{ $_ := set $params.commonService "nameSuffix" "tcp-cluster-ip" }}
{{ $_1 := set $params.commonService "type" "ClusterIP" }}
{{ else }}
{{ $_ := set $params.commonService "nameSuffix" "tcp" }}
{{ $_1 := set $params.commonService "type" "NodePort" }}
{{ end }}
{{ include "common.classes.service" $params }}

View File

@@ -1,9 +0,0 @@
{{ $ports := list }}
{{ $ports = mustAppend $ports (dict "name" "plex-dlna-udp" "port" 1900 "protocol" "UDP" "targetPort" "plex-dlna-udp") }}
{{ $ports = mustAppend $ports (dict "name" "plex-gdm1" "port" 32410 "protocol" "UDP" "targetPort" "plex-gdm1") }}
{{ $ports = mustAppend $ports (dict "name" "plex-gdm2" "port" 32412 "protocol" "UDP" "targetPort" "plex-gdm2") }}
{{ $ports = mustAppend $ports (dict "name" "plex-gdm3" "port" 32413 "protocol" "UDP" "targetPort" "plex-gdm3") }}
{{ $ports = mustAppend $ports (dict "name" "plex-gdm4" "port" 32414 "protocol" "UDP" "targetPort" "plex-gdm4") }}
{{ $params := . }}
{{ $_ := set $params "commonService" (dict "type" "ClusterIP" "ports" $ports "nameSuffix" "udp" ) }}
{{ include "common.classes.service" $params }}

View File

@@ -0,0 +1,4 @@
# 1.7.60
This version is kept because it contains a fix that is needed for migration to v2.x.x
It should be safe to remove few months after v2.x.x is released.

View File

@@ -0,0 +1 @@
- 1.7.60

View File

@@ -2,7 +2,42 @@ image:
pullPolicy: IfNotPresent
repository: plexinc/pms-docker
tag: 1.32.8.7639-fb6452ebf
plexpassImage:
plexPassImage:
pullPolicy: IfNotPresent
repository: plexinc/pms-docker
tag: plexpass
resources:
limits:
cpu: 4000m
memory: 8Gi
plexID:
user: 568
group: 568
plexConfig:
imageSelector: image
claimToken: ''
additionalEnvs: []
plexNetwork:
webPort: 30003
hostNetwork: false
plexStorage:
data:
type: ixVolume
ixVolumeConfig:
datasetName: data
config:
type: ixVolume
ixVolumeConfig:
datasetName: config
transcode:
type: ixVolume
ixVolumeConfig:
datasetName: transcode
additionalStorages: []
plexGPU: {}