NAS-121405 / 23.10 / Add Lidarr to community train (#1100)

* Add Lidarr to charts train

* Run chart tests in a matrix

* move to correct train

* Fix variable name and quote strings in questions.yaml
This commit is contained in:
Stavros Kois
2023-04-11 18:26:15 +03:00
committed by GitHub
parent 5d538a9365
commit a964babc58
18 changed files with 531 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ jobs:
helm-version:
- v3.9.4
- v3.10.3
- v3.11.1
- v3.11.2
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
@@ -45,21 +45,52 @@ jobs:
run: |
ct lint --config .github/ct-install-config/charts-ct-lint.yaml
list-changed:
needs:
- lint
name: List Changed Charts
runs-on: ubuntu-22.04
outputs:
changed_json: ${{ steps.list-changed.outputs.changed_json }}
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
- name: List Changed Charts
id: list-changed
shell: bash
run: |
changed_json=$(ct list-changed \
--config .github/ct-install-config/charts-ct-install.yaml | \
jq --raw-input '.' | jq --compact-output --slurp '.')
echo "changed_json=$changed_json" >> $GITHUB_OUTPUT
echo 'Detected changes in the following charts:'
echo "$changed_json" | jq --raw-output '.[]'
install:
needs:
- lint
name: Install Charts
- list-changed
name: Install Chart
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# We run tests on k3s version of latest SCALE release, SCALE nightly and manually defined "latest"
k3s-version:
- v1.25.3+k3s1
chart: ${{ fromJson(needs.list-changed.outputs.changed_json) }}
# We run tests on Helm version of latest SCALE release, SCALE nightly and manually defined "latest"
helm-version:
- v3.9.4
- v3.11.1
- v3.11.2
# We run tests on k3s version of latest SCALE release, SCALE nightly and manually defined "latest"
k3s-version:
- v1.25.3+k3s1
steps:
- name: Checkout
@@ -120,5 +151,6 @@ jobs:
k3d-args: --k3s-arg --disable=metrics-server@server:*
- name: Run chart-testing (install)
shell: bash
run: |
ct install --config .github/ct-install-config/charts-ct-install.yaml
ct install --config .github/ct-install-config/charts-ct-install.yaml --charts ${{ matrix.chart }}

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.0.3
digest: sha256:1a090020cfa582aff29906320874ffe9b543fcc6c2423c281f434514f2653e02
generated: "2023-04-10T15:33:17.498321276+03:00"

View File

@@ -0,0 +1,25 @@
name: lidarr
description: Lidarr is a music collection manager for Usenet and BitTorrent users.
annotations:
title: Lidarr
type: application
version: 1.0.0
apiVersion: v2
appVersion: '1.1.3.2982'
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
dependencies:
- name: common
repository: file://../../../common
version: 1.0.3
home: https://github.com/Lidarr/Lidarr
icon: https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/256.png
sources:
- https://github.com/onedr0p/containers/tree/main/apps/lidarr
- https://github.com/truenas/charts/tree/master/charts/lidarr
- https://github.com/Lidarr/Lidarr
keywords:
- media
- music

View File

@@ -0,0 +1,8 @@
# Lidarr
[Lidarr](https://github.com/Lidarr/Lidarr) is a music 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 `Lidarr` directories.
> Afterward, the `Lidarr` 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 @@
# Lidarr
[Lidarr](https://github.com/Lidarr/Lidarr) is a music 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 `Lidarr` directories.
> Afterward, the `Lidarr` 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,11 @@
lidarrNetwork:
webPort: 31000
lidarrRunAs:
user: 1000
group: 1000
lidarrStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config

View File

@@ -0,0 +1,21 @@
lidarrConfig:
additionalEnvs:
- name: LIDARR__API_KEY
value: some-long-api-key
- name: LIDARR__LOG_LEVEL
value: error
lidarrNetwork:
webPort: 31000
lidarrStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config
additionalStorages:
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/pop_music
mountPath: /pop_music
- type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/country_music
mountPath: /country_music

View File

@@ -0,0 +1,8 @@
lidarrNetwork:
webPort: 30000
hostNetwork: true
lidarrStorage:
config:
type: hostPath
hostPath: /mnt/{{ .Release.Namespace }}/config

View File

@@ -0,0 +1,4 @@
icon_url: https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/256.png
categories:
- media
- music

View File

@@ -0,0 +1,225 @@
groups:
- name: Lidarr Configuration
description: Configure Lidarr
- name: User and Group Configuration
description: Configure User and Group for Lidarr
- name: Network Configuration
description: Configure Network for Lidarr
- name: Storage Configuration
description: Configure Storage for Lidarr
- name: Resources Configuration
description: Configure Resources for Lidarr
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: lidarrConfig
label: ""
group: Lidarr Configuration
schema:
type: dict
attrs:
- variable: instanceName
label: Instance Name
description: The name of the Lidarr instance.
schema:
type: string
default: "Lidarr"
required: true
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Lidarr.
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: lidarrRunAs
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: user
label: User ID
description: The user id that Lidarr will run as.
schema:
type: int
min: 1
default: 568
required: true
- variable: group
label: Group ID
description: The group id that Lidarr will run as.
schema:
type: int
min: 1
default: 568
required: true
- variable: lidarrNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: webPort
label: Web Port
description: The port for the Lidarr Web UI.
schema:
type: int
default: 30000
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: lidarrStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: config
label: Lidarr Config Storage
description: The path to store Lidarr 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: additionalStorages
label: Additional Storage
description: Additional storage for Lidarr.
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 Lidarr.
schema:
type: string
default: "4000m"
required: true
- variable: memory
label: Memory
description: Memory limit for Lidarr.
schema:
type: string
default: "8Gi"
required: true

View File

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

View File

@@ -0,0 +1,97 @@
{{- define "lidarr.workload" -}}
workload:
lidarr:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.lidarrNetwork.hostNetwork }}
containers:
lidarr:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: {{ .Values.lidarrRunAs.user }}
runAsGroup: {{ .Values.lidarrRunAs.group }}
{{ with .Values.lidarrConfig.additionalEnvs }}
env:
{{ range $env := . }}
{{ $env.name }}: {{ $env.value }}
{{ end }}
{{ end }}
env:
LIDARR__PORT: {{ .Values.lidarrNetwork.webPort }}
LIDARR__INSTANCE_NAME: {{ .Values.lidarrConfig.instanceName }}
probes:
liveness:
enabled: true
type: http
port: "{{ .Values.lidarrNetwork.webPort }}"
path: /ping
readiness:
enabled: true
type: http
port: "{{ .Values.lidarrNetwork.webPort }}"
path: /ping
startup:
enabled: true
type: http
port: "{{ .Values.lidarrNetwork.webPort }}"
path: /ping
initContainers:
{{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
"UID" .Values.lidarrRunAs.user
"GID" .Values.lidarrRunAs.group
"mode" "check"
"type" "init") | nindent 8 }}
{{/* Service */}}
service:
lidarr:
enabled: true
primary: true
type: NodePort
targetSelector: lidarr
ports:
webui:
enabled: true
primary: true
port: {{ .Values.lidarrNetwork.webPort }}
nodePort: {{ .Values.lidarrNetwork.webPort }}
targetSelector: lidarr
{{/* Persistence */}}
persistence:
config:
enabled: true
type: {{ .Values.lidarrStorage.config.type }}
datasetName: {{ .Values.lidarrStorage.config.datasetName | default "" }}
hostPath: {{ .Values.lidarrStorage.config.hostPath | default "" }}
targetSelector:
lidarr:
lidarr:
mountPath: /config
01-permissions:
mountPath: /mnt/directories/config
tmp:
enabled: true
type: emptyDir
targetSelector:
lidarr:
lidarr:
mountPath: /tmp
{{- range $idx, $storage := .Values.lidarrStorage.additionalStorages }}
{{ printf "lidarr-%v" (int $idx) }}:
enabled: true
type: {{ $storage.type }}
datasetName: {{ $storage.datasetName | default "" }}
hostPath: {{ $storage.hostPath | default "" }}
targetSelector:
lidarr:
lidarr:
mountPath: {{ $storage.mountPath }}
01-permissions:
mountPath: /mnt/directories{{ $storage.mountPath }}
{{- end }}
{{- end -}}

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
image:
repository: ghcr.io/onedr0p/lidarr-develop
pullPolicy: IfNotPresent
tag: '1.1.3.2982'
resources:
limits:
cpu: 4000m
memory: 8Gi
lidarrConfig:
instanceName: Lidarr
additionalEnvs: []
lidarrNetwork:
webPort: 30000
hostNetwork: false
lidarrRunAs:
user: 568
group: 568
lidarrStorage:
config:
type: ixVolume
hostPath: ''
datasetName: config
additionalStorages: []