Add metube to community train (#1635)

* initial commit

* add upg strategy

* some metadata

* add template for service

* add values

* typo

* add more

* add metadata

* add readme

* add questions

* remove quotes
This commit is contained in:
Stavros Kois
2023-10-13 18:43:18 +03:00
committed by GitHub
parent 0341bfb015
commit fab1c03d74
20 changed files with 524 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.1.1
digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7
generated: "2023-10-12T16:10:43.537427728+03:00"

View File

@@ -0,0 +1,25 @@
name: metube
description: MeTube is a web GUI for youtube-dl (using the yt-dlp fork) with playlist support.
annotations:
title: MeTube
type: application
version: 1.0.0
apiVersion: v2
appVersion: '2023-10-03'
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.1.1
home: https://github.com/alexta69/metube
icon: https://localhost/no-icon
sources:
- https://github.com/truenas/charts/tree/master/library/ix-dev/community/metube
- https://github.com/alexta69/metube
keywords:
- youtube-dl
- yt-dlp

View File

@@ -0,0 +1,8 @@
# MeTube
[MeTube](https://github.com/alexta69/metube) is an ebook and audiobook collection manager for Usenet and BitTorrent users.
> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the `MeTube` directories.
> Afterward, the `MeTube` container will run as a **non**-root user (Default: `568`).
> All mounted storage(s) will be `chown`ed only if the parent directory does not match the configured user.

View File

@@ -0,0 +1,8 @@
# MeTube
[MeTube](https://github.com/alexta69/metube) is an ebook and audiobook collection manager for Usenet and BitTorrent users.
> When application is installed, a container will be launched with **root** privileges.
> This is required in order to apply the correct permissions to the `MeTube` directories.
> Afterward, the `MeTube` container will run as a **non**-root user (Default: `568`).
> All mounted storage(s) will be `chown`ed only if the parent directory does not match the configured user.

View File

@@ -0,0 +1,10 @@
metubeNetwork:
webPort: 31000
metubeRunAs:
user: 1000
group: 1000
metubeStorage:
downloads:
type: pvc

View File

@@ -0,0 +1,14 @@
metubeConfig:
defaultTheme: light
metubeNetwork:
webPort: 31000
metubeStorage:
downloads:
type: pvc
additionalStorages:
- type: pvc
mountPath: /data1
- type: pvc
mountPath: /data2

View File

@@ -0,0 +1,7 @@
metubeNetwork:
webPort: 31000
hostNetwork: true
metubeStorage:
downloads:
type: pvc

View File

@@ -0,0 +1,8 @@
icon_url: https://localhost/no-icon
categories:
- media
screenshots:
- https://github.com/alexta69/metube/raw/master/screenshot.gif
tags:
- youtube-dl
- yt-dlp

View File

@@ -0,0 +1,8 @@
runAsContext:
- userName: metube
groupName: metube
gid: 568
uid: 568
description: MeTube can run as any non-root user.
capabilities: []
hostMounts: []

View File

@@ -0,0 +1,247 @@
groups:
- name: MeTube Configuration
description: Configure MeTube
- name: User and Group Configuration
description: Configure User and Group for MeTube
- name: Network Configuration
description: Configure Network for MeTube
- name: Storage Configuration
description: Configure Storage for MeTube
- name: Resources Configuration
description: Configure Resources for MeTube
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: MeTubeConfig
label: ""
group: MeTube Configuration
schema:
type: dict
attrs:
- variable: defaultTheme
label: Default Theme
description: The default theme for MeTube.
schema:
type: string
default: auto
required: true
enum:
- value: "auto"
description: Auto
- value: "dark"
description: Dark
- value: "light"
description: Light
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for MeTube.
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: MeTubeRunAs
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: user
label: User ID
description: The user id that MeTube will run as.
schema:
type: int
min: 2
default: 568
required: true
- variable: group
label: Group ID
description: The group id that MeTube will run as.
schema:
type: int
min: 2
default: 568
required: true
- variable: MeTubeNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: webPort
label: Web Port
description: The port for the MeTube Web UI.
schema:
type: int
default: 30094
min: 9000
max: 65535
required: true
- 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: MeTubeStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: downloads
label: MeTube Downloads Storage
description: The path to store MeTube 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 MeTube.
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 MeTube.
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 MeTube.
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

View File

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

View File

@@ -0,0 +1,51 @@
{{- define "metube.workload" -}}
workload:
metube:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.metubeNetwork.hostNetwork }}
containers:
metube:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: {{ .Values.metubeRunAs.user }}
runAsGroup: {{ .Values.metubeRunAs.group }}
env:
PORT: {{ .Values.metubeNetwork.webPort }}
DOWNLOAD_DIR: /downloads
STATE_DIR: /downloads/.metube
DEFAULT_THEME: auto
{{ with .Values.metubeConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: http
port: {{ .Values.metubeNetwork.webPort }}
path: /
readiness:
enabled: true
type: http
port: {{ .Values.metubeNetwork.webPort }}
path: /
startup:
enabled: true
type: http
port: {{ .Values.metubeNetwork.webPort }}
path: /
initContainers:
{{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
"UID" .Values.metubeRunAs.user
"GID" .Values.metubeRunAs.group
"mode" "check"
"type" "init") | nindent 8 }}
{{- end -}}

View File

@@ -0,0 +1,34 @@
{{- define "metube.persistence" -}}
persistence:
downloads:
enabled: true
type: {{ .Values.metubeStorage.downloads.type }}
datasetName: {{ .Values.metubeStorage.downloads.datasetName | default "" }}
hostPath: {{ .Values.metubeStorage.downloads.hostPath | default "" }}
targetSelector:
metube:
metube:
mountPath: /downloads
01-permissions:
mountPath: /mnt/directories/downloads
tmp:
enabled: true
type: emptyDir
targetSelector:
metube:
metube:
mountPath: /tmp
{{- range $idx, $storage := .Values.metubeStorage.additionalStorages }}
{{ printf "metube-%v" (int $idx) }}:
enabled: true
type: {{ $storage.type }}
datasetName: {{ $storage.datasetName | default "" }}
hostPath: {{ $storage.hostPath | default "" }}
targetSelector:
metube:
metube:
mountPath: {{ $storage.mountPath }}
01-permissions:
mountPath: /mnt/directories{{ $storage.mountPath }}
{{- end }}
{{- end -}}

View File

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

View File

@@ -0,0 +1,15 @@
{{- define "metube.service" -}}
service:
metube:
enabled: true
primary: true
type: NodePort
targetSelector: metube
ports:
webui:
enabled: true
primary: true
port: {{ .Values.metubeNetwork.webPort }}
nodePort: {{ .Values.metubeNetwork.webPort }}
targetSelector: metube
{{- end -}}

View File

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

View File

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

View File

@@ -0,0 +1,31 @@
#!/usr/bin/python3
import json
import re
import sys
from catalog_update.upgrade_strategy import datetime_versioning
RE_STABLE_VERSION = re.compile(r'\d{4}-\d{2}-\d{2}')
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 = datetime_versioning(list(tags), '%Y-%m-%d')
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)))

View File

@@ -0,0 +1,27 @@
image:
repository: alexta69/metube
pullPolicy: IfNotPresent
tag: '2023-10-08'
resources:
limits:
cpu: 4000m
memory: 8Gi
metubeConfig:
defaultTheme: auto
additionalEnvs: []
metubeNetwork:
webPort: 30094
hostNetwork: false
metubeRunAs:
user: 568
group: 568
metubeStorage:
downloads:
type: ixVolume
datasetName: downloads
additionalStorages: []