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
197 lines
4.7 KiB
HCL
197 lines
4.7 KiB
HCL
variable "roundcube_db_password" { type = string }
|
|
variable "mysql_host" { type = string }
|
|
|
|
# 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"
|
|
tier = var.tier
|
|
}
|
|
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"
|
|
image = "roundcube/roundcubemail:1.6.13-apache"
|
|
# Uncomment me to mount additional settings
|
|
# volume_mount {
|
|
# name = "imap-config"
|
|
# mount_path = "/var/roundcube/config/imap.php"
|
|
# sub_path = "imap.php"
|
|
# }
|
|
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
|
|
}
|
|
|
|
# DB Settings
|
|
env {
|
|
name = "ROUNDCUBEMAIL_DB_TYPE"
|
|
value = "mysql"
|
|
}
|
|
env {
|
|
name = "ROUNDCUBEMAIL_DB_HOST"
|
|
value = var.mysql_host
|
|
}
|
|
env {
|
|
name = "ROUNDCUBEMAIL_DB_USER"
|
|
value = "roundcubemail"
|
|
}
|
|
env {
|
|
name = "ROUNDCUBEMAIL_DB_PASSWORD"
|
|
value = var.roundcube_db_password
|
|
}
|
|
# 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"
|
|
}
|
|
|
|
env {
|
|
name = "ROUNDCUBEMAIL_SMTP_DEBUG"
|
|
value = "false"
|
|
}
|
|
env {
|
|
name = "ROUNDCUBEMAIL_DEBUG_LEVEL"
|
|
value = "1"
|
|
}
|
|
env {
|
|
name = "ROUNDCUBEMAIL_LOG_DRIVER"
|
|
# value = "file"
|
|
value = "syslog"
|
|
}
|
|
port {
|
|
name = "web"
|
|
container_port = 80
|
|
protocol = "TCP"
|
|
}
|
|
volume_mount {
|
|
name = "html"
|
|
mount_path = "/var/www/html"
|
|
}
|
|
volume_mount {
|
|
name = "enigma"
|
|
mount_path = "/var/roundcube/enigma"
|
|
}
|
|
}
|
|
|
|
# volume {
|
|
# name = "imap-config"
|
|
# config_map {
|
|
# name = "roundcubemail.config"
|
|
# }
|
|
# }
|
|
|
|
volume {
|
|
name = "html"
|
|
nfs {
|
|
path = "/mnt/main/roundcubemail/html"
|
|
server = var.nfs_server
|
|
}
|
|
}
|
|
volume {
|
|
name = "enigma"
|
|
nfs {
|
|
path = "/mnt/main/roundcubemail/enigma"
|
|
server = var.nfs_server
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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" {
|
|
source = "../../../../modules/kubernetes/ingress_factory"
|
|
namespace = "mailserver"
|
|
name = "mail"
|
|
service_name = "roundcubemail"
|
|
tls_secret_name = var.tls_secret_name
|
|
rybbit_site_id = "082f164faa7d"
|
|
}
|