infra/stacks/servarr/soulseek/main.tf
Viktor Barzin 478629c1ee keel+anubis: extend sweep to non-V2 raw deployments; fix anubis replicas validation
Second-tier keel drift: actualbudget, mailserver (docker-mailserver + roundcube),
servarr (8 deployments), and authentik pgbouncer are live-enrolled (Kyverno injects
keel.sh/policy=patch) and drifting, but never had the V2 block in Terraform. Added
the full block (KYVERNO_LIFECYCLE_V2 + keel.sh/match-tag + per-container
KEEL_IGNORE_IMAGE + KEEL_LIFECYCLE_V1) to all 13 deployments. The docker-mailserver
deployment had no resource-level lifecycle at all — added one.

Also fixes a pre-existing bug in modules/kubernetes/anubis_instance: the `replicas`
validation `var.replicas == null || (...)` doesn't null-short-circuit in the current
TF version, failing apply on every single-replica Anubis site (blog, cyberchef,
f1-stream, homepage, jsoncrack, kms, postiz, real-estate-crawler, travel_blog) with
"argument must not be null". Switched to a null-safe ternary.

Verified: actualbudget plan shows no image drift (http-api 26.5.2 downgrade prevented).
The anubis module change triggers a full platform apply.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 06:02:24 +00:00

127 lines
3.1 KiB
HCL

variable "tls_secret_name" {}
variable "tier" { type = string }
variable "nfs_server" { type = string }
module "nfs_lidarr_host" {
source = "../../../modules/kubernetes/nfs_volume"
name = "servarr-soulseek-lidarr-host"
namespace = "servarr"
nfs_server = "192.168.1.127"
nfs_path = "/srv/nfs/servarr/lidarr"
}
resource "kubernetes_deployment" "soulseek" {
metadata {
name = "soulseek"
namespace = "servarr"
labels = {
app = "soulseek"
tier = var.tier
}
annotations = {
"reloader.stakater.com/search" = "true"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "soulseek"
}
}
template {
metadata {
labels = {
app = "soulseek"
}
}
spec {
container {
image = "realies/soulseek"
name = "soulseek"
port {
name = "soulseek"
container_port = 6080
}
env {
name = "PUID"
value = 1000
}
env {
name = "PGID"
value = 1000
}
volume_mount {
name = "config"
mount_path = "/data/.SoulseekQt"
sub_path = "soulseek/config"
}
volume_mount {
name = "downloads"
mount_path = "/data/Soulseek Downloads"
sub_path = "soulseek/downloads"
}
}
volume {
name = "config"
persistent_volume_claim {
claim_name = module.nfs_lidarr_host.claim_name
}
}
volume {
name = "downloads"
persistent_volume_claim {
claim_name = module.nfs_lidarr_host.claim_name
}
}
}
}
}
lifecycle {
# KYVERNO_LIFECYCLE_V1: Kyverno admission webhook mutates dns_config with ndots=2
ignore_changes = [
spec[0].template[0].spec[0].dns_config, # KYVERNO_LIFECYCLE_V1
metadata[0].annotations["keel.sh/policy"],
metadata[0].annotations["keel.sh/trigger"],
metadata[0].annotations["keel.sh/pollSchedule"], # KYVERNO_LIFECYCLE_V2
metadata[0].annotations["keel.sh/match-tag"],
spec[0].template[0].spec[0].container[0].image, # KEEL_IGNORE_IMAGE — Keel manages tag updates
metadata[0].annotations["kubernetes.io/change-cause"],
metadata[0].annotations["deployment.kubernetes.io/revision"],
spec[0].template[0].metadata[0].annotations["keel.sh/update-time"], # KEEL_LIFECYCLE_V1
]
}
}
resource "kubernetes_service" "soulseek" {
metadata {
name = "soulseek"
namespace = "servarr"
labels = {
app = "soulseek"
}
}
spec {
selector = {
app = "soulseek"
}
port {
name = "http"
port = 80
target_port = 6080
}
}
}
module "ingress" {
source = "../../../modules/kubernetes/ingress_factory"
dns_type = "non-proxied"
namespace = "servarr"
name = "soulseek"
tls_secret_name = var.tls_secret_name
auth = "required"
}