소스 검색

NAS-122451 / 23.10 / Add `deluge` to `community` apps (#1263)

* add `deluge` to `community` apps

* update UI and add a test

* fix default values
Stavros Kois 2 년 전
부모
커밋
d77d46640d

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

@@ -0,0 +1,6 @@
+dependencies:
+- name: common
+  repository: file://../../../common
+  version: 1.0.8
+digest: sha256:254efaa1285f634b7a80b7baadeadbd20a680f7fee49d1d9d3c4618aa0d657ad
+generated: "2023-06-13T16:21:59.289590931+03:00"

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

@@ -0,0 +1,26 @@
+name: deluge
+description: Deluge is a lightweight, Free Software, cross-platform BitTorrent client.
+annotations:
+  title: Deluge
+type: application
+version: 1.0.0
+apiVersion: v2
+appVersion: '9.5.3'
+kubeVersion: '>=1.16.0-0'
+maintainers:
+  - name: truenas
+    url: https://www.truenas.com/
+    email: dev@ixsystems.com
+dependencies:
+  - name: common
+    repository: file://../../../common
+    version: 1.0.8
+home: https://deluge-torrent.org
+icon: https://deluge-torrent.org/images/deluge_logo.png
+sources:
+  - https://hub.docker.com/r/linuxserver/deluge
+  - https://github.com/truenas/charts/tree/master/community/deluge
+  - https://deluge-torrent.org/
+keywords:
+  - torrent
+  - download

+ 3 - 0
library/ix-dev/community/deluge/README.md

@@ -0,0 +1,3 @@
+# Deluge
+
+[Deluge](https://deluge-torrent.org/) is a lightweight, Free Software, cross-platform BitTorrent client.

+ 3 - 0
library/ix-dev/community/deluge/app-readme.md

@@ -0,0 +1,3 @@
+# Deluge
+
+[Deluge](https://deluge-torrent.org/) is a lightweight, Free Software, cross-platform BitTorrent client.

BIN
library/ix-dev/community/deluge/charts/common-1.0.8.tgz


+ 7 - 0
library/ix-dev/community/deluge/ci/basic-values.yaml

@@ -0,0 +1,7 @@
+delugeStorage:
+  config:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/config
+  downloads:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/downloads

+ 10 - 0
library/ix-dev/community/deluge/ci/hostnet-values.yaml

@@ -0,0 +1,10 @@
+delugeStorage:
+  config:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/config
+  downloads:
+    type: hostPath
+    hostPath: /mnt/{{ .Release.Name }}/downloads
+
+delugeNetwork:
+  hostNetwork: true

+ 7 - 0
library/ix-dev/community/deluge/item.yaml

@@ -0,0 +1,7 @@
+icon_url: https://deluge-torrent.org/images/deluge_logo.png
+categories:
+  - media
+screenshots: []
+tags:
+  - torrent
+  - download

+ 18 - 0
library/ix-dev/community/deluge/metadata.yaml

@@ -0,0 +1,18 @@
+runAsContext:
+  - userName: root
+    groupName: root
+    gid: 0
+    uid: 0
+    description: Deluge requires root privileges to start the Deluge process
+capabilities:
+  - name: CHOWN
+    description: Deluge is able to chown files.
+  - name: DAC_OVERRIDE
+    description: Deluge is able to bypass permission checks.
+  - name: FOWNER
+    description: Deluge is able bypass permission checks for it's sub-processes.
+  - name: SETGID
+    description: Deluge is able to set group ID for it's sub-processes.
+  - name: SETUID
+    description: Deluge is able to set user ID for it's sub-processes.
+hostMounts: []

+ 280 - 0
library/ix-dev/community/deluge/questions.yaml

@@ -0,0 +1,280 @@
+groups:
+  - name: Deluge Configuration
+    description: Configure Deluge
+  - name: User and Group Configuration
+    description: Configure User and Group for Deluge
+  - name: Network Configuration
+    description: Configure Network for Deluge
+  - name: Storage Configuration
+    description: Configure Storage for Deluge
+  - name: Resources Configuration
+    description: Configure Resources for Deluge
+
+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: Deluge Configuration
+    label: Timezone
+    schema:
+      type: string
+      default: Etc/UTC
+      required: true
+      $ref:
+        - definitions/timezone
+
+  - variable: delugeConfig
+    label: ""
+    group: Deluge Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: additionalEnvs
+          label: Additional Environment Variables
+          description: Configure additional environment variables for Deluge.
+          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: delugeID
+    label: ""
+    group: User and Group Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: user
+          label: User ID
+          description: he user id that Deluge files will be owned by.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+        - variable: group
+          label: Group ID
+          description: The group id that Deluge files will be owned by.
+          schema:
+            type: int
+            min: 2
+            default: 568
+            required: true
+
+  - variable: delugeNetwork
+    label: ""
+    group: Network Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: hostNetwork
+          label: Host Network
+          description: |
+            Bind to the host network. It's recommended to keep this disabled.</br>
+          schema:
+            type: boolean
+            default: false
+        - variable: webPort
+          label: Web Port
+          description: The port for the Deluge Web UI.
+          schema:
+            type: int
+            show_if: [["hostNetwork", "=", false]]
+            default: 30038
+            min: 9000
+            max: 65535
+            required: true
+        - variable: torrentPort
+          label: Torrent Port
+          description: |
+            The port for the Deluge Torrent.</br>
+            Applies to both TCP and UDP.
+            (Internal port is always 6881)
+          schema:
+            type: int
+            show_if: [["hostNetwork", "=", false]]
+            default: 30039
+            min: 9000
+            max: 65535
+            required: true
+
+  - variable: delugeStorage
+    label: ""
+    group: Storage Configuration
+    schema:
+      type: dict
+      attrs:
+        - variable: config
+          label: Deluge Config Storage
+          description: The path to store Deluge 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: "config"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: downloads
+          label: Deluge Downloads Storage
+          description: The path to store Deluge Downloads.
+          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: "downloads"
+                  $ref:
+                    - "normalize/ixVolume"
+              - variable: hostPath
+                label: Host Path
+                schema:
+                  type: hostpath
+                  show_if: [["type", "=", "hostPath"]]
+                  immutable: true
+                  required: true
+        - variable: additionalStorages
+          label: Additional Storage
+          description: Additional storage for Deluge.
+          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 Deluge.
+                schema:
+                  type: string
+                  default: "4000m"
+                  required: true
+              - variable: memory
+                label: Memory
+                description: Memory limit for Deluge.
+                schema:
+                  type: string
+                  default: "8Gi"
+                  required: true

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

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

+ 118 - 0
library/ix-dev/community/deluge/templates/_deluge.tpl

@@ -0,0 +1,118 @@
+{{- define "deluge.workload" -}}
+workload:
+  deluge:
+    enabled: true
+    primary: true
+    type: Deployment
+    podSpec:
+      securityContext:
+        fsGroup: {{ .Values.delugeID.group }}
+      hostNetwork: {{ .Values.delugeNetwork.hostNetwork }}
+      containers:
+        deluge:
+          enabled: true
+          primary: true
+          imageSelector: image
+          securityContext:
+            runAsUser: 0
+            runAsGroup: 0
+            runAsNonRoot: false
+            readOnlyRootFilesystem: false
+            capabilities:
+              add:
+                - CHOWN
+                - DAC_OVERRIDE
+                - FOWNER
+                - SETGID
+                - SETUID
+          {{ with .Values.delugeConfig.additionalEnvs }}
+          envList:
+            {{ range $env := . }}
+            - name: {{ $env.name }}
+              value: {{ $env.value }}
+            {{ end }}
+          {{ end }}
+          probes:
+            liveness:
+              enabled: true
+              type: http
+              port: 8112
+              path: /
+            readiness:
+              enabled: true
+              type: http
+              port: 8112
+              path: /
+            startup:
+              enabled: true
+              type: http
+              port: 8112
+              path: /
+
+{{/* Service */}}
+service:
+  deluge:
+    enabled: true
+    primary: true
+    type: NodePort
+    targetSelector: deluge
+    ports:
+      webui:
+        enabled: true
+        primary: true
+        port: {{ .Values.delugeNetwork.webPort }}
+        nodePort: {{ .Values.delugeNetwork.webPort }}
+        targetPort: 8112
+        targetSelector: deluge
+  torrent:
+    enabled: true
+    type: NodePort
+    targetSelector: deluge
+    ports:
+      tcp:
+        enabled: true
+        primary: true
+        port: {{ .Values.delugeNetwork.torrentPort }}
+        nodePort: {{ .Values.delugeNetwork.torrentPort }}
+        targetPort: 6881
+        targetSelector: deluge
+      udp:
+        enabled: true
+        port: {{ .Values.delugeNetwork.torrentPort }}
+        nodePort: {{ .Values.delugeNetwork.torrentPort }}
+        targetPort: 6881
+        protocol: udp
+        targetSelector: deluge
+
+{{/* Persistence */}}
+persistence:
+  config:
+    enabled: true
+    type: {{ .Values.delugeStorage.config.type }}
+    datasetName: {{ .Values.delugeStorage.config.datasetName | default "" }}
+    hostPath: {{ .Values.delugeStorage.config.hostPath | default "" }}
+    targetSelector:
+      deluge:
+        deluge:
+          mountPath: /config
+  downloads:
+    enabled: true
+    type: {{ .Values.delugeStorage.downloads.type }}
+    datasetName: {{ .Values.delugeStorage.downloads.datasetName | default "" }}
+    hostPath: {{ .Values.delugeStorage.downloads.hostPath | default "" }}
+    targetSelector:
+      deluge:
+        deluge:
+          mountPath: /downloads
+  {{- range $idx, $storage := .Values.delugeStorage.additionalStorages }}
+  {{ printf "deluge-%v" (int $idx) }}:
+    enabled: true
+    type: {{ $storage.type }}
+    datasetName: {{ $storage.datasetName | default "" }}
+    hostPath: {{ $storage.hostPath | default "" }}
+    targetSelector:
+      deluge:
+        deluge:
+          mountPath: {{ $storage.mountPath }}
+  {{- end }}
+{{- end -}}

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

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

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

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

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

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

+ 31 - 0
library/ix-dev/community/deluge/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]+')
+
+
+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)))

+ 36 - 0
library/ix-dev/community/deluge/values.yaml

@@ -0,0 +1,36 @@
+image:
+  repository: linuxserver/deluge
+  pullPolicy: IfNotPresent
+  tag: '2.1.1'
+
+resources:
+  limits:
+    cpu: 4000m
+    memory: 8Gi
+
+delugeConfig:
+  additionalEnvs: []
+
+delugeNetwork:
+  hostNetwork: false
+  webPort: 30038
+  torrentPort: 30039
+
+delugeID:
+  user: 568
+  group: 568
+
+delugeStorage:
+  config:
+    type: ixVolume
+    datasetName: config
+  downloads:
+    type: ixVolume
+    datasetName: downloads
+  additionalStorages: []
+
+notes:
+  custom: |
+    Default credentials:
+      - Username: admin
+      - Password: deluge