infra/stacks/audiobookshelf/main.tf
Viktor Barzin db68067925
[ci skip] phase 5+6: update CI pipelines for SOPS, add sensitive=true to secret vars
Phase 5 — CI pipelines:
- default.yml: add SOPS decrypt in prepare step, change git add . to
  specific paths (stacks/ state/ .woodpecker/), cleanup on success+failure
- renew-tls.yml: change git add . to git add secrets/ state/

Phase 6 — sensitive=true:
- Add sensitive = true to 256 variable declarations across 149 stack files
- Prevents secret values from appearing in terraform plan output
- Does NOT modify shared modules (ingress_factory, nfs_volume) to avoid
  breaking module interface contracts

Note: CI pipeline SOPS decryption requires sops_age_key Woodpecker secret
to be created before the pipeline will work with SOPS. Until then, the old
terraform.tfvars path continues to function.
2026-03-07 14:30:36 +00:00

196 lines
4.8 KiB
HCL

variable "tls_secret_name" {
type = string
sensitive = true
}
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
}
liveness_probe {
http_get {
path = "/healthcheck"
port = 80
}
initial_delay_seconds = 15
period_seconds = 30
timeout_seconds = 5
failure_threshold = 5
}
readiness_probe {
http_get {
path = "/healthcheck"
port = 80
}
initial_delay_seconds = 5
period_seconds = 30
timeout_seconds = 5
failure_threshold = 3
}
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"
}