2026-02-22 13:56:34 +00:00
|
|
|
variable "tls_secret_name" { type = string }
|
|
|
|
|
variable "clickhouse_password" { type = string }
|
|
|
|
|
variable "clickhouse_postgres_password" { type = string }
|
[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 "nfs_server" { type = string }
|
|
|
|
|
variable "postgresql_host" { type = string }
|
2026-02-22 13:56:34 +00:00
|
|
|
|
|
|
|
|
|
2026-02-22 15:13:55 +00:00
|
|
|
resource "kubernetes_namespace" "rybbit" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "rybbit"
|
|
|
|
|
labels = {
|
|
|
|
|
tier = local.tiers.aux
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "tls_secret" {
|
|
|
|
|
source = "../../modules/kubernetes/setup_tls_secret"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "random_string" "random" {
|
|
|
|
|
length = 32
|
|
|
|
|
lower = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
locals {
|
|
|
|
|
clickhouse_db = "clickhouse"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment" "clickhouse" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "clickhouse"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
app = "clickhouse"
|
|
|
|
|
tier = local.tiers.aux
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
replicas = 1
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "clickhouse"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
app = "clickhouse"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
container {
|
|
|
|
|
name = "clickhouse"
|
|
|
|
|
image = "clickhouse/clickhouse-server:25.4.2"
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_DB"
|
|
|
|
|
value = local.clickhouse_db
|
|
|
|
|
}
|
|
|
|
|
# env {
|
|
|
|
|
# name = "CLICKHOUSE_USER"
|
|
|
|
|
# value = "clickhouse"
|
|
|
|
|
# }
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_PASSWORD"
|
|
|
|
|
value = var.clickhouse_password
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "clickhouse"
|
|
|
|
|
protocol = "TCP"
|
|
|
|
|
container_port = 8123
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "data"
|
|
|
|
|
mount_path = "/var/lib/clickhouse"
|
|
|
|
|
}
|
2026-02-25 20:53:08 +00:00
|
|
|
resources {
|
|
|
|
|
requests = {
|
|
|
|
|
cpu = "100m"
|
|
|
|
|
memory = "512Mi"
|
|
|
|
|
}
|
|
|
|
|
limits = {
|
|
|
|
|
cpu = "2"
|
|
|
|
|
memory = "4Gi"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-22 15:13:55 +00:00
|
|
|
}
|
|
|
|
|
volume {
|
|
|
|
|
name = "data"
|
|
|
|
|
nfs {
|
|
|
|
|
path = "/mnt/main/clickhouse"
|
[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
|
|
|
server = var.nfs_server
|
2026-02-22 15:13:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "clickhouse" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "clickhouse"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
"app" = "clickhouse"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
app = "clickhouse"
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
target_port = 8123
|
|
|
|
|
port = 8123
|
|
|
|
|
protocol = "TCP"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment" "rybbit" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "rybbit"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
app = "rybbit"
|
|
|
|
|
tier = local.tiers.aux
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
replicas = 1
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
app = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
container {
|
|
|
|
|
image = "ghcr.io/rybbit-io/rybbit-backend:latest"
|
|
|
|
|
name = "rybbit"
|
|
|
|
|
|
|
|
|
|
env {
|
|
|
|
|
name = "NODE_ENV"
|
|
|
|
|
value = "production"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_HOST"
|
|
|
|
|
value = "http://clickhouse.rybbit.svc.cluster.local:8123"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_DB"
|
|
|
|
|
value = local.clickhouse_db
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_USER"
|
|
|
|
|
value = "default"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "CLICKHOUSE_PASSWORD"
|
|
|
|
|
value = var.clickhouse_password
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "POSTGRES_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.postgresql_host
|
2026-02-22 15:13:55 +00:00
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "POSTGRES_PORT"
|
|
|
|
|
value = "5432"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "POSTGRES_DB"
|
|
|
|
|
value = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "POSTGRES_USER"
|
|
|
|
|
value = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "POSTGRES_PASSWORD"
|
|
|
|
|
value = var.clickhouse_postgres_password
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "BASE_URL"
|
|
|
|
|
value = "https://rybbit.viktorbarzin.me"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "DISABLE_SIGNUP"
|
|
|
|
|
value = true
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "BETTER_AUTH_SECRET"
|
|
|
|
|
value = random_string.random.result
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "AUTH_ENABLED"
|
|
|
|
|
value = true
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
container_port = 3001
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "rybbit" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "rybbit"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
"app" = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
"app" = "rybbit"
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
port = 80
|
|
|
|
|
target_port = 3001
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment" "rybbit-client" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "rybbit-client"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
app = "rybbit-client"
|
|
|
|
|
tier = local.tiers.aux
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
replicas = 1
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "rybbit-client"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
app = "rybbit-client"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
spec {
|
|
|
|
|
container {
|
|
|
|
|
name = "rybbit-client"
|
|
|
|
|
image = "ghcr.io/rybbit-io/rybbit-client:latest"
|
|
|
|
|
env {
|
|
|
|
|
name = "NODE_ENV"
|
|
|
|
|
value = "production"
|
|
|
|
|
}
|
|
|
|
|
env {
|
|
|
|
|
name = "DISABLE_SIGNUP"
|
|
|
|
|
value = true
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "rybbit-client"
|
|
|
|
|
protocol = "TCP"
|
|
|
|
|
container_port = 3002
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "rybbit-client" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "rybbit-client"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
"app" = "rybbit-client"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
"app" = "rybbit-client"
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
port = 80
|
|
|
|
|
target_port = 3002
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "ingress" {
|
|
|
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
name = "rybbit"
|
|
|
|
|
service_name = "rybbit-client"
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
|
|
|
|
rybbit_site_id = "3c476801a777"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "ingress-api" {
|
|
|
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
|
|
|
namespace = kubernetes_namespace.rybbit.metadata[0].name
|
|
|
|
|
name = "rybbit-api"
|
|
|
|
|
host = "rybbit"
|
|
|
|
|
service_name = "rybbit"
|
|
|
|
|
ingress_path = ["/api"]
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
2026-02-22 13:56:34 +00:00
|
|
|
}
|