infra/stacks/audiobookshelf/main.tf
Viktor Barzin 11b3d92684
[ci skip] migrate 29 services from inline NFS to CSI-backed PV/PVC
Batch migration of all single-volume and simple multi-volume stacks.
All services verified healthy after migration. Uses nfs-truenas
StorageClass with soft,timeo=30,retrans=3 mount options to eliminate
stale NFS mount hangs.

Services: atuin, audiobookshelf, calibre, changedetection, diun,
excalidraw, forgejo, freshrss, grampsweb, hackmd, health,
isponsorblocktv, matrix, meshcentral, n8n, navidrome, ntfy, ollama,
onlyoffice, owntracks, paperless-ngx, poison-fountain, send,
stirling-pdf, tandoor, wealthfolio, whisper, woodpecker, ytdlp
2026-03-02 00:15:39 +00:00

173 lines
4.2 KiB
HCL

variable "tls_secret_name" { type = string }
variable "nfs_server" { type = string }
resource "kubernetes_namespace" "audiobookshelf" {
metadata {
name = "audiobookshelf"
labels = {
"istio-injection" : "disabled"
tier = local.tiers.aux
}
}
}
module "tls_secret" {
source = "../../modules/kubernetes/setup_tls_secret"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
tls_secret_name = var.tls_secret_name
}
module "nfs_audiobooks" {
source = "../../modules/kubernetes/nfs_volume"
name = "audiobookshelf-audiobooks"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
nfs_server = var.nfs_server
nfs_path = "/mnt/main/audiobookshelf/audiobooks"
}
module "nfs_podcasts" {
source = "../../modules/kubernetes/nfs_volume"
name = "audiobookshelf-podcasts"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
nfs_server = var.nfs_server
nfs_path = "/mnt/main/audiobookshelf/podcasts"
}
module "nfs_config" {
source = "../../modules/kubernetes/nfs_volume"
name = "audiobookshelf-config"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
nfs_server = var.nfs_server
nfs_path = "/mnt/main/audiobookshelf/config"
}
module "nfs_metadata" {
source = "../../modules/kubernetes/nfs_volume"
name = "audiobookshelf-metadata"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
nfs_server = var.nfs_server
nfs_path = "/mnt/main/audiobookshelf/metadata"
}
resource "kubernetes_deployment" "audiobookshelf" {
metadata {
name = "audiobookshelf"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
labels = {
app = "audiobookshelf"
tier = local.tiers.aux
}
annotations = {
"reloader.stakater.com/search" = "true"
}
}
spec {
replicas = 1
strategy {
type = "Recreate"
}
selector {
match_labels = {
app = "audiobookshelf"
}
}
template {
metadata {
labels = {
app = "audiobookshelf"
}
}
spec {
container {
image = "ghcr.io/advplyr/audiobookshelf:2.32.1"
name = "audiobookshelf"
port {
container_port = 80
}
volume_mount {
name = "audiobooks"
mount_path = "/audiobooks"
}
volume_mount {
name = "podcasts"
mount_path = "/podcasts"
}
volume_mount {
name = "config"
mount_path = "/config"
}
volume_mount {
name = "metadata"
mount_path = "/metadata"
}
resources {
requests = {
cpu = "15m"
memory = "64Mi"
}
limits = {
cpu = "250m"
memory = "512Mi"
}
}
}
volume {
name = "audiobooks"
persistent_volume_claim {
claim_name = module.nfs_audiobooks.claim_name
}
}
volume {
name = "podcasts"
persistent_volume_claim {
claim_name = module.nfs_podcasts.claim_name
}
}
volume {
name = "config"
persistent_volume_claim {
claim_name = module.nfs_config.claim_name
}
}
volume {
name = "metadata"
persistent_volume_claim {
claim_name = module.nfs_metadata.claim_name
}
}
}
}
}
}
resource "kubernetes_service" "audiobookshelf" {
metadata {
name = "audiobookshelf"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
labels = {
"app" = "audiobookshelf"
}
}
spec {
selector = {
app = "audiobookshelf"
}
port {
name = "http"
target_port = 80
port = 80
protocol = "TCP"
}
}
}
module "ingress" {
source = "../../modules/kubernetes/ingress_factory"
namespace = kubernetes_namespace.audiobookshelf.metadata[0].name
name = "audiobookshelf"
tls_secret_name = var.tls_secret_name
rybbit_site_id = "b38fda4285df"
}