2026-06-01 19:45:03 +00:00
|
|
|
variable "tls_secret_name" {
|
|
|
|
|
type = string
|
|
|
|
|
sensitive = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_namespace" "t3code" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "t3code"
|
|
|
|
|
labels = {
|
|
|
|
|
"istio-injection" : "disabled"
|
|
|
|
|
tier = local.tiers.aux
|
|
|
|
|
"keel.sh/enrolled" = "true"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lifecycle {
|
|
|
|
|
# KYVERNO_LIFECYCLE_V1: goldilocks-vpa-auto-mode ClusterPolicy stamps this label on every namespace
|
|
|
|
|
ignore_changes = [metadata[0].labels["goldilocks.fairwinds.com/vpa-update-mode"]]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# TLS secret `tls-secret` (wildcard *.viktorbarzin.me) is auto-cloned into this
|
|
|
|
|
# namespace by Kyverno's `sync-tls-secret` ClusterPolicy — no local module or
|
|
|
|
|
# cert material needed; the renewal pipeline updates the source and Kyverno
|
|
|
|
|
# propagates within seconds.
|
|
|
|
|
|
2026-06-01 22:44:27 +00:00
|
|
|
# === Per-user dispatch + auto-provisioning ===================================
|
2026-06-01 21:38:06 +00:00
|
|
|
# t3 is single-owner (no in-app multi-user), so each person runs their OWN
|
2026-06-01 22:44:27 +00:00
|
|
|
# `t3 serve` instance on the DevVM as their own OS user (file perms enforced by
|
|
|
|
|
# the uid). A DevVM service `t3-dispatch` (10.0.10.10:3780) routes the single
|
|
|
|
|
# hostname t3.viktorbarzin.me by Authentik identity and auto-mints+injects the
|
|
|
|
|
# user's t3 session on first visit. Source of truth: /etc/ttyd-user-map. All the
|
|
|
|
|
# DevVM-side pieces (t3-serve@ template, reconcile, dispatch, t3-mint, sudoers)
|
|
|
|
|
# live in infra/scripts/ and are deployed there (outside TF, like t3-serve and
|
|
|
|
|
# terminal-lobby). This stack only owns the K8s edge:
|
|
|
|
|
# Traefik (Authentik forward-auth, auth="required") -> Service/Endpoints
|
|
|
|
|
# -> 10.0.10.10:3780 (t3-dispatch).
|
|
|
|
|
# See docs/plans/2026-06-01-t3-auto-provision-{design,plan}.md.
|
|
|
|
|
resource "kubernetes_service" "t3code" {
|
2026-06-01 19:45:03 +00:00
|
|
|
metadata {
|
2026-06-01 22:44:27 +00:00
|
|
|
name = "t3"
|
2026-06-01 19:45:03 +00:00
|
|
|
namespace = kubernetes_namespace.t3code.metadata[0].name
|
2026-06-01 22:44:27 +00:00
|
|
|
labels = {
|
|
|
|
|
app = "t3"
|
|
|
|
|
}
|
2026-06-01 19:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
2026-06-01 22:44:27 +00:00
|
|
|
port {
|
|
|
|
|
name = "http"
|
|
|
|
|
port = 80
|
|
|
|
|
target_port = 3780
|
2026-06-01 19:45:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-01 22:44:27 +00:00
|
|
|
resource "kubernetes_endpoints" "t3code" {
|
2026-06-01 19:45:03 +00:00
|
|
|
metadata {
|
2026-06-01 22:44:27 +00:00
|
|
|
name = "t3"
|
2026-06-01 19:45:03 +00:00
|
|
|
namespace = kubernetes_namespace.t3code.metadata[0].name
|
|
|
|
|
}
|
2026-06-01 22:44:27 +00:00
|
|
|
|
|
|
|
|
subset {
|
|
|
|
|
address {
|
|
|
|
|
ip = "10.0.10.10"
|
|
|
|
|
}
|
2026-06-01 19:45:03 +00:00
|
|
|
port {
|
2026-06-01 22:44:27 +00:00
|
|
|
name = "http"
|
|
|
|
|
port = 3780
|
2026-06-01 19:45:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "ingress" {
|
|
|
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
|
|
|
dns_type = "proxied"
|
|
|
|
|
namespace = kubernetes_namespace.t3code.metadata[0].name
|
|
|
|
|
name = "t3"
|
2026-06-01 22:44:27 +00:00
|
|
|
service_name = kubernetes_service.t3code.metadata[0].name
|
2026-06-01 19:45:03 +00:00
|
|
|
tls_secret_name = var.tls_secret_name
|
2026-06-01 21:38:06 +00:00
|
|
|
# Authentik forward-auth gates t3.viktorbarzin.me and injects
|
2026-06-01 22:44:27 +00:00
|
|
|
# X-authentik-username, which the DevVM t3-dispatch service maps to each user's
|
|
|
|
|
# own `t3 serve` instance (per-user isolation mirroring the terminal stack).
|
|
|
|
|
# The same-origin self-served UI works behind forward-auth (WS carries the
|
|
|
|
|
# Authentik cookie); t3's own pairing/bearer is the inner gate, auto-injected
|
|
|
|
|
# on first visit. Cross-origin clients (native app / app.t3.codes) are
|
|
|
|
|
# intentionally NOT supported here — deferred until the native app is published.
|
2026-06-01 21:38:06 +00:00
|
|
|
auth = "required"
|
2026-06-01 19:45:03 +00:00
|
|
|
extra_annotations = {
|
|
|
|
|
"gethomepage.dev/enabled" = "true"
|
|
|
|
|
"gethomepage.dev/name" = "T3 Code"
|
2026-06-01 22:44:27 +00:00
|
|
|
"gethomepage.dev/description" = "Coding-agent GUI (per-user, t3 serve on DevVM)"
|
2026-06-01 19:45:03 +00:00
|
|
|
"gethomepage.dev/icon" = "mdi-robot"
|
|
|
|
|
"gethomepage.dev/group" = "Infrastructure"
|
|
|
|
|
"gethomepage.dev/pod-selector" = ""
|
|
|
|
|
}
|
|
|
|
|
}
|