2026-03-07 14:30:36 +00:00
|
|
|
variable "roundcube_db_password" {
|
2026-03-14 08:51:45 +00:00
|
|
|
type = string
|
2026-03-07 14:30:36 +00:00
|
|
|
sensitive = true
|
|
|
|
|
}
|
[ci skip] Infrastructure hardening: security, monitoring, reliability, maintainability
Phase 1 - Critical Security:
- Netbox: move hardcoded DB/superuser passwords to variables
- MeshCentral: disable public registration, add Authentik auth
- Traefik: disable insecure API dashboard (api.insecure=false)
- Traefik: configure forwarded headers with Cloudflare trusted IPs
Phase 2 - Security Hardening:
- Add security headers middleware (HSTS, X-Frame-Options, nosniff, etc.)
- Add Kyverno pod security policies in audit mode (privileged, host
namespaces, SYS_ADMIN, trusted registries)
- Tighten rate limiting (avg=10, burst=50)
- Add Authentik protection to grampsweb
Phase 3 - Monitoring & Alerting:
- Add critical service alerts (PostgreSQL, MySQL, Redis, Headscale,
Authentik, Loki)
- Increase Loki retention from 7 to 30 days (720h)
- Add predictive PV filling alert (predict_linear)
- Re-enable Hackmd and Privatebin down alerts
Phase 4 - Reliability:
- Add resource requests/limits to Redis, DBaaS, Technitium, Headscale,
Vaultwarden, Uptime Kuma
- Increase Alloy DaemonSet memory to 512Mi/1Gi
Phase 6 - Maintainability:
- Extract duplicated tiers locals to terragrunt.hcl generate block
(removed from 67 stacks)
- Replace hardcoded NFS IP 10.0.10.15 with var.nfs_server (114
instances across 63 files)
- Replace hardcoded Redis/PostgreSQL/MySQL/Ollama/mail host references
with variables across ~35 stacks
- Migrate xray raw ingress resources to ingress_factory modules
2026-02-23 22:05:28 +00:00
|
|
|
variable "mysql_host" { type = string }
|
2025-10-18 13:23:53 +00:00
|
|
|
|
[ci skip] complete NFS CSI migration: complex stacks + platform modules
Migrate remaining multi-volume stacks and all platform modules from
inline NFS volumes to CSI-backed PV/PVC with nfs-truenas StorageClass
(soft,timeo=30,retrans=3 mount options).
Complex stacks: openclaw (4 vols), immich (8 vols), frigate (2 vols),
nextcloud (2 vols + old PV replaced), rybbit (1 vol)
Remaining stacks: affine, ebook2audiobook, f1-stream, osm_routing,
real-estate-crawler
Platform modules: monitoring (prometheus, loki, alertmanager PVs
converted from native NFS to CSI), redis, dbaas, technitium,
headscale, vaultwarden, uptime-kuma, mailserver, infra-maintenance
2026-03-02 01:24:07 +00:00
|
|
|
module "nfs_roundcube_html" {
|
|
|
|
|
source = "../../../../modules/kubernetes/nfs_volume"
|
|
|
|
|
name = "roundcubemail-html"
|
|
|
|
|
namespace = kubernetes_namespace.mailserver.metadata[0].name
|
|
|
|
|
nfs_server = var.nfs_server
|
|
|
|
|
nfs_path = "/mnt/main/roundcubemail/html"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "nfs_roundcube_enigma" {
|
|
|
|
|
source = "../../../../modules/kubernetes/nfs_volume"
|
|
|
|
|
name = "roundcubemail-enigma"
|
|
|
|
|
namespace = kubernetes_namespace.mailserver.metadata[0].name
|
|
|
|
|
nfs_server = var.nfs_server
|
|
|
|
|
nfs_path = "/mnt/main/roundcubemail/enigma"
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 13:23:53 +00:00
|
|
|
# If you want to override settings mount this in /var/roundcube/config
|
|
|
|
|
# more info in https://github.com/roundcube/roundcubemail-docker?tab=readme-ov-file
|
|
|
|
|
# resource "kubernetes_config_map" "roundcubemail_config" {
|
|
|
|
|
# metadata {
|
|
|
|
|
# name = "roundcubemail.config"
|
|
|
|
|
# namespace = "mailserver"
|
|
|
|
|
|
|
|
|
|
# labels = {
|
|
|
|
|
# app = "mailserver"
|
|
|
|
|
# }
|
|
|
|
|
# annotations = {
|
|
|
|
|
# "reloader.stakater.com/match" = "true"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
# data = {
|
|
|
|
|
# # if you want to override things see https://github.com/roundcube/roundcubemail/blob/master/config/defaults.inc.php
|
|
|
|
|
# "imap.php" = <<-EOF
|
|
|
|
|
# <?php
|
|
|
|
|
# $config['imap_host'] = 'ssl://mail.viktorbarzin.me:993';
|
|
|
|
|
# ?>
|
|
|
|
|
# EOF
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment" "roundcubemail" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "roundcubemail"
|
|
|
|
|
namespace = "mailserver"
|
|
|
|
|
labels = {
|
|
|
|
|
"app" = "roundcubemail"
|
2026-01-10 16:28:12 +00:00
|
|
|
tier = var.tier
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
annotations = {
|
|
|
|
|
"reloader.stakater.com/search" = "true"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
replicas = "1"
|
|
|
|
|
strategy {
|
|
|
|
|
type = "RollingUpdate"
|
|
|
|
|
}
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
"app" = "roundcubemail"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
"app" = "roundcubemail"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
container {
|
|
|
|
|
name = "roundcube"
|
2026-02-23 20:51:20 +00:00
|
|
|
image = "roundcube/roundcubemail:1.6.13-apache"
|
2025-10-18 19:03:06 +00:00
|
|
|
# Uncomment me to mount additional settings
|
|
|
|
|
# volume_mount {
|
|
|
|
|
# name = "imap-config"
|
|
|
|
|
# mount_path = "/var/roundcube/config/imap.php"
|
|
|
|
|
# sub_path = "imap.php"
|
|
|
|
|
# }
|
2025-10-18 13:23:53 +00:00
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DEFAULT_HOST"
|
|
|
|
|
value = "ssl://mail.viktorbarzin.me" # tls cert must be valid!
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DEFAULT_PORT"
|
|
|
|
|
value = "993"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_SMTP_SERVER"
|
|
|
|
|
value = "tls://mail.viktorbarzin.me" # tls cert must be valid!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_SMTP_PORT"
|
|
|
|
|
value = 587
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 19:03:06 +00:00
|
|
|
# DB Settings
|
2025-10-18 13:23:53 +00:00
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DB_TYPE"
|
|
|
|
|
value = "mysql"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DB_HOST"
|
[ci skip] Infrastructure hardening: security, monitoring, reliability, maintainability
Phase 1 - Critical Security:
- Netbox: move hardcoded DB/superuser passwords to variables
- MeshCentral: disable public registration, add Authentik auth
- Traefik: disable insecure API dashboard (api.insecure=false)
- Traefik: configure forwarded headers with Cloudflare trusted IPs
Phase 2 - Security Hardening:
- Add security headers middleware (HSTS, X-Frame-Options, nosniff, etc.)
- Add Kyverno pod security policies in audit mode (privileged, host
namespaces, SYS_ADMIN, trusted registries)
- Tighten rate limiting (avg=10, burst=50)
- Add Authentik protection to grampsweb
Phase 3 - Monitoring & Alerting:
- Add critical service alerts (PostgreSQL, MySQL, Redis, Headscale,
Authentik, Loki)
- Increase Loki retention from 7 to 30 days (720h)
- Add predictive PV filling alert (predict_linear)
- Re-enable Hackmd and Privatebin down alerts
Phase 4 - Reliability:
- Add resource requests/limits to Redis, DBaaS, Technitium, Headscale,
Vaultwarden, Uptime Kuma
- Increase Alloy DaemonSet memory to 512Mi/1Gi
Phase 6 - Maintainability:
- Extract duplicated tiers locals to terragrunt.hcl generate block
(removed from 67 stacks)
- Replace hardcoded NFS IP 10.0.10.15 with var.nfs_server (114
instances across 63 files)
- Replace hardcoded Redis/PostgreSQL/MySQL/Ollama/mail host references
with variables across ~35 stacks
- Migrate xray raw ingress resources to ingress_factory modules
2026-02-23 22:05:28 +00:00
|
|
|
value = var.mysql_host
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DB_USER"
|
|
|
|
|
value = "roundcubemail"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DB_PASSWORD"
|
|
|
|
|
value = var.roundcube_db_password
|
|
|
|
|
}
|
2025-10-18 19:03:06 +00:00
|
|
|
# Plugins
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_COMPOSER_PLUGINS"
|
|
|
|
|
value = "mmvi/twofactor_webauthn,texxasrulez/persistent_login,dsoares/rcguard"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_PLUGINS"
|
|
|
|
|
value = "attachment_reminder,database_attachments,enigma,twofactor_webauthn,persistent_login,rcguard"
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-18 13:23:53 +00:00
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_SMTP_DEBUG"
|
2026-02-23 20:29:39 +00:00
|
|
|
value = "false"
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_DEBUG_LEVEL"
|
2026-02-23 20:29:39 +00:00
|
|
|
value = "1"
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "ROUNDCUBEMAIL_LOG_DRIVER"
|
|
|
|
|
# value = "file"
|
|
|
|
|
value = "syslog"
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "web"
|
|
|
|
|
container_port = 80
|
|
|
|
|
protocol = "TCP"
|
|
|
|
|
}
|
2025-10-18 19:03:06 +00:00
|
|
|
volume_mount {
|
|
|
|
|
name = "html"
|
|
|
|
|
mount_path = "/var/www/html"
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "enigma"
|
|
|
|
|
mount_path = "/var/roundcube/enigma"
|
|
|
|
|
}
|
2026-03-14 21:46:49 +00:00
|
|
|
resources {
|
|
|
|
|
requests = {
|
|
|
|
|
cpu = "25m"
|
|
|
|
|
memory = "192Mi"
|
|
|
|
|
}
|
|
|
|
|
limits = {
|
|
|
|
|
memory = "192Mi"
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-18 19:03:06 +00:00
|
|
|
# volume {
|
|
|
|
|
# name = "imap-config"
|
|
|
|
|
# config_map {
|
|
|
|
|
# name = "roundcubemail.config"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
volume {
|
|
|
|
|
name = "html"
|
[ci skip] complete NFS CSI migration: complex stacks + platform modules
Migrate remaining multi-volume stacks and all platform modules from
inline NFS volumes to CSI-backed PV/PVC with nfs-truenas StorageClass
(soft,timeo=30,retrans=3 mount options).
Complex stacks: openclaw (4 vols), immich (8 vols), frigate (2 vols),
nextcloud (2 vols + old PV replaced), rybbit (1 vol)
Remaining stacks: affine, ebook2audiobook, f1-stream, osm_routing,
real-estate-crawler
Platform modules: monitoring (prometheus, loki, alertmanager PVs
converted from native NFS to CSI), redis, dbaas, technitium,
headscale, vaultwarden, uptime-kuma, mailserver, infra-maintenance
2026-03-02 01:24:07 +00:00
|
|
|
persistent_volume_claim {
|
|
|
|
|
claim_name = module.nfs_roundcube_html.claim_name
|
2025-10-18 19:03:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-18 13:23:53 +00:00
|
|
|
volume {
|
2025-10-18 19:03:06 +00:00
|
|
|
name = "enigma"
|
[ci skip] complete NFS CSI migration: complex stacks + platform modules
Migrate remaining multi-volume stacks and all platform modules from
inline NFS volumes to CSI-backed PV/PVC with nfs-truenas StorageClass
(soft,timeo=30,retrans=3 mount options).
Complex stacks: openclaw (4 vols), immich (8 vols), frigate (2 vols),
nextcloud (2 vols + old PV replaced), rybbit (1 vol)
Remaining stacks: affine, ebook2audiobook, f1-stream, osm_routing,
real-estate-crawler
Platform modules: monitoring (prometheus, loki, alertmanager PVs
converted from native NFS to CSI), redis, dbaas, technitium,
headscale, vaultwarden, uptime-kuma, mailserver, infra-maintenance
2026-03-02 01:24:07 +00:00
|
|
|
persistent_volume_claim {
|
|
|
|
|
claim_name = module.nfs_roundcube_enigma.claim_name
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-23 22:43:05 +00:00
|
|
|
dns_config {
|
|
|
|
|
option {
|
|
|
|
|
name = "ndots"
|
|
|
|
|
value = "2"
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "roundcubemail" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "roundcubemail"
|
|
|
|
|
namespace = "mailserver"
|
|
|
|
|
|
|
|
|
|
labels = {
|
|
|
|
|
app = "roundcubemail"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
app = "roundcubemail"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
port {
|
|
|
|
|
name = "roundcube"
|
|
|
|
|
protocol = "TCP"
|
|
|
|
|
port = 80
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "ingress" {
|
2026-02-22 14:38:14 +00:00
|
|
|
source = "../../../../modules/kubernetes/ingress_factory"
|
2025-10-18 13:23:53 +00:00
|
|
|
namespace = "mailserver"
|
|
|
|
|
name = "mail"
|
|
|
|
|
service_name = "roundcubemail"
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
2025-12-18 08:53:16 +00:00
|
|
|
rybbit_site_id = "082f164faa7d"
|
2026-03-07 16:41:36 +00:00
|
|
|
extra_annotations = {
|
|
|
|
|
"gethomepage.dev/enabled" = "true"
|
|
|
|
|
"gethomepage.dev/name" = "Roundcube Mail"
|
|
|
|
|
"gethomepage.dev/description" = "Webmail client"
|
|
|
|
|
"gethomepage.dev/icon" = "roundcube.png"
|
|
|
|
|
"gethomepage.dev/group" = "Other"
|
|
|
|
|
"gethomepage.dev/pod-selector" = ""
|
|
|
|
|
}
|
2025-10-18 13:23:53 +00:00
|
|
|
}
|