2026-02-17 21:42:39 +00:00
|
|
|
variable "tls_secret_name" {}
|
|
|
|
|
variable "tier" { type = string }
|
[ci skip] k8s portal: fix setup script + add onboarding hub (5 new pages)
Bug fixes:
- CA cert now populated in ConfigMap (was empty → TLS failures)
- Remove useless heredoc quote escaping in setup script
- Fix homepage: VPN callout, correct verification command (get namespaces)
- Fix false-positive sensitive=true on ingress_path, tls_secret_name,
truenas_host, ollama_host, client_certificate_secret_name
New pages (direct Svelte, no mdsvex dependency):
- /onboarding: step-by-step guide (VPN, kubectl, git, first PR)
- /architecture: cluster topology, storage, networking, tiers
- /services: catalog of 70+ services with URLs
- /contributing: PR workflow, what you can/can't change, NEVER list
- /troubleshooting: common issues and fixes
Navigation bar added to layout. All pages use consistent docs styling.
Requires Docker image rebuild: cd stacks/platform/modules/k8s-portal/files
&& docker build -t viktorbarzin/k8s-portal:latest . && docker push
2026-03-07 15:06:26 +00:00
|
|
|
variable "k8s_ca_cert" {
|
|
|
|
|
type = string
|
|
|
|
|
default = ""
|
|
|
|
|
}
|
2026-02-17 21:42:39 +00:00
|
|
|
|
|
|
|
|
resource "kubernetes_namespace" "k8s_portal" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "k8s-portal"
|
|
|
|
|
labels = {
|
|
|
|
|
tier = var.tier
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "tls_secret" {
|
2026-02-22 14:38:14 +00:00
|
|
|
source = "../../../../modules/kubernetes/setup_tls_secret"
|
2026-02-17 21:42:39 +00:00
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_config_map" "k8s_portal_config" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "k8s-portal-config"
|
|
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = {
|
[ci skip] k8s portal: fix setup script + add onboarding hub (5 new pages)
Bug fixes:
- CA cert now populated in ConfigMap (was empty → TLS failures)
- Remove useless heredoc quote escaping in setup script
- Fix homepage: VPN callout, correct verification command (get namespaces)
- Fix false-positive sensitive=true on ingress_path, tls_secret_name,
truenas_host, ollama_host, client_certificate_secret_name
New pages (direct Svelte, no mdsvex dependency):
- /onboarding: step-by-step guide (VPN, kubectl, git, first PR)
- /architecture: cluster topology, storage, networking, tiers
- /services: catalog of 70+ services with URLs
- /contributing: PR workflow, what you can/can't change, NEVER list
- /troubleshooting: common issues and fixes
Navigation bar added to layout. All pages use consistent docs styling.
Requires Docker image rebuild: cd stacks/platform/modules/k8s-portal/files
&& docker build -t viktorbarzin/k8s-portal:latest . && docker push
2026-03-07 15:06:26 +00:00
|
|
|
"ca.crt" = var.k8s_ca_cert
|
2026-02-17 21:42:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment" "k8s_portal" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "k8s-portal"
|
|
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
labels = {
|
|
|
|
|
app = "k8s-portal"
|
|
|
|
|
tier = var.tier
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
replicas = 1
|
2026-03-16 22:55:15 +00:00
|
|
|
strategy {
|
|
|
|
|
type = "Recreate"
|
|
|
|
|
}
|
|
|
|
|
revision_history_limit = 3
|
2026-02-17 21:42:39 +00:00
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "k8s-portal"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template {
|
|
|
|
|
metadata {
|
|
|
|
|
labels = {
|
|
|
|
|
app = "k8s-portal"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
container {
|
|
|
|
|
name = "portal"
|
|
|
|
|
image = "viktorbarzin/k8s-portal:latest"
|
|
|
|
|
port {
|
|
|
|
|
container_port = 3000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "config"
|
add generic multi-user cluster onboarding system
Data-driven user onboarding: add a JSON entry to Vault KV k8s_users,
apply vault + platform + woodpecker stacks, and everything is auto-generated.
Vault stack: namespace creation, per-user Vault policies with secret isolation
via identity entities/aliases, K8s deployer roles, CI policy update.
Platform stack: domains field in k8s_users type, TLS secrets per user namespace,
user domains merged into Cloudflare DNS, user-roles ConfigMap mounted in portal.
Woodpecker stack: admin list auto-generated from k8s_users, WOODPECKER_OPEN=true.
K8s-portal: dual-track onboarding (general/namespace-owner), namespace-owner
dashboard with Vault/kubectl commands, setup script adds Vault+Terraform+Terragrunt,
contributing page with CI pipeline template, versioned image tags in CI pipeline.
New: stacks/_template/ with copyable stack template for namespace-owners.
2026-03-15 22:23:36 +00:00
|
|
|
mount_path = "/config/ca.crt"
|
|
|
|
|
sub_path = "ca.crt"
|
|
|
|
|
read_only = true
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "user-roles"
|
|
|
|
|
mount_path = "/config/users.json"
|
|
|
|
|
sub_path = "users.json"
|
2026-02-17 21:42:39 +00:00
|
|
|
read_only = true
|
|
|
|
|
}
|
[ci skip] right-size all pod resources based on VPA + live metrics audit
Full cluster resource audit: cross-referenced Goldilocks VPA recommendations,
live kubectl top metrics, and Terraform definitions for 100+ containers.
Critical fixes:
- dashy: CPU throttled at 98% (490m/500m) → 2 CPU limit
- stirling-pdf: CPU throttled at 99.7% (299m/300m) → 2 CPU limit
- traefik auth-proxy/bot-block-proxy: mem limit 32Mi → 128Mi
Added explicit resources to ~40 containers that had none:
- audiobookshelf, changedetection, cyberchef, dawarich, diun, echo,
excalidraw, freshrss, hackmd, isponsorblocktv, linkwarden, n8n,
navidrome, ntfy, owntracks, privatebin, send, shadowsocks, tandoor,
tor-proxy, wealthfolio, networking-toolbox, rybbit, mailserver,
cloudflared, pgadmin, phpmyadmin, crowdsec-web, xray, wireguard,
k8s-portal, tuya-bridge, ollama-ui, whisper, piper, immich-server,
immich-postgresql, osrm-foot
GPU containers: added CPU/mem alongside GPU limits:
- ollama: removed CPU/mem limits (models vary in size), keep GPU only
- frigate: req 500m/2Gi, lim 4/8Gi + GPU
- immich-ml: req 100m/1Gi, lim 2/4Gi + GPU
Right-sized ~25 over-provisioned containers:
- kms-web-page: 500m/512Mi → 50m/64Mi (was using 0m/10Mi)
- onlyoffice: CPU 8 → 2 (VPA upper 45m)
- realestate-crawler-api: CPU 2000m → 250m
- blog/travel-blog/webhook-handler: 500m → 100m
- coturn/health/plotting-book: reduced to match actual usage
Conservative methodology: limits = max(VPA upper * 2, live usage * 2)
2026-03-01 19:18:50 +00:00
|
|
|
resources {
|
|
|
|
|
requests = {
|
|
|
|
|
cpu = "10m"
|
2026-03-14 21:46:49 +00:00
|
|
|
memory = "128Mi"
|
[ci skip] right-size all pod resources based on VPA + live metrics audit
Full cluster resource audit: cross-referenced Goldilocks VPA recommendations,
live kubectl top metrics, and Terraform definitions for 100+ containers.
Critical fixes:
- dashy: CPU throttled at 98% (490m/500m) → 2 CPU limit
- stirling-pdf: CPU throttled at 99.7% (299m/300m) → 2 CPU limit
- traefik auth-proxy/bot-block-proxy: mem limit 32Mi → 128Mi
Added explicit resources to ~40 containers that had none:
- audiobookshelf, changedetection, cyberchef, dawarich, diun, echo,
excalidraw, freshrss, hackmd, isponsorblocktv, linkwarden, n8n,
navidrome, ntfy, owntracks, privatebin, send, shadowsocks, tandoor,
tor-proxy, wealthfolio, networking-toolbox, rybbit, mailserver,
cloudflared, pgadmin, phpmyadmin, crowdsec-web, xray, wireguard,
k8s-portal, tuya-bridge, ollama-ui, whisper, piper, immich-server,
immich-postgresql, osrm-foot
GPU containers: added CPU/mem alongside GPU limits:
- ollama: removed CPU/mem limits (models vary in size), keep GPU only
- frigate: req 500m/2Gi, lim 4/8Gi + GPU
- immich-ml: req 100m/1Gi, lim 2/4Gi + GPU
Right-sized ~25 over-provisioned containers:
- kms-web-page: 500m/512Mi → 50m/64Mi (was using 0m/10Mi)
- onlyoffice: CPU 8 → 2 (VPA upper 45m)
- realestate-crawler-api: CPU 2000m → 250m
- blog/travel-blog/webhook-handler: 500m → 100m
- coturn/health/plotting-book: reduced to match actual usage
Conservative methodology: limits = max(VPA upper * 2, live usage * 2)
2026-03-01 19:18:50 +00:00
|
|
|
}
|
|
|
|
|
limits = {
|
|
|
|
|
memory = "128Mi"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-17 21:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume {
|
|
|
|
|
name = "config"
|
|
|
|
|
config_map {
|
|
|
|
|
name = kubernetes_config_map.k8s_portal_config.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
}
|
add generic multi-user cluster onboarding system
Data-driven user onboarding: add a JSON entry to Vault KV k8s_users,
apply vault + platform + woodpecker stacks, and everything is auto-generated.
Vault stack: namespace creation, per-user Vault policies with secret isolation
via identity entities/aliases, K8s deployer roles, CI policy update.
Platform stack: domains field in k8s_users type, TLS secrets per user namespace,
user domains merged into Cloudflare DNS, user-roles ConfigMap mounted in portal.
Woodpecker stack: admin list auto-generated from k8s_users, WOODPECKER_OPEN=true.
K8s-portal: dual-track onboarding (general/namespace-owner), namespace-owner
dashboard with Vault/kubectl commands, setup script adds Vault+Terraform+Terragrunt,
contributing page with CI pipeline template, versioned image tags in CI pipeline.
New: stacks/_template/ with copyable stack template for namespace-owners.
2026-03-15 22:23:36 +00:00
|
|
|
volume {
|
|
|
|
|
name = "user-roles"
|
|
|
|
|
config_map {
|
|
|
|
|
name = "k8s-user-roles"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-23 22:43:05 +00:00
|
|
|
dns_config {
|
|
|
|
|
option {
|
|
|
|
|
name = "ndots"
|
|
|
|
|
value = "2"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-17 21:42:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
add generic multi-user cluster onboarding system
Data-driven user onboarding: add a JSON entry to Vault KV k8s_users,
apply vault + platform + woodpecker stacks, and everything is auto-generated.
Vault stack: namespace creation, per-user Vault policies with secret isolation
via identity entities/aliases, K8s deployer roles, CI policy update.
Platform stack: domains field in k8s_users type, TLS secrets per user namespace,
user domains merged into Cloudflare DNS, user-roles ConfigMap mounted in portal.
Woodpecker stack: admin list auto-generated from k8s_users, WOODPECKER_OPEN=true.
K8s-portal: dual-track onboarding (general/namespace-owner), namespace-owner
dashboard with Vault/kubectl commands, setup script adds Vault+Terraform+Terragrunt,
contributing page with CI pipeline template, versioned image tags in CI pipeline.
New: stacks/_template/ with copyable stack template for namespace-owners.
2026-03-15 22:23:36 +00:00
|
|
|
lifecycle {
|
|
|
|
|
ignore_changes = [
|
|
|
|
|
spec[0].template[0].spec[0].dns_config,
|
|
|
|
|
spec[0].template[0].spec[0].container[0].image, # CI updates image tag
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-02-17 21:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_service" "k8s_portal" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "k8s-portal"
|
|
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
|
|
|
|
selector = {
|
|
|
|
|
app = "k8s-portal"
|
|
|
|
|
}
|
|
|
|
|
port {
|
|
|
|
|
port = 80
|
|
|
|
|
target_port = 3000
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "ingress" {
|
2026-02-22 14:38:14 +00:00
|
|
|
source = "../../../../modules/kubernetes/ingress_factory"
|
2026-02-17 21:42:39 +00:00
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
name = "k8s-portal"
|
|
|
|
|
tls_secret_name = var.tls_secret_name
|
|
|
|
|
protected = true # Require Authentik login
|
2026-03-07 16:41:36 +00:00
|
|
|
extra_annotations = {
|
|
|
|
|
"gethomepage.dev/enabled" = "true"
|
|
|
|
|
"gethomepage.dev/name" = "K8s Portal"
|
|
|
|
|
"gethomepage.dev/description" = "Kubernetes portal"
|
|
|
|
|
"gethomepage.dev/icon" = "kubernetes.png"
|
|
|
|
|
"gethomepage.dev/group" = "Core Platform"
|
|
|
|
|
"gethomepage.dev/pod-selector" = ""
|
|
|
|
|
}
|
2026-02-17 21:42:39 +00:00
|
|
|
}
|
2026-02-17 22:22:41 +00:00
|
|
|
|
2026-03-14 08:51:45 +00:00
|
|
|
# Unprotected ingress for the setup script and agent endpoint (needs to be curl-able without auth)
|
2026-02-17 22:22:41 +00:00
|
|
|
module "ingress_setup_script" {
|
2026-02-22 14:38:14 +00:00
|
|
|
source = "../../../../modules/kubernetes/ingress_factory"
|
2026-02-17 22:22:41 +00:00
|
|
|
namespace = kubernetes_namespace.k8s_portal.metadata[0].name
|
|
|
|
|
name = "k8s-portal-setup"
|
|
|
|
|
host = "k8s-portal"
|
|
|
|
|
service_name = "k8s-portal"
|
2026-03-14 08:51:45 +00:00
|
|
|
ingress_path = ["/setup/script", "/agent"]
|
2026-02-17 22:22:41 +00:00
|
|
|
tls_secret_name = var.tls_secret_name
|
|
|
|
|
protected = false
|
|
|
|
|
}
|