diff --git a/config.tfvars b/config.tfvars index a6e00fb2..5293e1b2 100644 Binary files a/config.tfvars and b/config.tfvars differ diff --git a/stacks/servarr/audiobook-search/main.tf b/stacks/servarr/audiobook-search/main.tf new file mode 100644 index 00000000..86f9cfe8 --- /dev/null +++ b/stacks/servarr/audiobook-search/main.tf @@ -0,0 +1,120 @@ +variable "tls_secret_name" {} +variable "tier" { type = string } +variable "audiobookshelf_token" { + type = string + sensitive = true +} +variable "qbittorrent_password" { + type = string + sensitive = true +} + +resource "kubernetes_deployment" "audiobook_search" { + metadata { + name = "audiobook-search" + namespace = "servarr" + labels = { + app = "audiobook-search" + tier = var.tier + } + } + spec { + replicas = 1 + selector { + match_labels = { + app = "audiobook-search" + } + } + template { + metadata { + labels = { + app = "audiobook-search" + } + } + spec { + container { + image = "viktorbarzin/audiobook-search:latest" + image_pull_policy = "Always" + name = "audiobook-search" + + port { + container_port = 8000 + } + env { + name = "QBITTORRENT_URL" + value = "http://qbittorrent.servarr.svc.cluster.local" + } + env { + name = "QBITTORRENT_PASS" + value = var.qbittorrent_password + } + env { + name = "AUDIOBOOKSHELF_URL" + value = "http://audiobookshelf.audiobookshelf.svc.cluster.local" + } + env { + name = "AUDIOBOOKSHELF_TOKEN" + value = var.audiobookshelf_token + } + resources { + requests = { + cpu = "10m" + memory = "64Mi" + } + limits = { + memory = "128Mi" + } + } + liveness_probe { + http_get { + path = "/health" + port = 8000 + } + initial_delay_seconds = 10 + period_seconds = 30 + } + } + } + } + } + lifecycle { + ignore_changes = [spec[0].template[0].spec[0].dns_config] + } +} + +resource "kubernetes_service" "audiobook_search" { + metadata { + name = "audiobook-search" + namespace = "servarr" + labels = { + app = "audiobook-search" + } + } + + spec { + selector = { + app = "audiobook-search" + } + port { + name = "http" + port = 80 + target_port = 8000 + } + } +} + +module "ingress" { + source = "../../../modules/kubernetes/ingress_factory" + namespace = "servarr" + name = "audiobook-search" + tls_secret_name = var.tls_secret_name + protected = true + extra_annotations = { + "gethomepage.dev/enabled" = "true" + "gethomepage.dev/name" = "Audiobook Search" + "gethomepage.dev/description" = "Search & download audiobooks" + "gethomepage.dev/icon" = "audiobookshelf.png" + "gethomepage.dev/group" = "Media & Entertainment" + "gethomepage.dev/pod-selector" = "" + } +} diff --git a/stacks/servarr/main.tf b/stacks/servarr/main.tf index 9acd350c..99db1ab5 100644 --- a/stacks/servarr/main.tf +++ b/stacks/servarr/main.tf @@ -114,3 +114,11 @@ module "aiostreams" { tier = local.tiers.aux nfs_server = var.nfs_server } + +module "audiobook_search" { + source = "./audiobook-search" + tls_secret_name = var.tls_secret_name + tier = local.tiers.aux + audiobookshelf_token = data.kubernetes_secret.eso_secrets.data["audiobookshelf_api_token"] + qbittorrent_password = data.kubernetes_secret.eso_secrets.data["qbittorrent_password"] +} diff --git a/stacks/servarr/qbittorrent/main.tf b/stacks/servarr/qbittorrent/main.tf index 7c63f2e2..ab5fd43a 100644 --- a/stacks/servarr/qbittorrent/main.tf +++ b/stacks/servarr/qbittorrent/main.tf @@ -23,6 +23,14 @@ module "nfs_downloads" { nfs_path = "/mnt/main/servarr/downloads" } +module "nfs_audiobooks" { + source = "../../../modules/kubernetes/nfs_volume" + name = "servarr-qbittorrent-audiobooks" + namespace = "servarr" + nfs_server = var.nfs_server + nfs_path = "/mnt/main/audiobookshelf/audiobooks" +} + resource "kubernetes_deployment" "qbittorrent" { metadata { name = "qbittorrent" @@ -80,6 +88,10 @@ resource "kubernetes_deployment" "qbittorrent" { name = "downloads" mount_path = "/downloads" } + volume_mount { + name = "audiobooks" + mount_path = "/audiobooks" + } } volume { name = "data" @@ -93,6 +105,12 @@ resource "kubernetes_deployment" "qbittorrent" { claim_name = module.nfs_downloads.claim_name } } + volume { + name = "audiobooks" + persistent_volume_claim { + claim_name = module.nfs_audiobooks.claim_name + } + } } } }