infra/stacks/ntfy/main.tf
Viktor Barzin 28ac1382d1 Remove all CPU limits cluster-wide to eliminate CFS throttling
CPU limits cause CFS throttling even when nodes have idle capacity.
Move to a request-only CPU model: keep CPU requests for scheduling
fairness but remove all CPU limits. Memory limits stay (incompressible).

Changes across 108 files:
- Kyverno LimitRange policy: remove cpu from default/max in all 6 tiers
- Kyverno ResourceQuota policy: remove limits.cpu from all 5 tiers
- Custom ResourceQuotas: remove limits.cpu from 8 namespace quotas
- Custom LimitRanges: remove cpu from default/max (nextcloud, onlyoffice)
- RBAC module: remove cpu_limits variable and quota reference
- Freedify factory: remove cpu_limit variable and limits reference
- 86 deployment files: remove cpu from all limits blocks
- 6 Helm values files: remove cpu under limits sections
2026-03-18 08:03:58 +00:00

181 lines
4.1 KiB
HCL

variable "tls_secret_name" {
type = string
sensitive = true
}
variable "nfs_server" { type = string }
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
}
module "nfs_data" {
source = "../../modules/kubernetes/nfs_volume"
name = "ntfy-data"
namespace = kubernetes_namespace.ntfy.metadata[0].name
nfs_server = var.nfs_server
nfs_path = "/mnt/main/ntfy"
}
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
}
liveness_probe {
http_get {
path = "/v1/health"
port = 80
}
initial_delay_seconds = 15
period_seconds = 30
timeout_seconds = 5
failure_threshold = 5
}
readiness_probe {
http_get {
path = "/v1/health"
port = 80
}
initial_delay_seconds = 5
period_seconds = 30
timeout_seconds = 5
failure_threshold = 3
}
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/"
}
resources {
requests = {
cpu = "10m"
memory = "32Mi"
}
limits = {
memory = "128Mi"
}
}
}
volume {
name = "data"
persistent_volume_claim {
claim_name = module.nfs_data.claim_name
}
}
}
}
}
}
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
extra_annotations = {
"gethomepage.dev/enabled" = "true"
"gethomepage.dev/name" = "ntfy"
"gethomepage.dev/description" = "Push notifications"
"gethomepage.dev/icon" = "ntfy.png"
"gethomepage.dev/group" = "Productivity"
"gethomepage.dev/pod-selector" = ""
}
}