diff --git a/library/ix-dev/charts/emby/Chart.lock b/library/ix-dev/charts/emby/Chart.lock index e877367d2c..85a4574775 100644 --- a/library/ix-dev/charts/emby/Chart.lock +++ b/library/ix-dev/charts/emby/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: common - repository: file://../../../common/2304.0.1 - version: 2304.0.1 -digest: sha256:1ed155c6760e1166e2cb75b52bc5e81c6bdf0252c16ff5ede001157077c41670 -generated: "2023-04-24T13:39:27.652206102+03:00" + repository: file://../../../common + version: 1.2.9 +digest: sha256:af1a9a1f87e3e48453c9f25f909f5ebcd7fa6e25162b7b425448ba752bcdbc5c +generated: "2024-01-22T16:49:24.448208256+02:00" diff --git a/library/ix-dev/charts/emby/Chart.yaml b/library/ix-dev/charts/emby/Chart.yaml index cb0b2d324d..afef4294b8 100644 --- a/library/ix-dev/charts/emby/Chart.yaml +++ b/library/ix-dev/charts/emby/Chart.yaml @@ -1,9 +1,9 @@ name: emby -description: Emby Server +description: Emby is designed to help you manage your personal media library, such as home videos and photos annotations: title: Emby Server type: application -version: 1.0.30 +version: 2.0.0 apiVersion: v2 appVersion: 4.7.14.0 kubeVersion: '>=1.16.0-0' @@ -13,8 +13,8 @@ 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://emby.media/ icon: https://media.sys.truenas.net/apps/emby/icons/icon.png sources: diff --git a/library/ix-dev/charts/emby/README.md b/library/ix-dev/charts/emby/README.md index 3f1c5438ab..680e4bdd23 100644 --- a/library/ix-dev/charts/emby/README.md +++ b/library/ix-dev/charts/emby/README.md @@ -1,5 +1,3 @@ -# Emby Server helm chart +# Emby -## Configuration - -Please refer to questions.yaml for a detailed overview on supported configurable items. +[Emby](https://emby.media/) is designed to help you manage your personal media library, such as home videos and photos diff --git a/library/ix-dev/charts/emby/app-readme.md b/library/ix-dev/charts/emby/app-readme.md index e9a7916971..680e4bdd23 100644 --- a/library/ix-dev/charts/emby/app-readme.md +++ b/library/ix-dev/charts/emby/app-readme.md @@ -1,3 +1,3 @@ -# Emby Server +# Emby -Emby Server is a personal media server with apps on just about every device +[Emby](https://emby.media/) is designed to help you manage your personal media library, such as home videos and photos diff --git a/library/ix-dev/charts/emby/charts/common-1.2.9.tgz b/library/ix-dev/charts/emby/charts/common-1.2.9.tgz new file mode 100644 index 0000000000..cf131132de Binary files /dev/null and b/library/ix-dev/charts/emby/charts/common-1.2.9.tgz differ diff --git a/library/ix-dev/charts/emby/charts/common-2304.0.1.tgz b/library/ix-dev/charts/emby/charts/common-2304.0.1.tgz deleted file mode 100644 index 32f9fc2290..0000000000 Binary files a/library/ix-dev/charts/emby/charts/common-2304.0.1.tgz and /dev/null differ diff --git a/library/ix-dev/charts/emby/ci/basic-values.yaml b/library/ix-dev/charts/emby/ci/basic-values.yaml new file mode 100644 index 0000000000..2eb3654848 --- /dev/null +++ b/library/ix-dev/charts/emby/ci/basic-values.yaml @@ -0,0 +1,10 @@ +embyNetwork: + webPort: 31000 + +embyID: + user: 1000 + group: 1000 + +embyStorage: + config: + type: pvc diff --git a/library/ix-dev/charts/emby/ci/extra-values.yaml b/library/ix-dev/charts/emby/ci/extra-values.yaml new file mode 100644 index 0000000000..8fd4060a87 --- /dev/null +++ b/library/ix-dev/charts/emby/ci/extra-values.yaml @@ -0,0 +1,11 @@ +embyNetwork: + webPort: 31000 + +embyStorage: + config: + type: pvc + additionalStorages: + - type: pvc + mountPath: /action_movies + - type: pvc + mountPath: /adventure_movies diff --git a/library/ix-dev/charts/emby/ci/hostNet-values.yaml b/library/ix-dev/charts/emby/ci/hostNet-values.yaml new file mode 100644 index 0000000000..05c8b76fc0 --- /dev/null +++ b/library/ix-dev/charts/emby/ci/hostNet-values.yaml @@ -0,0 +1,7 @@ +embyNetwork: + webPort: 31000 + hostNetwork: true + +embyStorage: + config: + type: pvc diff --git a/library/ix-dev/charts/emby/ci/test-values.yaml b/library/ix-dev/charts/emby/ci/test-values.yaml deleted file mode 100644 index 623a1daca3..0000000000 --- a/library/ix-dev/charts/emby/ci/test-values.yaml +++ /dev/null @@ -1,16 +0,0 @@ -appVolumeMounts: - config: - emptyDir: true - mountPath: /config -embyServerHttp: - port: 32496 -emptyDirVolumes: true -environmentVariables: [] -extraAppVolumeMounts: -- hostPath: /mnt/extras/something - mountPath: /mnt/extras - readOnly: true -gpuConfiguration: {} -hostNetwork: false -updateStrategy: Recreate -global: {} diff --git a/library/ix-dev/charts/emby/metadata.yaml b/library/ix-dev/charts/emby/metadata.yaml index 90a0701358..61276c0fdc 100644 --- a/library/ix-dev/charts/emby/metadata.yaml +++ b/library/ix-dev/charts/emby/metadata.yaml @@ -7,30 +7,12 @@ runAsContext: capabilities: - name: CHOWN description: Emby is able to chown files. - - name: FOWNER - description: Emby is able to bypass permission checks for it's sub-processes. - - name: SYS_CHROOT - description: Emby is able to use chroot. - - name: MKNOD - description: Emby is able to create device nodes. - name: DAC_OVERRIDE description: Emby is able to bypass permission checks. - - name: FSETID - description: Emby is able to set file capabilities. - - name: KILL - description: Emby is able to kill processes. + - name: FOWNER + description: Emby is able to bypass permission checks for it's sub-processes. - name: SETGID description: Emby is able to set group ID for it's sub-processes. - name: SETUID description: Emby is able to set user ID for it's sub-processes. - - name: SETPCAP - description: Emby is able to set process capabilities. - - name: NET_BIND_SERVICE - description: Emby is able to bind to privileged ports. - - name: SETFCAP - description: Emby is able to set file capabilities. - - name: NET_RAW - description: Emby is able to use raw sockets. - - name: AUDIT_WRITE - description: Emby is able to write to audit log. hostMounts: [] diff --git a/library/ix-dev/charts/emby/migrations/migrate b/library/ix-dev/charts/emby/migrations/migrate new file mode 100755 index 0000000000..9b0d6843d7 --- /dev/null +++ b/library/ix-dev/charts/emby/migrations/migrate @@ -0,0 +1,82 @@ +#!/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', 'environmentVariables', 'updateStrategy', 'embyServerHttp', 'gpuConfiguration', + 'appVolumeMounts', 'extraAppVolumeMounts', 'enableResourceLimits', 'cpuLimit', 'memLimit' + ] + + values.update({ + # Migrate Network + 'embyNetwork': { + 'webPort': values['embyServerHttp'], + 'hostNetwork': values['hostNetwork'], + }, + # Migrate Resources + 'resources': { + 'limits': { + 'cpu': values.get('cpuLimit', '4000m'), + 'memory': values.get('memLimit', '8Gi'), + } + }, + 'embyID': { + # We didn't have exposed this on UI the default + # set by the container is 2, so we will use that + 'user': 2, + 'group': 2, + }, + # Migrate Config + 'embyConfig': { + 'additionalEnvs': values.get('environmentVariables', []), + }, + # Migrate Storage + 'embyStorage': { + 'config': migrate_volume(values['appVolumeMounts']['config']), + '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())))) diff --git a/library/ix-dev/charts/emby/questions.yaml b/library/ix-dev/charts/emby/questions.yaml index fa860589b4..afacdb7239 100644 --- a/library/ix-dev/charts/emby/questions.yaml +++ b/library/ix-dev/charts/emby/questions.yaml @@ -1,194 +1,378 @@ groups: - - name: "Emby Server Configuration" - description: "Configure Emby Server" - - 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: "Resource Limits" - description: "Set CPU/memory limits for Kubernetes Pod" + - name: Emby Configuration + description: Configure Emby + - name: User and Group Configuration + description: Configure User and Group for Emby + - name: Network Configuration + description: Configure Network for Emby + - name: Storage Configuration + description: Configure Storage for Emby + - name: Resources Configuration + description: Configure Resources for Emby portals: web_portal: protocols: - - "http" + - "$kubernetes-resource_configmap_portal_protocol" host: - - "$node_ip" + - "$kubernetes-resource_configmap_portal_host" ports: - "$kubernetes-resource_configmap_portal_port" - path: "/web" + path: "$kubernetes-resource_configmap_portal_path" questions: - - variable: hostNetwork - label: "Enable Host Network" - group: "Networking" + - variable: embyConfig + label: "" + group: Emby Configuration schema: - type: boolean - default: false - - - variable: environmentVariables - label: "Environment Variables for Emby Server" - group: "Emby Server 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 - - # 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: embyServerHttp - label: "Configure Emby Server HTTP Service" - group: "Networking" - schema: - show_if: [[ "hostNetwork", "!=", true]] type: dict attrs: - - variable: port - label: "Port to expose for Emby Server UI" + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Emby. + schema: + type: list + default: [] + items: + - variable: env + label: Environment Variable + schema: + type: dict + attrs: + - variable: name + label: Name + schema: + type: string + required: true + - variable: value + label: Value + schema: + type: string + required: true + + - variable: embyID + label: "" + group: User and Group Configuration + schema: + type: dict + attrs: + - variable: user + label: User ID + description: The user id that Emby files will be owned by. schema: type: int + min: 2 + default: 568 + required: true + - variable: group + label: Group ID + description: The group id that Emby files will be owned by. + schema: + type: int + min: 2 + default: 568 + required: true + + - variable: embyNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: hostNetwork + label: Host Network + description: | + Bind to the host network. While it's recommended to keep this disabled.
+ It's required for autodiscovery to work. + schema: + type: boolean + default: false + - variable: webPort + label: Web Port + description: The port for the Emby Web UI. + schema: + type: int + show_if: [["hostNetwork", "=", false]] min: 9000 max: 65535 default: 9096 + required: true - # Specify GPU configuration - - variable: gpuConfiguration - label: "GPU Configuration" - group: "Resource Reservation" + - variable: embyStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: config + label: Emby Config Storage + description: The path to store Emby Configuration. + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ 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: additionalStorages + label: Additional Storage + description: Additional storage for Emby. + 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.
+ Host Path: Is a path that already exists on the system.
+ 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 + group: Resources Configuration + label: "" + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Emby. + 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
+ - Plain Integer - eg. 1
+ - Float - eg. 0.5
+ - Milicpu - eg. 500m + default: "4000m" + required: true + - variable: memory + label: Memory + description: Memory limit for Emby. + 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
+ - Suffixed with E/P/T/G/M/K - eg. 1G
+ - Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi
+ - Plain Integer in bytes - eg. 1024
+ - Exponent - eg. 134e6 + default: "8Gi" + required: true + + - variable: embyGPU + group: Resources Configuration + label: GPU Configuration schema: type: dict $ref: - "definitions/gpuConfiguration" attrs: [] - - - variable: appVolumeMounts - label: "Emby Server Storage" - group: "Storage" - schema: - type: dict - attrs: - - variable: config - label: "Config Volume" - schema: - type: dict - attrs: - - variable: datasetName - label: "Emby Server Config Volume Name" - schema: - type: string - $ref: - - "normalize/ixVolume" - show_if: [["hostPathEnabled", "=", false]] - default: "ix-emby_config" - editable: false - hidden: true - - variable: mountPath - label: "Emby Server 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 Emby Server Config Volume" - schema: - type: boolean - default: false - show_subquestions_if: true - subquestions: - - variable: hostPath - label: "Host Path for Emby Server Config Volume" - schema: - type: hostpath - required: true - - - variable: extraAppVolumeMounts - label: "Emby Server Extra Host Path Volumes" - group: "Storage" - schema: - type: list - items: - - variable: extraAppVolume - label: "Emby Server Host Path Volume" - description: "Add an extra host path volume for emby 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 - - 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" diff --git a/library/ix-dev/charts/emby/templates/NOTES.txt b/library/ix-dev/charts/emby/templates/NOTES.txt index d2e3ff976e..ba4e01146c 100644 --- a/library/ix-dev/charts/emby/templates/NOTES.txt +++ b/library/ix-dev/charts/emby/templates/NOTES.txt @@ -1,7 +1 @@ -1. Get the application URL by running these commands: - -{{- if .Values.hostNetwork }} -http://$node_ip:8096/ -{{ else }} -http://$node_ip:{{ .Values.embyServerHttp.port }}/ -{{ end }} +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/charts/emby/templates/_emby.tpl b/library/ix-dev/charts/emby/templates/_emby.tpl new file mode 100644 index 0000000000..96a37f9800 --- /dev/null +++ b/library/ix-dev/charts/emby/templates/_emby.tpl @@ -0,0 +1,64 @@ +{{- define "emby.workload" -}} +workload: + emby: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: {{ .Values.embyNetwork.hostNetwork }} + securityContext: + fsGroup: {{ .Values.embyID.group }} + containers: + emby: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 0 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + capabilities: + add: + - CHOWN + - DAC_OVERRIDE + - FOWNER + - SETGID + - SETUID + fixedEnv: + PUID: {{ .Values.embyID.user }} + {{ with .Values.embyConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: http + path: /emby/System/Ping + port: 8096 + readiness: + enabled: true + type: http + path: /emby/System/Ping + port: 8096 + startup: + enabled: true + type: http + path: /emby/System/Ping + port: 8096 + +{{ with .Values.embyGPU }} +scaleGPU: + {{ range $key, $value := . }} + - gpu: + {{ $key }}: {{ $value }} + targetSelector: + emby: + - emby + {{ end }} +{{ end }} +{{- end -}} diff --git a/library/ix-dev/charts/emby/templates/_migration.tpl b/library/ix-dev/charts/emby/templates/_migration.tpl new file mode 100644 index 0000000000..d3300a3e83 --- /dev/null +++ b/library/ix-dev/charts/emby/templates/_migration.tpl @@ -0,0 +1,35 @@ +{{- define "emby.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 "emby.migration" -}} + {{- $versions := (fromYaml (include "emby.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 .30 */}} + {{- if and (eq $oldV.Major 1) (lt ($oldV.Patch | int) 30) -}} + {{/* Block the upgrade */}} + {{- fail "Migration to 2.x.x is only allowed from 1.0.30 or higher" -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/library/ix-dev/charts/emby/templates/_persistance.tpl b/library/ix-dev/charts/emby/templates/_persistance.tpl new file mode 100644 index 0000000000..3e2ecfe0e6 --- /dev/null +++ b/library/ix-dev/charts/emby/templates/_persistance.tpl @@ -0,0 +1,26 @@ +{{- define "emby.persistence" -}} +persistence: + config: + enabled: true + {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.embyStorage.config) | nindent 4 }} + targetSelector: + emby: + emby: + mountPath: /config + tmp: + enabled: true + type: emptyDir + targetSelector: + emby: + emby: + mountPath: /tmp + {{- range $idx, $storage := .Values.embyStorage.additionalStorages }} + {{ printf "emby-%v:" (int $idx) }} + enabled: true + {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }} + targetSelector: + emby: + emby: + mountPath: {{ $storage.mountPath }} + {{- end }} +{{- end -}} diff --git a/library/ix-dev/charts/emby/templates/_portal.tpl b/library/ix-dev/charts/emby/templates/_portal.tpl new file mode 100644 index 0000000000..edaad0a5fc --- /dev/null +++ b/library/ix-dev/charts/emby/templates/_portal.tpl @@ -0,0 +1,16 @@ +{{- define "emby.portal" -}} +{{- $port := .Values.embyNetwork.webPort -}} +{{- if .Values.embyNetwork.hostNetwork -}} + {{- $port = 8096 -}} +{{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: portal +data: + port: {{ $port | quote }} + path: "/" + protocol: "http" + host: $node_ip +{{- end -}} diff --git a/library/ix-dev/charts/emby/templates/_service.tpl b/library/ix-dev/charts/emby/templates/_service.tpl new file mode 100644 index 0000000000..f6972e0f43 --- /dev/null +++ b/library/ix-dev/charts/emby/templates/_service.tpl @@ -0,0 +1,35 @@ +{{- define "emby.service" -}} +service: + emby: + enabled: true + primary: true + type: NodePort + targetSelector: emby + ports: + webui: + enabled: true + primary: true + port: {{ .Values.embyNetwork.webPort }} + nodePort: {{ .Values.embyNetwork.webPort }} + targetPort: 8096 + targetSelector: emby + discovery: + enabled: true + # This service is added only to provide + # a way for in-cluster apps to discovery emby + # For LAN discovery, host networking is required + type: ClusterIP + targetSelector: emby + ports: + dlna: + enabled: true + primary: true + port: 1900 + targetPort: 1900 + targetSelector: emby + local-discovery: + enabled: true + port: 7359 + targetPort: 7359 + targetSelector: emby +{{- end -}} diff --git a/library/ix-dev/charts/emby/templates/common.yaml b/library/ix-dev/charts/emby/templates/common.yaml new file mode 100644 index 0000000000..bf5fc4eccd --- /dev/null +++ b/library/ix-dev/charts/emby/templates/common.yaml @@ -0,0 +1,13 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{- include "emby.migration" $ -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "emby.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "emby.service" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "emby.persistence" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "emby.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/charts/emby/templates/deployment.yaml b/library/ix-dev/charts/emby/templates/deployment.yaml deleted file mode 100644 index e03780890f..0000000000 --- a/library/ix-dev/charts/emby/templates/deployment.yaml +++ /dev/null @@ -1,108 +0,0 @@ -{{ include "common.storage.hostPathValidate" .Values }} -apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }} -kind: Deployment -metadata: - name: {{ template "common.names.fullname" . }}-emby - 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: - {{- if .Values.hostNetwork }} - hostNetwork: {{ .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 }} - {{ include "common.containers.imageConfig" .Values.image | nindent 10 }} - 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: emby - protocol: TCP - containerPort: 8096 - {{- if not .Values.hostNetwork }} - hostPort: null - {{- end }} - - name: emby-dlna - protocol: UDP - containerPort: 1900 - {{- if not .Values.hostNetwork }} - hostPort: null - {{- end }} - - name: emby-lnd - protocol: UDP - containerPort: 7359 - {{- 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 }} - {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }} - readinessProbe: - httpGet: - path: /emby/System/Ping - port: 8096 - initialDelaySeconds: 10 - periodSeconds: 10 - timeoutSeconds: 5 - failureThreshold: 5 - successThreshold: 2 - livenessProbe: - httpGet: - path: /emby/System/Ping - port: 8096 - initialDelaySeconds: 10 - periodSeconds: 10 - timeoutSeconds: 5 - failureThreshold: 5 - successThreshold: 1 - startupProbe: - httpGet: - path: /emby/System/Ping - port: 8096 - initialDelaySeconds: 10 - periodSeconds: 5 - timeoutSeconds: 2 - failureThreshold: 60 - successThreshold: 1 - volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }} - {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }} - - name: extrappvolume-{{ $index }} - hostPath: - path: {{ $hostPathConfiguration.hostPath }} - {{ end }} diff --git a/library/ix-dev/charts/emby/templates/portal.tpl b/library/ix-dev/charts/emby/templates/portal.tpl deleted file mode 100644 index 3cf73f3d06..0000000000 --- a/library/ix-dev/charts/emby/templates/portal.tpl +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: portal -data: - {{- if .Values.hostNetwork }} - port: "8096" - {{- else }} - port: {{ .Values.embyServerHttp.port | quote }} - {{- end }} diff --git a/library/ix-dev/charts/emby/templates/service-tcp.yaml b/library/ix-dev/charts/emby/templates/service-tcp.yaml deleted file mode 100644 index 7a5a7d7439..0000000000 --- a/library/ix-dev/charts/emby/templates/service-tcp.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{ $svc := .Values.embyServerHttp }} -{{ $ports := list }} -{{ if .Values.hostNetwork }} -{{ $ports = mustAppend $ports (dict "name" "http" "port" 8096 "targetPort" 8096) }} -{{ else }} -{{ $ports = mustAppend $ports (dict "name" "http" "port" $svc.port "nodePort" $svc.port "targetPort" 8096) }} -{{ end }} -{{ $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 }} diff --git a/library/ix-dev/charts/emby/templates/service-udp.yaml b/library/ix-dev/charts/emby/templates/service-udp.yaml deleted file mode 100644 index e18769d83e..0000000000 --- a/library/ix-dev/charts/emby/templates/service-udp.yaml +++ /dev/null @@ -1,6 +0,0 @@ -{{ $ports := list }} -{{ $ports = mustAppend $ports (dict "name" "emby-dlna" "port" 1900 "protocol" "UDP" "targetPort" "emby-dlna") }} -{{ $ports = mustAppend $ports (dict "name" "emby-lnd" "port" 7359 "protocol" "UDP" "targetPort" "emby-lnd") }} -{{ $params := . }} -{{ $_ := set $params "commonService" (dict "type" "ClusterIP" "ports" $ports "nameSuffix" "udp" ) }} -{{ include "common.classes.service" $params }} diff --git a/library/ix-dev/charts/emby/to_keep_versions.md b/library/ix-dev/charts/emby/to_keep_versions.md new file mode 100644 index 0000000000..1f40b08e8b --- /dev/null +++ b/library/ix-dev/charts/emby/to_keep_versions.md @@ -0,0 +1,4 @@ +# 1.0.30 + +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. diff --git a/library/ix-dev/charts/emby/to_keep_versions.yaml b/library/ix-dev/charts/emby/to_keep_versions.yaml new file mode 100644 index 0000000000..ade3e363bc --- /dev/null +++ b/library/ix-dev/charts/emby/to_keep_versions.yaml @@ -0,0 +1 @@ +- 1.0.30 diff --git a/library/ix-dev/charts/emby/values.yaml b/library/ix-dev/charts/emby/values.yaml index 86c9dd4b8c..9d5e197283 100644 --- a/library/ix-dev/charts/emby/values.yaml +++ b/library/ix-dev/charts/emby/values.yaml @@ -2,3 +2,29 @@ image: pullPolicy: IfNotPresent repository: emby/embyserver tag: 4.7.14.0 + +resources: + limits: + cpu: 4000m + memory: 8Gi + +embyConfig: + additionalEnvs: [] + +# On migration the default is 2 +embyID: + user: 568 + group: 568 + +embyNetwork: + webPort: 9096 + hostNetwork: false + +embyStorage: + config: + type: ixVolume + ixVolumeConfig: + datasetName: config + additionalStorages: [] + +embyGPU: {}