mirror of
https://github.com/auricom/home-cluster.git
synced 2025-09-17 18:24:14 +02:00
🚀 lidarr postgresql
This commit is contained in:
@@ -20,7 +20,7 @@ spec:
|
||||
- name: POSTGRES_HOST
|
||||
value: ${POSTGRES_HOST}
|
||||
- name: POSTGRES_DB
|
||||
value: "authelia,bazarr,freshrss,gatus,ghostfolio,kresus,immich,invidious,joplin,linkding,lldap,lychee,outline,paperless,prowlarr_main,pushover-notifier,radarr_main,sharry,tandoor,vaultwarden,vikunja,wallabag"
|
||||
value: "authelia,bazarr,freshrss,gatus,ghostfolio,kresus,immich,invidious,joplin,lidarr,linkding,lldap,lychee,outline,paperless,prowlarr_main,pushover-notifier,radarr_main,sharry,tandoor,vaultwarden,vikunja,wallabag"
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
@@ -12,7 +12,29 @@ spec:
|
||||
target:
|
||||
name: lidarr-secret
|
||||
creationPolicy: Owner
|
||||
template:
|
||||
engineVersion: v2
|
||||
data:
|
||||
# App
|
||||
LIDARR__API_KEY: "{{ .LIDARR__API_KEY }}"
|
||||
LIDARR__POSTGRES_HOST: &dbHost postgres-rw.default.svc.cluster.local
|
||||
LIDARR__POSTGRES_PORT: "5432"
|
||||
LIDARR__POSTGRES_USER: &dbUser "{{ .LIDARR__POSTGRES_USER }}"
|
||||
LIDARR__POSTGRES_PASSWORD: &dbPass "{{ .LIDARR__POSTGRES_PASSWORD }}"
|
||||
LIDARR__POSTGRES_MAIN_DB: lidarr_main
|
||||
LIDARR__POSTGRES_LOG_DB: lidarr_log
|
||||
PUSHOVER_API_TOKEN: "{{ .PUSHOVER_API_TOKEN }}"
|
||||
PUSHOVER_USER_KEY: "{{ .PUSHOVER_USER_KEY }}"
|
||||
# Postgres Init
|
||||
INIT_POSTGRES_DBNAME: lidarr_main lidarr_log
|
||||
INIT_POSTGRES_HOST: *dbHost
|
||||
INIT_POSTGRES_USER: *dbUser
|
||||
INIT_POSTGRES_PASS: *dbPass
|
||||
INIT_POSTGRES_SUPER_PASS: "{{ .POSTGRES_SUPER_PASS }}"
|
||||
dataFrom:
|
||||
- extract:
|
||||
# LIDARR__API_KEY
|
||||
key: cloudnative-pg
|
||||
- extract:
|
||||
key: pushover
|
||||
- extract:
|
||||
key: lidarr
|
||||
|
@@ -35,9 +35,18 @@ spec:
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
controllers:
|
||||
main:
|
||||
type: statefulset
|
||||
annotations:
|
||||
reloader.stakater.com/auto: "true"
|
||||
configmap.reloader.stakater.com/reload: "lidarr-pushover"
|
||||
initContainers:
|
||||
init-db:
|
||||
image:
|
||||
repository: ghcr.io/auricom/postgres-init
|
||||
tag: 15.4@sha256:83e1abf06be5741bdfb8cb53fc03a1ade6e6b5ec7b92a8aac0c69ba5dc7e51f0
|
||||
pullPolicy: IfNotPresent
|
||||
envFrom: &envFrom
|
||||
- secretRef:
|
||||
name: lidarr-secret
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
@@ -48,6 +57,7 @@ spec:
|
||||
LIDARR__INSTANCE_NAME: Lidarr
|
||||
LIDARR__PORT: &port 8080
|
||||
LIDARR__LOG_LEVEL: info
|
||||
PUSHOVER_APP_URL: &host "{{ .Release.Name }}.${SECRET_CLUSTER_DOMAIN}"
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: lidarr-secret
|
||||
@@ -57,14 +67,6 @@ spec:
|
||||
memory: 250Mi
|
||||
limits:
|
||||
memory: 2000Mi
|
||||
statefulset:
|
||||
volumeClaimTemplates:
|
||||
- name: config
|
||||
accessMode: ReadWriteOnce
|
||||
size: 20Gi
|
||||
storageClass: rook-ceph-block
|
||||
globalMounts:
|
||||
- path: /config
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
@@ -78,7 +80,7 @@ spec:
|
||||
auth.home.arpa/enabled: "true"
|
||||
hajimari.io/icon: mdi:headphones
|
||||
hosts:
|
||||
- host: &host "{{ .Release.Name }}.${SECRET_CLUSTER_DOMAIN}"
|
||||
- host: *host
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
@@ -88,17 +90,26 @@ spec:
|
||||
- hosts:
|
||||
- *host
|
||||
persistence:
|
||||
music:
|
||||
config:
|
||||
enabled: true
|
||||
type: emptyDir
|
||||
music:
|
||||
type: nfs
|
||||
server: "${LOCAL_LAN_TRUENAS}"
|
||||
path: /mnt/storage/music
|
||||
globalMounts:
|
||||
- path: /mnt/storage/music
|
||||
downloads:
|
||||
enabled: true
|
||||
type: nfs
|
||||
server: "${LOCAL_LAN_TRUENAS}"
|
||||
path: /mnt/storage/downloads
|
||||
globalMounts:
|
||||
- path: /mnt/storage/downloads
|
||||
scripts:
|
||||
type: configMap
|
||||
name: lidarr-pushover
|
||||
defaultMode: 0775
|
||||
globalMounts:
|
||||
- path: /scripts/pushover-notify.sh
|
||||
subPath: pushover-notify.sh
|
||||
readOnly: true
|
||||
|
@@ -7,4 +7,11 @@ resources:
|
||||
- ./externalsecret.yaml
|
||||
- ./gatus.yaml
|
||||
- ./helmrelease.yaml
|
||||
- ./volsync.yaml
|
||||
configMapGenerator:
|
||||
- name: lidarr-pushover
|
||||
files:
|
||||
- ./scripts/pushover-notify.sh
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
annotations:
|
||||
kustomize.toolkit.fluxcd.io/substitute: disabled
|
||||
|
106
kubernetes/apps/default/lidarr/app/scripts/pushover-notify.sh
Executable file
106
kubernetes/apps/default/lidarr/app/scripts/pushover-notify.sh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PUSHOVER_DEBUG="${PUSHOVER_DEBUG:-"true"}"
|
||||
# kubectl port-forward service/lidarr -n default 7878:7878
|
||||
# export PUSHOVER_STARR_INSTANCE_NAME=Lidarr;
|
||||
# export PUSHOVER_APP_URL="";
|
||||
# export PUSHOVER_API_TOKEN="";
|
||||
# export PUSHOVER_USER_KEY="";
|
||||
# export lidarr_eventtype=Download;
|
||||
# ./notify.sh
|
||||
|
||||
CONFIG_FILE="/config/config.xml" && [[ "${PUSHOVER_DEBUG}" == "true" ]] && CONFIG_FILE="config.xml"
|
||||
ERRORS=()
|
||||
|
||||
#
|
||||
# Discoverable variables
|
||||
#
|
||||
# shellcheck disable=SC2086
|
||||
PUSHOVER_STARR_PORT="$(xmlstarlet sel -t -v "//Port" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_PORT}" ]] && ERRORS+=("PUSHOVER_STARR_PORT not defined")
|
||||
PUSHOVER_STARR_APIKEY="$(xmlstarlet sel -t -v "//ApiKey" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_APIKEY}" ]] && ERRORS+=("PUSHOVER_STARR_APIKEY not defined")
|
||||
PUSHOVER_STARR_INSTANCE_NAME="$(xmlstarlet sel -t -v "//InstanceName" -nl ${CONFIG_FILE})" && [[ -z "${PUSHOVER_STARR_INSTANCE_NAME}" ]] && ERRORS+=("PUSHOVER_STARR_INSTANCE_NAME not defined")
|
||||
|
||||
#
|
||||
# Configurable variables
|
||||
#
|
||||
# Required
|
||||
PUSHOVER_APP_URL="${PUSHOVER_APP_URL:-}" && [[ -z "${PUSHOVER_APP_URL}" ]] && ERRORS+=("PUSHOVER_APP_URL not defined")
|
||||
PUSHOVER_USER_KEY="${PUSHOVER_USER_KEY:-}" && [[ -z "${PUSHOVER_USER_KEY}" ]] && ERRORS+=("PUSHOVER_USER_KEY not defined")
|
||||
PUSHOVER_API_TOKEN="${PUSHOVER_API_TOKEN:-}" && [[ -z "${PUSHOVER_API_TOKEN}" ]] && ERRORS+=("PUSHOVER_API_TOKEN not defined")
|
||||
# Optional
|
||||
PUSHOVER_DEVICE="${PUSHOVER_DEVICE:-}"
|
||||
PUSHOVER_PRIORITY="${PUSHOVER_PRIORITY:-"-2"}"
|
||||
PUSHOVER_SOUND="${PUSHOVER_SOUND:-}"
|
||||
|
||||
#
|
||||
# Print defined variables
|
||||
#
|
||||
for pushover_vars in ${!PUSHOVER_*}
|
||||
do
|
||||
declare -n var="${pushover_vars}"
|
||||
[[ -n "${var}" && "${PUSHOVER_DEBUG}" = "true" ]] && printf "%s - %s=%s\n" "$(date)" "${!var}" "${var}"
|
||||
done
|
||||
|
||||
#
|
||||
# Validate required variables are set
|
||||
#
|
||||
if [ ${#ERRORS[@]} -gt 0 ]; then
|
||||
for err in "${ERRORS[@]}"; do printf "%s - Undefined variable %s\n" "$(date)" "${err}" >&2; done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Send Notification on Test
|
||||
#
|
||||
if [[ "${lidarr_eventtype:-}" == "Test" ]]; then
|
||||
PUSHOVER_TITLE="Test Notification"
|
||||
PUSHOVER_MESSAGE="Howdy this is a test notification from ${PUSHOVER_STARR_INSTANCE_NAME}"
|
||||
fi
|
||||
|
||||
#
|
||||
# Send notification on Download or Upgrade
|
||||
#
|
||||
if [[ "${lidarr_eventtype:-}" == "Download" ]]; then
|
||||
printf -v PUSHOVER_TITLE "%s (%s) [%s]" \
|
||||
"${lidarr_artist_name:-"Michael Jackson"}" \
|
||||
"${lidarr_album_releasedate:-"1982"}" \
|
||||
"${lidarr_album_title:-"Thriller"}"
|
||||
# "${lidarr_trackfile_quality:-""}"
|
||||
printf -v PUSHOVER_MESSAGE "%s" \
|
||||
"$(curl --silent --header "X-Api-Key:${PUSHOVER_STARR_APIKEY}" "http://localhost:${PUSHOVER_STARR_PORT}/api/v1/album/${lidarr_album_id:-"2619"}" \
|
||||
| jq -r ".overview")"
|
||||
printf -v PUSHOVER_URL "https://%s/album/%s" \
|
||||
"${PUSHOVER_APP_URL}" \
|
||||
"${lidarr_artist_mbid:-"122"}"
|
||||
printf -v PUSHOVER_URL_TITLE "View album in %s" \
|
||||
"${PUSHOVER_STARR_INSTANCE_NAME}"
|
||||
fi
|
||||
|
||||
notification=$(jq -n \
|
||||
--arg token "${PUSHOVER_API_TOKEN}" \
|
||||
--arg user "${PUSHOVER_USER_KEY}" \
|
||||
--arg title "${PUSHOVER_TITLE}" \
|
||||
--arg message "${PUSHOVER_MESSAGE:-"Unable to obtain album details"}" \
|
||||
--arg url "${PUSHOVER_URL}" \
|
||||
--arg url_title "${PUSHOVER_URL_TITLE}" \
|
||||
--arg priority "${PUSHOVER_PRIORITY}" \
|
||||
--arg sound "${PUSHOVER_SOUND}" \
|
||||
--arg device "${PUSHOVER_DEVICE}" \
|
||||
'{token: $token, user: $user, title: $title, message: $message, url: $url, url_title: $url_title, priority: $priority, sound: $sound, device: $device}' \
|
||||
)
|
||||
|
||||
status_code=$(curl \
|
||||
--write-out "%{http_code}" \
|
||||
--silent \
|
||||
--output /dev/null \
|
||||
--header "Content-Type: application/json" \
|
||||
--data-binary "${notification}" \
|
||||
--request POST "https://api.pushover.net/1/messages.json" \
|
||||
)
|
||||
|
||||
if [[ "${status_code}" -ne 200 ]] ; then
|
||||
printf "%s - Unable to send notification with status code %s and payload: %s\n" "$(date)" "${status_code}" "$(echo "${notification}" | jq -c)" >&2
|
||||
exit 1
|
||||
else
|
||||
printf "%s - Sent notification with status code %s and payload: %s\n" "$(date)" "${status_code}" "$(echo "${notification}" | jq -c)"
|
||||
fi
|
@@ -1,49 +0,0 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://kubernetes-schemas.devbu.io/external-secrets.io/externalsecret_v1beta1.json
|
||||
apiVersion: external-secrets.io/v1beta1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: lidarr-restic
|
||||
namespace: default
|
||||
spec:
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: onepassword-connect
|
||||
target:
|
||||
name: lidarr-restic-secret
|
||||
creationPolicy: Owner
|
||||
template:
|
||||
engineVersion: v2
|
||||
data:
|
||||
RESTIC_REPOSITORY: '{{ .REPOSITORY_TEMPLATE }}/lidarr'
|
||||
RESTIC_PASSWORD: '{{ .RESTIC_PASSWORD }}'
|
||||
AWS_ACCESS_KEY_ID: '{{ .AWS_ACCESS_KEY_ID }}'
|
||||
AWS_SECRET_ACCESS_KEY: '{{ .AWS_SECRET_ACCESS_KEY }}'
|
||||
dataFrom:
|
||||
- extract:
|
||||
key: volsync-restic-template
|
||||
---
|
||||
# yaml-language-server: $schema=https://kubernetes-schemas.devbu.io/volsync.backube/replicationsource_v1alpha1.json
|
||||
apiVersion: volsync.backube/v1alpha1
|
||||
kind: ReplicationSource
|
||||
metadata:
|
||||
name: lidarr
|
||||
namespace: default
|
||||
spec:
|
||||
sourcePVC: config-lidarr-0
|
||||
trigger:
|
||||
schedule: "0 7 * * *"
|
||||
restic:
|
||||
copyMethod: Snapshot
|
||||
pruneIntervalDays: 7
|
||||
repository: lidarr-restic-secret
|
||||
cacheCapacity: 10Gi
|
||||
volumeSnapshotClassName: csi-ceph-blockpool
|
||||
storageClassName: rook-ceph-block
|
||||
moverSecurityContext:
|
||||
runAsUser: 568
|
||||
runAsGroup: 568
|
||||
fsGroup: 568
|
||||
retain:
|
||||
daily: 7
|
||||
within: 3d
|
Reference in New Issue
Block a user