infra/stacks/ntfy/main.tf
Viktor Barzin c7c7047f1c [ci skip] Flatten module wrappers into stack roots
Remove the module "xxx" { source = "./module" } indirection layer
from all 66 service stacks. Resources are now defined directly in
each stack's main.tf instead of through a wrapper module.

- Merge module/main.tf contents into stack main.tf
- Apply variable replacements (var.tier -> local.tiers.X, renamed vars)
- Fix shared module paths (one fewer ../ at each level)
- Move extra files/dirs (factory/, chart_values, subdirs) to stack root
- Update state files to strip module.<name>. prefix
- Update CLAUDE.md to reflect flat structure

Verified: terragrunt plan shows 0 add, 0 destroy across all stacks.
2026-02-22 15:13:55 +00:00

142 lines
2.9 KiB
HCL

variable "tls_secret_name" { type = string }
locals {
tiers = {
core = "0-core"
cluster = "1-cluster"
gpu = "2-gpu"
edge = "3-edge"
aux = "4-aux"
}
}
resource "kubernetes_namespace" "ntfy" {
metadata {
name = "ntfy"
labels = {
tier = local.tiers.aux
}
}
}
module "tls_secret" {
source = "../../modules/kubernetes/setup_tls_secret"
namespace = kubernetes_namespace.ntfy.metadata[0].name
tls_secret_name = var.tls_secret_name
}
resource "kubernetes_deployment" "ntfy" {
metadata {
name = "ntfy"
namespace = kubernetes_namespace.ntfy.metadata[0].name
labels = {
app = "ntfy"
tier = local.tiers.aux
}
annotations = {
"reloader.stakater.com/search" = "true"
}
}
spec {
replicas = 1
strategy {
type = "RollingUpdate"
}
selector {
match_labels = {
app = "ntfy"
}
}
template {
metadata {
labels = {
app = "ntfy"
}
}
spec {
container {
image = "binwiederhier/ntfy"
name = "ntfy"
args = ["serve"]
port {
container_port = 80
}
env {
name = "NTFY_BASE_URL"
value = "https://ntfy.viktorbarzin.me"
}
env {
name = "NTFY_UPSTREAM_BASE_URL"
# value = "https://ntfy.viktorbarzin.me"
value = "https://ntfy.sh"
}
env {
name = "NTFY_BEHIND_PROXY"
value = true
}
env {
name = "NTFY_ENABLE_LOGIN"
value = true
}
env {
name = "NTFY_AUTH_FILE"
value = "/var/lib/ntfy/user.db"
}
env {
name = "NTFY_AUTH_DEFAULT_ACCESS"
value = "deny-all"
}
env {
name = "NTFY_ENABLE_METRICS"
value = true
}
volume_mount {
name = "data"
mount_path = "/var/lib/ntfy/"
}
}
volume {
name = "data"
nfs {
server = "10.0.10.15"
path = "/mnt/main/ntfy"
}
}
}
}
}
}
resource "kubernetes_service" "ntfy" {
metadata {
name = "ntfy"
namespace = kubernetes_namespace.ntfy.metadata[0].name
labels = {
"app" = "ntfy"
}
annotations = {
"prometheus.io/scrape" = "true"
"prometheus.io/path" = "/metrics"
"prometheus.io/port" = "80"
}
}
spec {
selector = {
app = "ntfy"
}
port {
name = "http"
target_port = 80
port = 80
}
}
}
module "ingress" {
source = "../../modules/kubernetes/ingress_factory"
namespace = kubernetes_namespace.ntfy.metadata[0].name
name = "ntfy"
tls_secret_name = var.tls_secret_name
}