Files
infrastructure/servers/legion/main.tf
T
Will Anderson 714a7c7a8d launch: deploy daemon StatefulSet, fix neuron-rest security context, add daemon Argo CD app
- Add neuron-daemon Argo CD Application (apps/neuron-daemon.yaml) pointing to
  k8s/neuron-technologies/daemon/ on main — daemon will deploy once image is built
- Add daemon k8s manifests: StatefulSet (2 replicas, imagePullPolicy: Always),
  Service (ClusterIP :7749, session affinity), ExternalSecret (Anthropic API key from Vault)
- Fix neuron-rest runAsNonRoot: remove constraint since v0.15.3 image runs as root,
  clears the CreateContainerConfigError on the 11h-old stale pod
- Add NEURON_DAEMON_WS_URL env var to marketing deployment for chat UI connectivity
- Add neuron.neurontechnologies.ai Cloudflare DNS record and tunnel ingress rule (Terraform)
2026-04-26 10:13:48 -05:00

264 lines
7.0 KiB
Terraform

terraform {
required_version = ">= 1.5"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.30"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.14"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.0"
}
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "legion-terraform-state"
key = "legion/terraform.tfstate"
region = "auto"
endpoint = "https://651161e0a3d321561b4c90b5bcd5f15b.r2.cloudflarestorage.com"
# R2 is S3-compatible but not AWS — skip AWS-specific checks
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
force_path_style = true
}
}
provider "kubernetes" {
config_path = var.kubeconfig_path
}
provider "helm" {
kubernetes {
config_path = var.kubeconfig_path
}
}
provider "cloudflare" {
email = var.cloudflare_email
api_key = var.cloudflare_api_key
}
# Cloudflare tunnel ingress rules — all hostnames that route through the legion tunnel
# Catch-all (http_status:404) is implicit and always last; managed by Cloudflare API
resource "cloudflare_zero_trust_tunnel_cloudflared_config" "legion" {
account_id = var.cloudflare_account_id
tunnel_id = var.cloudflare_tunnel_id
config {
# neuron.neuralplatform.ai — MCP server, stable prod
ingress_rule {
hostname = "neuron.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# neuron-alpha.neuralplatform.ai — experiment zone 1 (CI auto-deploys here)
ingress_rule {
hostname = "neuron-alpha.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# neuron-beta.neuralplatform.ai — experiment zone 2
ingress_rule {
hostname = "neuron-beta.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# neuron-gamma.neuralplatform.ai — experiment zone 3
ingress_rule {
hostname = "neuron-gamma.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
ingress_rule {
hostname = "vault.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
ingress_rule {
hostname = "watch.nook.family"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
ingress_rule {
hostname = "jellyfin.nook.family"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
ingress_rule {
hostname = "bazarr.nook.family"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# fornax.neuralplatform.ai — Fornax torrent coordinator (qBittorrent API proxy)
ingress_rule {
hostname = "fornax.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# git.neuralplatform.ai — Gitea web UI (HTTP via Traefik)
ingress_rule {
hostname = "git.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# ssh.git.neuralplatform.ai — Gitea SSH (direct to NodePort 30022)
ingress_rule {
hostname = "ssh.git.neuralplatform.ai"
service = "ssh://localhost:30022"
}
# neuron.neurontechnologies.ai — Neuron MCP (private, neuron-prod namespace)
ingress_rule {
hostname = "neuron.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# neurontechnologies.ai — Neuron Technologies prod (neuron-prod namespace)
ingress_rule {
hostname = "neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
ingress_rule {
hostname = "www.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# dev.neurontechnologies.ai — Neuron Technologies dev (neuron-dev namespace)
ingress_rule {
hostname = "dev.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# stage.neurontechnologies.ai — Neuron Technologies stage (neuron-stage namespace)
ingress_rule {
hostname = "stage.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# alpha.neurontechnologies.ai — experiment zone 1 (CI auto-deploys here)
ingress_rule {
hostname = "alpha.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# beta.neurontechnologies.ai — experiment zone 2
ingress_rule {
hostname = "beta.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# gamma.neurontechnologies.ai — experiment zone 3
ingress_rule {
hostname = "gamma.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# api.neurontechnologies.ai — Neuron REST backend (neuron-rest service)
ingress_rule {
hostname = "api.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# sign.neurontechnologies.ai — Docuseal e-signature
ingress_rule {
hostname = "sign.neurontechnologies.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# sign.neuralplatform.ai — Docuseal temporary (license transfer)
ingress_rule {
hostname = "sign.neuralplatform.ai"
service = "https://traefik.kube-system.svc:443"
origin_request {
no_tls_verify = true
}
}
# vpn.neuralplatform.ai — Headscale coordination server (Tailscale control plane)
# Route directly to Headscale — bypasses Traefik which strips the Upgrade: ts2021 header
# Cloudflare handles TLS termination; internal connection is plain HTTP
ingress_rule {
hostname = "vpn.neuralplatform.ai"
service = "http://headscale.headscale.svc.cluster.local:8080"
}
# Catch-all — must be last
ingress_rule {
service = "http_status:404"
}
}
}