Kaynağa Gözat

NAS-121565 / 23.10 / Add Tdarr to community train (#1141)

* Add Tdarr to community train

* fix UI

* Apply suggestions from code review
Stavros Kois 2 yıl önce
ebeveyn
işleme
c539489f78

+ 6 - 0
library/ix-dev/community/tdarr/Chart.lock

@@ -0,0 +1,6 @@
+dependencies:
+- name: common
+  repository: file://../../../common
+  version: 1.0.6
+digest: sha256:2f1f31c15fb7f92db141a66adbb8d23a8598727730050a3883a211763a4e5472
+generated: "2023-04-20T01:43:11.036358079+03:00"

+ 26 - 0
library/ix-dev/community/tdarr/Chart.yaml

@@ -0,0 +1,26 @@
+name: tdarr
+description: Tdarr is a Distributed Transcoding System
+annotations:
+  title: Tdarr
+type: application
+version: 1.0.0
+apiVersion: v2
+appVersion: '2.00.20.1'
+kubeVersion: '>=1.16.0-0'
+maintainers:
+  - name: truenas
+    url: https://www.truenas.com/
+dependencies:
+  - name: common
+    repository: file://../../../common
+    version: 1.0.6
+home: https://home.tdarr.io/
+icon: https://home.tdarr.io/static/media/logo3-min.246d6df4.png
+sources:
+  - https://home.tdarr.io/
+  - https://github.com/truenas/charts/tree/master/community/tdarr
+  - https://docs.tdarr.io/docs
+keywords:
+  - media
+  - encode
+  - transcode

+ 5 - 0
library/ix-dev/community/tdarr/README.md

@@ -0,0 +1,5 @@
+# Tdarr
+
+[Tdarr](https://home.tdarr.io/) is a Distributed Transcoding System
+
+- App runs as `root` user

+ 5 - 0
library/ix-dev/community/tdarr/app-readme.md

@@ -0,0 +1,5 @@
+# Tdarr
+
+[Tdarr](https://home.tdarr.io/) is a Distributed Transcoding System
+
+- App runs as `root` user

BIN
library/ix-dev/community/tdarr/charts/common-1.0.6.tgz


+ 19 - 0
library/ix-dev/community/tdarr/ci/basic-values.yaml

@@ -0,0 +1,19 @@
+tdarrConfig:
+  nodeName: My Internal Node
+tdarrID:
+  user: 1001
+  group: 1001
+tdarrStorage:
+  server:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/server
+  configs:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/configs
+  logs:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/logs
+  transcodes:
+    type: emptyDir
+    medium: Memory
+    size: 1Gi

+ 16 - 0
library/ix-dev/community/tdarr/ci/no-internal-node-values.yaml

@@ -0,0 +1,16 @@
+tdarrConfig:
+  nodeName: ''
+  internalNode: false
+tdarrStorage:
+  server:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/server
+  configs:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/configs
+  logs:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/logs
+  transcodes:
+    type: emptyDir
+    size: 1Gi

+ 5 - 0
library/ix-dev/community/tdarr/item.yaml

@@ -0,0 +1,5 @@
+icon_url: https://home.tdarr.io/static/media/logo3-min.246d6df4.png
+categories:
+  - media
+  - encode
+  - transcode

+ 395 - 0
library/ix-dev/community/tdarr/questions.yaml

@@ -0,0 +1,395 @@
+groups:
+  - name: Tdarr Configuration
+    description: Configure Tdarr
+  - name: User and Group Configuration
+    description: Configure User and Group for Tdarr
+  - name: Network Configuration
+    description: Configure Network for Tdarr
+  - name: Storage Configuration
+    description: Configure Storage for Tdarr
+  - name: Resources Configuration
+    description: Configure Resources for Tdarr
+
+portals:
+  web_portal:
+    protocols:
+      - "$kubernetes-resource_configmap_portal_protocol"
+    host:
+      - "$kubernetes-resource_configmap_portal_host"
+    ports:
+      - "$kubernetes-resource_configmap_portal_port"
+    path: "$kubernetes-resource_configmap_portal_path"
+
+questions:
+  - variable: TZ
+    group: Tdarr Configuration
+    label: Timezone
+    schema:
+      type: string
+      default: Etc/UTC
+      required: true
+      $ref:
+        - definitions/timezone
+
+  - variable: tdarrConfig
+    label: ""
+    group: Tdarr Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: internalNode
+          label: Internal Node
+          description: |
+            If disabled, Tdarr will run only the server and webUI.</br>
+            If enabled, Tdarr will also start an internal node in the same container.
+          schema:
+            type: boolean
+            default: true
+        - variable: nodeName
+          label: Node Name
+          description: The name of the Tdarr Node.
+          schema:
+            type: string
+            default: "Tdarr"
+            show_if: [["internalNode", "=", true]]
+            required: true
+        - variable: additionalEnvs
+          label: Additional Environment Variables
+          description: Configure additional environment variables for Tdarr.
+          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: tdarrID
+    label: ""
+    group: User and Group Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: user
+          label: User ID
+          description: The user id that Tdarr files will be owned by.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+        - variable: group
+          label: Group ID
+          description: The group id that Tdarr files will be owned by.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+
+  - variable: tdarrNetwork
+    label: ""
+    group: Network Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: webPort
+          label: Web Port
+          description: The port for the Tdarr Web UI.
+          schema:
+            type: int
+            default: 30000
+            min: 9000
+            max: 65535
+            required: true
+        - variable: serverPort
+          label: Server Port
+          description: The port for the Tdarr Server.
+          schema:
+            type: int
+            default: 30001
+            min: 9000
+            max: 65535
+            required: true
+
+  - variable: tdarrStorage
+    label: ""
+    group: Storage Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: server
+          label: Tdarr Server Storage
+          description: The path to store Tdarr Server 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
+                  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: datasetName
+                label: Dataset Name
+                schema:
+                  type: string
+                  show_if: [["type", "=", "ixVolume"]]
+                  required: true
+                  hidden: true
+                  immutable: true
+                  default: "server"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: configs
+          label: Tdarr Config Storage
+          description: The path to store Tdarr 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
+                  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: datasetName
+                label: Dataset Name
+                schema:
+                  type: string
+                  show_if: [["type", "=", "ixVolume"]]
+                  required: true
+                  hidden: true
+                  immutable: true
+                  default: "configs"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: logs
+          label: Tdarr Logs Storage
+          description: The path to store Tdarr Logs.
+          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
+                  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: datasetName
+                label: Dataset Name
+                schema:
+                  type: string
+                  show_if: [["type", "=", "ixVolume"]]
+                  required: true
+                  hidden: true
+                  immutable: true
+                  default: "logs"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: transcodes
+          label: Tdarr Transcodes Storage
+          description: The path to store Tdarr Transcodes.
+          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
+                  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: datasetName
+                label: Dataset Name
+                schema:
+                  type: string
+                  show_if: [["type", "=", "ixVolume"]]
+                  required: true
+                  hidden: true
+                  immutable: true
+                  default: "transcodes"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+              - 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
+                  show_if: [["type", "=", "emptyDir"]]
+                  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
+                description: |
+                  The maximum size of the temporary directory.</br>
+                  For example: 2Gi
+                schema:
+                  type: string
+                  show_if: [["type", "=", "emptyDir"]]
+                  default: "2Gi"
+        - variable: additionalStorages
+          label: Additional Storage
+          description: Additional storage for Tdarr.
+          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.
+                      schema:
+                        type: string
+                        required: 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: mountPath
+                      label: Mount Path
+                      description: The path inside the container to mount the storage.
+                      schema:
+                        type: path
+                        required: true
+                    - variable: hostPath
+                      label: Host Path
+                      description: The host path to use for storage.
+                      schema:
+                        type: hostpath
+                        show_if: [["type", "=", "hostPath"]]
+                        required: true
+                    - variable: datasetName
+                      label: Dataset Name
+                      description: The name of the dataset to use for storage.
+                      schema:
+                        type: string
+                        show_if: [["type", "=", "ixVolume"]]
+                        required: true
+                        immutable: true
+                        default: "storage_entry"
+                        $ref:
+                          - "normalize/ixVolume"
+
+  - 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 Tdarr.
+                schema:
+                  type: string
+                  default: "4000m"
+                  required: true
+              - variable: memory
+                label: Memory
+                description: Memory limit for Tdarr.
+                schema:
+                  type: string
+                  default: "8Gi"
+                  required: true
+
+  - variable: tdarrGPU
+    group: Resources Configuration
+    label: GPU Configuration
+    schema:
+      type: dict
+      $ref:
+        - "definitions/gpuConfiguration"
+      attrs: []

+ 1 - 0
library/ix-dev/community/tdarr/templates/NOTES.txt

@@ -0,0 +1 @@
+{{ include "ix.v1.common.lib.chart.notes" $ }}

+ 12 - 0
library/ix-dev/community/tdarr/templates/_portal.tpl

@@ -0,0 +1,12 @@
+{{- define "tdarr.portal" -}}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: portal
+data:
+  path: "/"
+  port: {{ .Values.tdarrNetwork.webPort | quote }}
+  protocol: http
+  host: $node_ip
+{{- end -}}

+ 144 - 0
library/ix-dev/community/tdarr/templates/_tdarr.tpl

@@ -0,0 +1,144 @@
+{{- define "tdarr.workload" -}}
+workload:
+  tdarr:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      hostNetwork: false
+      securityContext:
+        fsGroup: {{ .Values.tdarrID.group }}
+      containers:
+        tdarr:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsUser: 0
+            runAsGroup: 0
+            readOnlyRootFilesystem: false
+            runAsNonRoot: false
+            capabilities:
+              add:
+                - CHOWN
+                - FOWNER
+                - SETUID
+                - SETGID
+          env:
+            inContainer: "true"
+            internalNode: {{ .Values.tdarrConfig.internalNode | quote }}
+            serverPort: {{ .Values.tdarrNetwork.serverPort }}
+            webUIPort: {{ .Values.tdarrNetwork.webPort }}
+            nodeName: {{ .Values.tdarrConfig.nodeName }}
+            serverIP: {{ .Values.tdarrConfig.serverIP }}
+          fixedEnv:
+            PUID: {{ .Values.tdarrID.user }}
+          envList:
+          {{ with .Values.tdarrConfig.additionalEnvs }}
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: "{{ .Values.tdarrNetwork.webPort }}"
+              path: /api/v2/status
+            readiness:
+              enabled: true
+              type: http
+              port: "{{ .Values.tdarrNetwork.webPort }}"
+              path: /api/v2/status
+            startup:
+              enabled: true
+              type: http
+              port: "{{ .Values.tdarrNetwork.webPort }}"
+              path: /api/v2/status
+
+{{/* Service */}}
+service:
+  tdarr:
+    enabled: true
+    primary: true
+    type: NodePort
+    targetSelector: tdarr
+    ports:
+      webui:
+        enabled: true
+        primary: true
+        port: {{ .Values.tdarrNetwork.webPort }}
+        nodePort: {{ .Values.tdarrNetwork.webPort }}
+        targetSelector: tdarr
+      server:
+        enabled: true
+        port: {{ .Values.tdarrNetwork.serverPort }}
+        nodePort: {{ .Values.tdarrNetwork.serverPort }}
+        targetSelector: tdarr
+
+{{/* Persistence */}}
+persistence:
+  server:
+    enabled: true
+    type: {{ .Values.tdarrStorage.server.type }}
+    datasetName: {{ .Values.tdarrStorage.server.datasetName | default "" }}
+    hostPath: {{ .Values.tdarrStorage.server.hostPath | default "" }}
+    targetSelector:
+      tdarr:
+        tdarr:
+          mountPath: /app/server
+  configs:
+    enabled: true
+    type: {{ .Values.tdarrStorage.configs.type }}
+    datasetName: {{ .Values.tdarrStorage.configs.datasetName | default "" }}
+    hostPath: {{ .Values.tdarrStorage.configs.hostPath | default "" }}
+    targetSelector:
+      tdarr:
+        tdarr:
+          mountPath: /app/configs
+  logs:
+    enabled: true
+    type: {{ .Values.tdarrStorage.logs.type }}
+    datasetName: {{ .Values.tdarrStorage.logs.datasetName | default "" }}
+    hostPath: {{ .Values.tdarrStorage.logs.hostPath | default "" }}
+    targetSelector:
+      tdarr:
+        tdarr:
+          mountPath: /app/logs
+  transcode:
+    enabled: true
+    type: {{ .Values.tdarrStorage.transcodes.type }}
+    datasetName: {{ .Values.tdarrStorage.transcodes.datasetName | default "" }}
+    hostPath: {{ .Values.tdarrStorage.transcodes.hostPath | default "" }}
+    medium: {{ .Values.tdarrStorage.transcodes.medium | default "" }}
+    {{/* Size of the emptyDir */}}
+    size: {{ .Values.tdarrStorage.transcodes.size | default "" }}
+    targetSelector:
+      tdarr:
+        tdarr:
+          mountPath: /temp
+  {{- range $idx, $storage := .Values.tdarrStorage.additionalStorages }}
+  {{ printf "tdarr-%v" (int $idx) }}:
+    enabled: true
+    type: {{ $storage.type }}
+    datasetName: {{ $storage.datasetName | default "" }}
+    hostPath: {{ $storage.hostPath | default "" }}
+    targetSelector:
+      tdarr:
+        tdarr:
+          mountPath: {{ $storage.mountPath }}
+  {{- end }}
+
+{{ with .Values.tdarrGPU }}
+  {{ if gt (. | len) 1 }}
+    {{- fail "Tdarr - Max [1] GPUs allowed" -}}
+  {{ end }}
+scaleGPU:
+  - gpu:
+      {{ . | keys | first }}: {{ . | values | first }}
+    targetSelector:
+      tdarr:
+        - tdarr
+{{ end }}
+{{- end -}}

+ 9 - 0
library/ix-dev/community/tdarr/templates/common.yaml

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

+ 1 - 0
library/ix-dev/community/tdarr/upgrade_info.json

@@ -0,0 +1 @@
+{"filename": "values.yaml", "keys": ["image"]}

+ 31 - 0
library/ix-dev/community/tdarr/upgrade_strategy

@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+import json
+import re
+import sys
+
+from catalog_update.upgrade_strategy import semantic_versioning
+
+
+RE_STABLE_VERSION = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
+
+
+def newer_mapping(image_tags):
+    key = list(image_tags.keys())[0]
+    tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)}
+    version = semantic_versioning(list(tags))
+    if not version:
+        return {}
+
+    return {
+        'tags': {key: tags[version]},
+        'app_version': version,
+    }
+
+
+if __name__ == '__main__':
+    try:
+        versions_json = json.loads(sys.stdin.read())
+    except ValueError:
+        raise ValueError('Invalid json specified')
+
+    print(json.dumps(newer_mapping(versions_json)))

+ 41 - 0
library/ix-dev/community/tdarr/values.yaml

@@ -0,0 +1,41 @@
+image:
+  repository: haveagitgat/tdarr
+  pullPolicy: IfNotPresent
+  tag: '2.00.20.1'
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+tdarrConfig:
+  nodeName: ''
+  internalNode: true
+  serverIP: "0.0.0.0"
+  additionalEnvs: []
+tdarrNetwork:
+  webPort: 30000
+  serverPort: 30001
+tdarrGPU: {}
+tdarrID:
+  user: 568
+  group: 568
+tdarrStorage:
+  server:
+    type: ixVolume
+    hostPath: ''
+    datasetName: server
+  configs:
+    type: ixVolume
+    hostPath: ''
+    datasetName: configs
+  logs:
+    type: ixVolume
+    hostPath: ''
+    datasetName: logs
+  transcodes:
+    type: ixVolume
+    hostPath: ''
+    datasetName: transcodes
+    medium: ''
+    size: ''
+  additionalStorages: []