move authentik to standalone compose
This commit is contained in:
parent
8ee0ca4f72
commit
d08b633a9e
|
|
@ -1,34 +0,0 @@
|
|||
# Authentik
|
||||
|
||||
Authentik is the homelab identity provider and future SSO control plane.
|
||||
|
||||
Phase 1 deploys Authentik itself only. It does not yet move Grafana, Jellyfin,
|
||||
or other applications to SSO.
|
||||
|
||||
## Deploy
|
||||
|
||||
Run from the Debian homelab server:
|
||||
|
||||
```bash
|
||||
./jeannie authentik-secret ensure
|
||||
./jeannie platform
|
||||
```
|
||||
|
||||
`./jeannie platform` also runs the secret step automatically before applying the
|
||||
platform OpenTofu stack.
|
||||
|
||||
The generated secret file is:
|
||||
|
||||
```text
|
||||
apps/authentik/authentik.secret.yaml
|
||||
```
|
||||
|
||||
Commit only that SOPS-encrypted file, never a plaintext secret.
|
||||
|
||||
## Public URL
|
||||
|
||||
```text
|
||||
https://auth.lab2025.duckdns.org/
|
||||
```
|
||||
|
||||
The first SSO integration target will be Grafana in a later phase.
|
||||
|
|
@ -14,31 +14,38 @@ locals {
|
|||
crowdsec_whitelist = templatefile("${path.module}/templates/crowdsec-homelab-whitelist.yaml.tftpl", {})
|
||||
heimdall_server_name = "heimdall.${var.server_name}"
|
||||
homepage_server_name = "homepage.${var.server_name}"
|
||||
authentik_server_name = "auth.${var.server_name}"
|
||||
jellyfin_server_name = "jellyfin.${var.server_name}"
|
||||
heimdall_backend_host = var.heimdall_backend_host != "" ? var.heimdall_backend_host : var.gitea_backend_host
|
||||
homepage_backend_host = var.homepage_backend_host != "" ? var.homepage_backend_host : var.gitea_backend_host
|
||||
authentik_backend_host = (
|
||||
var.authentik_backend_host != "" ? var.authentik_backend_host : var.gitea_backend_host
|
||||
)
|
||||
jellyfin_backend_host = var.jellyfin_backend_host != "" ? var.jellyfin_backend_host : var.gitea_backend_host
|
||||
server_names = distinct(concat([var.server_name, local.heimdall_server_name, local.homepage_server_name, local.jellyfin_server_name], var.additional_server_names))
|
||||
server_names = distinct(concat([var.server_name, local.heimdall_server_name, local.homepage_server_name, local.authentik_server_name, local.jellyfin_server_name], var.additional_server_names))
|
||||
matrix_server_names = var.matrix_enabled ? [var.matrix_server_name, var.element_server_name] : []
|
||||
main_server_names = [for name in local.server_names : name if !contains([local.heimdall_server_name, local.homepage_server_name, local.jellyfin_server_name], name) && !contains(local.matrix_server_names, name)]
|
||||
main_server_names = [for name in local.server_names : name if !contains([local.heimdall_server_name, local.homepage_server_name, local.authentik_server_name, local.jellyfin_server_name], name) && !contains(local.matrix_server_names, name)]
|
||||
default_conf = templatefile("${path.module}/templates/default.conf.tftpl", {
|
||||
server_name = var.server_name
|
||||
server_names = join(" ", local.server_names)
|
||||
main_server_names = join(" ", local.main_server_names)
|
||||
backend_host = var.backend_host
|
||||
backend_port = tostring(var.backend_port)
|
||||
demos_backend_port = var.demos_backend_port
|
||||
gitea_backend_host = var.gitea_backend_host
|
||||
gitea_backend_port = var.gitea_backend_port
|
||||
heimdall_server_name = local.heimdall_server_name
|
||||
heimdall_backend_host = local.heimdall_backend_host
|
||||
heimdall_backend_port = tostring(var.heimdall_backend_port)
|
||||
homepage_server_name = local.homepage_server_name
|
||||
homepage_backend_host = local.homepage_backend_host
|
||||
homepage_backend_port = tostring(var.homepage_backend_port)
|
||||
jellyfin_server_name = local.jellyfin_server_name
|
||||
jellyfin_backend_host = local.jellyfin_backend_host
|
||||
jellyfin_backend_port = tostring(var.jellyfin_backend_port)
|
||||
server_name = var.server_name
|
||||
server_names = join(" ", local.server_names)
|
||||
main_server_names = join(" ", local.main_server_names)
|
||||
backend_host = var.backend_host
|
||||
backend_port = tostring(var.backend_port)
|
||||
demos_backend_port = var.demos_backend_port
|
||||
gitea_backend_host = var.gitea_backend_host
|
||||
gitea_backend_port = var.gitea_backend_port
|
||||
heimdall_server_name = local.heimdall_server_name
|
||||
heimdall_backend_host = local.heimdall_backend_host
|
||||
heimdall_backend_port = tostring(var.heimdall_backend_port)
|
||||
homepage_server_name = local.homepage_server_name
|
||||
homepage_backend_host = local.homepage_backend_host
|
||||
homepage_backend_port = tostring(var.homepage_backend_port)
|
||||
authentik_server_name = local.authentik_server_name
|
||||
authentik_backend_host = local.authentik_backend_host
|
||||
authentik_backend_port = tostring(var.authentik_backend_port)
|
||||
jellyfin_server_name = local.jellyfin_server_name
|
||||
jellyfin_backend_host = local.jellyfin_backend_host
|
||||
jellyfin_backend_port = tostring(var.jellyfin_backend_port)
|
||||
})
|
||||
default_vcl = templatefile("${path.module}/templates/default.vcl.tftpl", {
|
||||
backend_host = var.backend_host
|
||||
|
|
@ -88,6 +95,8 @@ resource "null_resource" "edge_services" {
|
|||
gitea_backend_port = tostring(var.gitea_backend_port)
|
||||
heimdall_host = local.heimdall_backend_host
|
||||
heimdall_port = tostring(var.heimdall_backend_port)
|
||||
authentik_host = local.authentik_backend_host
|
||||
authentik_port = tostring(var.authentik_backend_port)
|
||||
jellyfin_host = local.jellyfin_backend_host
|
||||
jellyfin_port = tostring(var.jellyfin_backend_port)
|
||||
enable_letsencrypt = tostring(var.enable_letsencrypt)
|
||||
|
|
@ -167,6 +176,8 @@ gitea_backend_host="${self.triggers.gitea_backend_host}"
|
|||
gitea_backend_port="${self.triggers.gitea_backend_port}"
|
||||
heimdall_host="${self.triggers.heimdall_host}"
|
||||
heimdall_port="${self.triggers.heimdall_port}"
|
||||
authentik_host="${self.triggers.authentik_host}"
|
||||
authentik_port="${self.triggers.authentik_port}"
|
||||
jellyfin_host="${self.triggers.jellyfin_host}"
|
||||
jellyfin_port="${self.triggers.jellyfin_port}"
|
||||
enable_letsencrypt="${self.triggers.enable_letsencrypt}"
|
||||
|
|
@ -205,6 +216,11 @@ if ! curl -sS --connect-timeout 10 "http://$heimdall_host:$heimdall_port/" >/dev
|
|||
echo "Run ./jeannie deploy-heimdall on the Debian host if the service is missing." >&2
|
||||
fi
|
||||
|
||||
if ! curl -sS --connect-timeout 10 "http://$authentik_host:$authentik_port/-/health/live/" >/dev/null; then
|
||||
echo "Warning: cannot reach Authentik backend http://$authentik_host:$authentik_port/ from the edge host." >&2
|
||||
echo "Run ./jeannie deploy-authentik on the Debian host before testing the public hostname." >&2
|
||||
fi
|
||||
|
||||
if ! curl -sS --connect-timeout 10 "http://$jellyfin_host:$jellyfin_port/" >/dev/null; then
|
||||
echo "Warning: cannot reach Jellyfin backend http://$jellyfin_host:$jellyfin_port/ from the edge host." >&2
|
||||
echo "Check the Debian Jellyfin container and published port before testing the public hostname." >&2
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ upstream homepage_backend {
|
|||
keepalive 8;
|
||||
}
|
||||
|
||||
upstream authentik_backend {
|
||||
server ${authentik_backend_host}:${authentik_backend_port};
|
||||
keepalive 8;
|
||||
}
|
||||
|
||||
upstream jellyfin_backend {
|
||||
server ${jellyfin_backend_host}:${jellyfin_backend_port};
|
||||
keepalive 8;
|
||||
|
|
@ -73,7 +78,7 @@ server {
|
|||
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${heimdall_server_name} ${homepage_server_name} ${jellyfin_server_name};
|
||||
server_name ${heimdall_server_name} ${homepage_server_name} ${authentik_server_name} ${jellyfin_server_name};
|
||||
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
|
|
@ -86,6 +91,62 @@ server {
|
|||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name ${authentik_server_name};
|
||||
|
||||
ssl_certificate /etc/nginx/certs/current.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/current.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_session_cache shared:homelab_ssl:10m;
|
||||
ssl_session_timeout 1d;
|
||||
|
||||
keepalive_timeout 65s;
|
||||
keepalive_requests 1000;
|
||||
|
||||
if ($blocked_uris) { return 403; }
|
||||
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||
add_header Permissions-Policy "geolocation=(), microphone=()";
|
||||
|
||||
gzip on;
|
||||
gzip_comp_level 2;
|
||||
gzip_min_length 1000;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
location = /edge-health {
|
||||
access_log off;
|
||||
return 204;
|
||||
}
|
||||
|
||||
location / {
|
||||
limit_req zone=one burst=20 nodelay;
|
||||
client_max_body_size 64m;
|
||||
|
||||
proxy_pass http://authentik_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-Port 443;
|
||||
proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;
|
||||
add_header Cache-Control "no-store";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,16 @@ variable "homepage_backend_port" {
|
|||
default = 8083
|
||||
}
|
||||
|
||||
variable "authentik_backend_host" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "authentik_backend_port" {
|
||||
type = number
|
||||
default = 9000
|
||||
}
|
||||
|
||||
variable "jellyfin_backend_host" {
|
||||
type = string
|
||||
default = ""
|
||||
|
|
|
|||
|
|
@ -2119,176 +2119,6 @@ EOT
|
|||
}
|
||||
}
|
||||
|
||||
resource "helm_release" "authentik" {
|
||||
count = var.authentik.enabled ? 1 : 0
|
||||
|
||||
depends_on = [helm_release.traefik]
|
||||
name = "authentik"
|
||||
repository = var.authentik.repository
|
||||
chart = var.authentik.chart
|
||||
version = var.authentik.version
|
||||
namespace = var.authentik.namespace
|
||||
create_namespace = false
|
||||
timeout = 900
|
||||
wait = false
|
||||
cleanup_on_fail = true
|
||||
|
||||
values = [
|
||||
yamlencode({
|
||||
global = {
|
||||
nodeSelector = local.prometheus_stack_node_selector
|
||||
env = [
|
||||
{
|
||||
name = "AUTHENTIK_WEB__BASE_URL"
|
||||
value = "https://${var.authentik.hostname}"
|
||||
},
|
||||
{
|
||||
name = "AUTHENTIK_LISTEN__TRUSTED_PROXY_CIDRS"
|
||||
value = "127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fe80::/10,::1/128"
|
||||
}
|
||||
]
|
||||
envFrom = [
|
||||
{
|
||||
secretRef = {
|
||||
name = var.authentik.secret_name
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
authentik = {
|
||||
log_level = "info"
|
||||
error_reporting = {
|
||||
enabled = false
|
||||
}
|
||||
postgresql = {
|
||||
host = "authentik-postgresql"
|
||||
name = "authentik"
|
||||
user = "authentik"
|
||||
}
|
||||
}
|
||||
server = {
|
||||
replicas = 1
|
||||
nodeSelector = local.prometheus_stack_node_selector
|
||||
ingress = {
|
||||
enabled = true
|
||||
ingressClassName = var.traefik.ingress_class
|
||||
hosts = [var.authentik.hostname]
|
||||
}
|
||||
metrics = {
|
||||
enabled = true
|
||||
serviceMonitor = {
|
||||
enabled = var.authentik.service_monitor
|
||||
namespace = var.observability.namespace
|
||||
}
|
||||
}
|
||||
resources = {
|
||||
requests = {
|
||||
cpu = var.authentik.server_cpu_request
|
||||
memory = var.authentik.server_memory_request
|
||||
}
|
||||
limits = {
|
||||
cpu = var.authentik.server_cpu_limit
|
||||
memory = var.authentik.server_memory_limit
|
||||
}
|
||||
}
|
||||
startupProbe = {
|
||||
failureThreshold = 180
|
||||
initialDelaySeconds = 10
|
||||
periodSeconds = 10
|
||||
timeoutSeconds = 10
|
||||
}
|
||||
}
|
||||
worker = {
|
||||
replicas = 1
|
||||
nodeSelector = local.prometheus_stack_node_selector
|
||||
resources = {
|
||||
requests = {
|
||||
cpu = var.authentik.worker_cpu_request
|
||||
memory = var.authentik.worker_memory_request
|
||||
}
|
||||
limits = {
|
||||
cpu = var.authentik.worker_cpu_limit
|
||||
memory = var.authentik.worker_memory_limit
|
||||
}
|
||||
}
|
||||
startupProbe = {
|
||||
failureThreshold = 180
|
||||
initialDelaySeconds = 30
|
||||
periodSeconds = 10
|
||||
timeoutSeconds = 10
|
||||
}
|
||||
}
|
||||
postgresql = {
|
||||
enabled = true
|
||||
auth = {
|
||||
username = "authentik"
|
||||
database = "authentik"
|
||||
existingSecret = var.authentik.secret_name
|
||||
secretKeys = {
|
||||
adminPasswordKey = "postgres-password"
|
||||
userPasswordKey = "postgresql-password"
|
||||
}
|
||||
}
|
||||
primary = {
|
||||
persistence = {
|
||||
enabled = true
|
||||
storageClass = var.openebs.retain_storage_class
|
||||
size = var.authentik.postgresql_storage
|
||||
}
|
||||
resources = {
|
||||
requests = {
|
||||
cpu = "100m"
|
||||
memory = "256Mi"
|
||||
}
|
||||
limits = {
|
||||
cpu = "500m"
|
||||
memory = "512Mi"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
resource "null_resource" "authentik_readiness" {
|
||||
count = var.authentik.enabled ? 1 : 0
|
||||
|
||||
depends_on = [helm_release.authentik]
|
||||
|
||||
triggers = {
|
||||
kubeconfig_path = var.kubeconfig_path
|
||||
namespace = var.authentik.namespace
|
||||
hostname = var.authentik.hostname
|
||||
release_version = var.authentik.version
|
||||
}
|
||||
|
||||
provisioner "local-exec" {
|
||||
interpreter = ["/bin/bash", "-lc"]
|
||||
command = <<EOT
|
||||
set -euo pipefail
|
||||
|
||||
kubeconfig="${self.triggers.kubeconfig_path}"
|
||||
namespace="${self.triggers.namespace}"
|
||||
|
||||
dump_authentik_debug() {
|
||||
kubectl --kubeconfig "$kubeconfig" -n "$namespace" get pods,deploy,sts,svc,ingress,pvc -o wide >&2 || true
|
||||
kubectl --kubeconfig "$kubeconfig" -n "$namespace" get events --sort-by=.lastTimestamp 2>/dev/null | tail -80 >&2 || true
|
||||
}
|
||||
|
||||
if ! kubectl --kubeconfig "$kubeconfig" -n "$namespace" rollout status deployment/authentik-server --timeout=1800s; then
|
||||
dump_authentik_debug
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! kubectl --kubeconfig "$kubeconfig" -n "$namespace" rollout status deployment/authentik-worker --timeout=1800s; then
|
||||
dump_authentik_debug
|
||||
exit 1
|
||||
fi
|
||||
EOT
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_config_map" "grafana_dashboards" {
|
||||
for_each = local.grafana_dashboard_files
|
||||
|
||||
|
|
|
|||
|
|
@ -248,48 +248,6 @@ variable "observability" {
|
|||
}
|
||||
}
|
||||
|
||||
variable "authentik" {
|
||||
type = object({
|
||||
enabled = bool
|
||||
namespace = string
|
||||
repository = string
|
||||
chart = string
|
||||
version = string
|
||||
hostname = string
|
||||
postgresql_storage = string
|
||||
secret_name = string
|
||||
service_monitor = bool
|
||||
server_cpu_request = string
|
||||
server_memory_request = string
|
||||
server_cpu_limit = string
|
||||
server_memory_limit = string
|
||||
worker_cpu_request = string
|
||||
worker_memory_request = string
|
||||
worker_cpu_limit = string
|
||||
worker_memory_limit = string
|
||||
})
|
||||
|
||||
default = {
|
||||
enabled = true
|
||||
namespace = "authentik"
|
||||
repository = "https://charts.goauthentik.io"
|
||||
chart = "authentik"
|
||||
version = "2026.8.3"
|
||||
hostname = "auth.lab2025.duckdns.org"
|
||||
postgresql_storage = "8Gi"
|
||||
secret_name = "authentik-secrets"
|
||||
service_monitor = false
|
||||
server_cpu_request = "100m"
|
||||
server_memory_request = "512Mi"
|
||||
server_cpu_limit = "500m"
|
||||
server_memory_limit = "1Gi"
|
||||
worker_cpu_request = "100m"
|
||||
worker_memory_request = "512Mi"
|
||||
worker_cpu_limit = "500m"
|
||||
worker_memory_limit = "1Gi"
|
||||
}
|
||||
}
|
||||
|
||||
variable "prometheus_stack_node_selector" {
|
||||
description = "Node selector applied to kube-prometheus-stack control workloads so they stay off the control plane."
|
||||
type = map(string)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@ services:
|
|||
install_dir: /data/homelab-heimdall
|
||||
http_port: 8083
|
||||
public_url: https://homepage.lab2025.duckdns.org/
|
||||
authentik:
|
||||
host: debian
|
||||
install_dir: /data/homelab-authentik
|
||||
http_port: 9000
|
||||
public_url: https://auth.lab2025.duckdns.org/
|
||||
jellyfin:
|
||||
host: debian
|
||||
http_port: 8096
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
# Authentik
|
||||
|
||||
Authentik is the homelab identity provider and SSO control plane.
|
||||
|
||||
It intentionally runs outside Kubernetes as a Debian-hosted Docker Compose
|
||||
stack. That keeps login available while the Kubernetes cluster is rebuilt,
|
||||
recreated, or broken.
|
||||
|
||||
## Placement decision
|
||||
|
||||
The Raspberry Pi 4 is useful as a lightweight always-on appliance, but this lab
|
||||
already uses it for DNS, Unbound, Uptime Kuma, and node-exporter. Authentik is
|
||||
stateful and will become a dependency for Grafana, Argo CD, Jellyfin, and other
|
||||
apps, so the first standalone placement is the Debian host under `/data`.
|
||||
|
||||
The RPi can become a later failover target after restore drills prove the
|
||||
PostgreSQL/media backup path.
|
||||
|
||||
## Deploy
|
||||
|
||||
Run from the Debian homelab server:
|
||||
|
||||
```bash
|
||||
./jeannie deploy-authentik
|
||||
./jeannie edge
|
||||
```
|
||||
|
||||
After the standalone stack is healthy and edge points to it, remove the old
|
||||
Kubernetes proof-of-concept release:
|
||||
|
||||
```bash
|
||||
./jeannie platform
|
||||
```
|
||||
|
||||
The deploy command reuses the existing SOPS-encrypted secret:
|
||||
|
||||
```text
|
||||
apps/authentik/authentik.secret.yaml
|
||||
```
|
||||
|
||||
It renders a local Compose `.env` file on the Debian host. Do not commit the
|
||||
rendered `.env` file.
|
||||
|
||||
## Public URL
|
||||
|
||||
```text
|
||||
https://auth.lab2025.duckdns.org/
|
||||
```
|
||||
|
||||
First setup:
|
||||
|
||||
```text
|
||||
https://auth.lab2025.duckdns.org/if/flow/initial-setup/
|
||||
```
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
services:
|
||||
postgresql:
|
||||
image: ${AUTHENTIK_POSTGRES_IMAGE:-postgres:16-alpine}
|
||||
container_name: ${AUTHENTIK_POSTGRES_CONTAINER_NAME:-homelab-authentik-postgres}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${AUTHENTIK_POSTGRESQL__NAME:-authentik}
|
||||
POSTGRES_USER: ${AUTHENTIK_POSTGRESQL__USER:-authentik}
|
||||
POSTGRES_PASSWORD: ${AUTHENTIK_POSTGRESQL__PASSWORD}
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- pg_isready -d "$${POSTGRES_DB}" -U "$${POSTGRES_USER}"
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
volumes:
|
||||
- ${AUTHENTIK_POSTGRES_DATA_DIR:-/data/homelab-authentik/postgresql}:/var/lib/postgresql/data
|
||||
networks:
|
||||
- authentik
|
||||
|
||||
redis:
|
||||
image: ${AUTHENTIK_REDIS_IMAGE:-redis:7-alpine}
|
||||
container_name: ${AUTHENTIK_REDIS_CONTAINER_NAME:-homelab-authentik-redis}
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- redis-server
|
||||
- --save
|
||||
- "60"
|
||||
- "1"
|
||||
- --loglevel
|
||||
- warning
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD
|
||||
- redis-cli
|
||||
- ping
|
||||
interval: 30s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
volumes:
|
||||
- ${AUTHENTIK_REDIS_DATA_DIR:-/data/homelab-authentik/redis}:/data
|
||||
networks:
|
||||
- authentik
|
||||
|
||||
server:
|
||||
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server:2026.8.3}
|
||||
container_name: ${AUTHENTIK_SERVER_CONTAINER_NAME:-homelab-authentik-server}
|
||||
restart: unless-stopped
|
||||
command: server
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${AUTHENTIK_BIND_IP:-0.0.0.0}:${AUTHENTIK_HTTP_PORT:-9000}:9000/tcp"
|
||||
volumes:
|
||||
- ${AUTHENTIK_MEDIA_DIR:-/data/homelab-authentik/media}:/media
|
||||
- ${AUTHENTIK_TEMPLATES_DIR:-/data/homelab-authentik/templates}:/templates
|
||||
networks:
|
||||
- authentik
|
||||
|
||||
worker:
|
||||
image: ${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server:2026.8.3}
|
||||
container_name: ${AUTHENTIK_WORKER_CONTAINER_NAME:-homelab-authentik-worker}
|
||||
restart: unless-stopped
|
||||
command: worker
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ${AUTHENTIK_MEDIA_DIR:-/data/homelab-authentik/media}:/media
|
||||
- ${AUTHENTIK_TEMPLATES_DIR:-/data/homelab-authentik/templates}:/templates
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
networks:
|
||||
- authentik
|
||||
|
||||
networks:
|
||||
authentik:
|
||||
name: ${AUTHENTIK_NETWORK:-homelab-authentik}
|
||||
7
jeannie
7
jeannie
|
|
@ -53,6 +53,7 @@ Build And Bootstrap
|
|||
up Deploy the full homelab pipeline.
|
||||
deploy-gitea Deploy the Debian-hosted Gitea container.
|
||||
deploy-heimdall Deploy the Debian-hosted Heimdall dashboard.
|
||||
deploy-authentik Deploy the Debian-hosted Authentik SSO stack.
|
||||
deploy-matrix Deploy the Matrix homeserver (Synapse + Element + Postgres).
|
||||
deploy-omniroute Deploy the OmniRoute LLM routing gateway.
|
||||
deploy-hermes Deploy the Hermes agent (git-install + venv + gateway service).
|
||||
|
|
@ -100,7 +101,7 @@ Operator View And Reports
|
|||
|
||||
Observability And GitOps
|
||||
grafana-dashboards {list|apply} List or apply repo-managed Grafana dashboards.
|
||||
authentik-secret {ensure|apply|file} Generate/apply SOPS-encrypted Authentik bootstrap secrets.
|
||||
authentik-secret {ensure|file} Generate/check SOPS-encrypted Authentik bootstrap secrets.
|
||||
gitops-status Print focused Argo CD health and sync status.
|
||||
platform Deploy platform stack only.
|
||||
edge Deploy/check the OCI edge stack only.
|
||||
|
|
@ -351,6 +352,10 @@ case "${1:-}" in
|
|||
record_change_journal "deploy-heimdall" "$@"
|
||||
deploy_heimdall
|
||||
;;
|
||||
deploy-authentik)
|
||||
record_change_journal "deploy-authentik" "$@"
|
||||
deploy_authentik
|
||||
;;
|
||||
deploy-matrix)
|
||||
record_change_journal "deploy-matrix" "$@"
|
||||
deploy_matrix
|
||||
|
|
|
|||
|
|
@ -1397,6 +1397,7 @@ status_report() {
|
|||
fi
|
||||
status_compose_stack "gitea" "/data/homelab-gitea"
|
||||
status_compose_stack "heimdall" "${LAB_HEIMDALL_INSTALL_DIR:-/data/homelab-heimdall}"
|
||||
status_compose_stack "authentik" "${LAB_AUTHENTIK_INSTALL_DIR:-/data/homelab-authentik}"
|
||||
status_compose_stack "arr-stack" "${REPO_ROOT}/infra/arr-stack"
|
||||
|
||||
status_kubernetes
|
||||
|
|
@ -1415,8 +1416,10 @@ status_report() {
|
|||
status_http "website public" "${LAB_PUBLIC_URL:?LAB_PUBLIC_URL is required from homelab.yml}/"
|
||||
status_http "gitea public" "${LAB_GITEA_ROOT_URL:-${LAB_PUBLIC_URL:?LAB_PUBLIC_URL is required from homelab.yml}/git/}"
|
||||
status_http "heimdall public" "${LAB_HEIMDALL_PUBLIC_URL:-https://heimdall.${LAB_DOMAIN:?LAB_DOMAIN is required from homelab.yml}/}"
|
||||
status_http "authentik public" "${LAB_AUTHENTIK_PUBLIC_URL:-https://auth.${LAB_DOMAIN:?LAB_DOMAIN is required from homelab.yml}/}"
|
||||
status_http "gitea local" "http://127.0.0.1:${LAB_GITEA_HTTP_PORT:-3000}/"
|
||||
status_http "heimdall local" "http://127.0.0.1:${LAB_HEIMDALL_HTTP_PORT:-8082}/"
|
||||
status_http "authentik local" "http://127.0.0.1:${LAB_AUTHENTIK_HTTP_PORT:-9000}/-/health/live/"
|
||||
status_http "traefik lb" "http://${LAB_TRAEFIK_LB_IP:?LAB_TRAEFIK_LB_IP is required from homelab.yml}/"
|
||||
status_http "arr radarr" "http://127.0.0.1:7878/"
|
||||
status_http "arr sonarr" "http://127.0.0.1:8989/"
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ mapping = {
|
|||
"services.heimdall.public_url": "LAB_HEIMDALL_PUBLIC_URL",
|
||||
"services.homepage.http_port": "LAB_HOMEPAGE_HTTP_PORT",
|
||||
"services.homepage.public_url": "LAB_HOMEPAGE_PUBLIC_URL",
|
||||
"services.authentik.install_dir": "LAB_AUTHENTIK_INSTALL_DIR",
|
||||
"services.authentik.http_port": "LAB_AUTHENTIK_HTTP_PORT",
|
||||
"services.authentik.public_url": "LAB_AUTHENTIK_PUBLIC_URL",
|
||||
"services.jellyfin.http_port": "LAB_JELLYFIN_HTTP_PORT",
|
||||
"services.jellyfin.public_url": "LAB_JELLYFIN_PUBLIC_URL",
|
||||
"services.local_registry.endpoint": "LAB_REGISTRY_ENDPOINT",
|
||||
|
|
@ -185,6 +188,8 @@ export_homelab_inventory_tf_vars() {
|
|||
export_if_unset TF_VAR_heimdall_backend_port "${LAB_HEIMDALL_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_homepage_backend_host "${LAB_HOMEPAGE_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_homepage_backend_port "${LAB_HOMEPAGE_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_authentik_backend_host "${LAB_AUTHENTIK_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_authentik_backend_port "${LAB_AUTHENTIK_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_jellyfin_backend_host "${LAB_JELLYFIN_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_jellyfin_backend_port "${LAB_JELLYFIN_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_gitops_repo_url "${LAB_GITOPS_REPO_URL:-}"
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ mapping = {
|
|||
"services.heimdall.public_url": "LAB_HEIMDALL_PUBLIC_URL",
|
||||
"services.homepage.http_port": "LAB_HOMEPAGE_HTTP_PORT",
|
||||
"services.homepage.public_url": "LAB_HOMEPAGE_PUBLIC_URL",
|
||||
"services.authentik.install_dir": "LAB_AUTHENTIK_INSTALL_DIR",
|
||||
"services.authentik.http_port": "LAB_AUTHENTIK_HTTP_PORT",
|
||||
"services.authentik.public_url": "LAB_AUTHENTIK_PUBLIC_URL",
|
||||
"services.jellyfin.http_port": "LAB_JELLYFIN_HTTP_PORT",
|
||||
"services.jellyfin.public_url": "LAB_JELLYFIN_PUBLIC_URL",
|
||||
"services.local_registry.endpoint": "LAB_REGISTRY_ENDPOINT",
|
||||
|
|
@ -186,6 +189,8 @@ export_homelab_inventory_tf_vars() {
|
|||
export_if_unset TF_VAR_heimdall_backend_port "${LAB_HEIMDALL_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_homepage_backend_host "${LAB_HOMEPAGE_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_homepage_backend_port "${LAB_HOMEPAGE_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_authentik_backend_host "${LAB_AUTHENTIK_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_authentik_backend_port "${LAB_AUTHENTIK_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_jellyfin_backend_host "${LAB_JELLYFIN_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}"
|
||||
export_if_unset TF_VAR_jellyfin_backend_port "${LAB_JELLYFIN_HTTP_PORT:-}"
|
||||
export_if_unset TF_VAR_gitops_repo_url "${LAB_GITOPS_REPO_URL:-}"
|
||||
|
|
@ -503,10 +508,6 @@ run_tofu_stack() {
|
|||
ensure_edge_tailscale_routes
|
||||
ensure_edge_haproxy_stats_password
|
||||
fi
|
||||
if [[ "${stack}" == "bootstrap/platform" ]]; then
|
||||
ensure_authentik_secret
|
||||
fi
|
||||
|
||||
if truthy "${auto_approve}"; then
|
||||
apply_args+=("-auto-approve")
|
||||
elif ! disabled_value "${auto_approve}"; then
|
||||
|
|
@ -3997,6 +3998,152 @@ ENV_EOT
|
|||
echo "Homepage is reachable at http://127.0.0.1:${homepage_http_port}/ and ${homepage_public_url%/}/."
|
||||
}
|
||||
|
||||
deploy_authentik() {
|
||||
local mode="${LAB_AUTHENTIK_DEPLOY:-true}"
|
||||
local install_dir="${LAB_AUTHENTIK_INSTALL_DIR:-/data/homelab-authentik}"
|
||||
local data_dir="${LAB_AUTHENTIK_DATA_DIR:-${install_dir}/data}"
|
||||
local http_port="${LAB_AUTHENTIK_HTTP_PORT:-9000}"
|
||||
local bind_ip="${LAB_AUTHENTIK_BIND_IP:-0.0.0.0}"
|
||||
local public_url="${LAB_AUTHENTIK_PUBLIC_URL:-https://auth.${LAB_DOMAIN:-lab2025.duckdns.org}/}"
|
||||
local image="${AUTHENTIK_IMAGE:-ghcr.io/goauthentik/server:2026.8.3}"
|
||||
local postgres_image="${AUTHENTIK_POSTGRES_IMAGE:-postgres:16-alpine}"
|
||||
local redis_image="${AUTHENTIK_REDIS_IMAGE:-redis:7-alpine}"
|
||||
local network="${AUTHENTIK_NETWORK:-homelab-authentik}"
|
||||
local install_docker="${LAB_AUTHENTIK_INSTALL_DOCKER:-false}"
|
||||
local source_dir="${REPO_ROOT}/infra/authentik"
|
||||
local secret_file
|
||||
local key_file
|
||||
local decrypted_text
|
||||
local rendered_secret_env
|
||||
local elapsed=0
|
||||
local value_name
|
||||
local value
|
||||
|
||||
require_debian_server "deploy-authentik"
|
||||
|
||||
if disabled_value "${mode}"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
for value_name in install_dir data_dir http_port bind_ip public_url image postgres_image redis_image network install_docker; do
|
||||
value="${!value_name}"
|
||||
if [[ "${value}" == *$'\n'* ]]; then
|
||||
echo "${value_name} cannot contain a newline." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -s "${source_dir}/docker-compose.yml" ]]; then
|
||||
echo "Missing Authentik source files in ${source_dir}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_authentik_secret_file
|
||||
secret_file="$(authentik_secret_file)"
|
||||
key_file="$(sops_age_key_file)"
|
||||
if [[ -s "${key_file}" ]]; then
|
||||
decrypted_text="$(SOPS_AGE_KEY_FILE="${key_file}" sops -d "${secret_file}")" || exit 1
|
||||
else
|
||||
decrypted_text="$(sops -d "${secret_file}")" || exit 1
|
||||
fi
|
||||
|
||||
rendered_secret_env="$(SECRET_TEXT="${decrypted_text}" python3 - <<'PY'
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except Exception as exc:
|
||||
print(f"PyYAML is required to parse the Authentik secret: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
document = yaml.safe_load(os.environ.get("SECRET_TEXT", "")) or {}
|
||||
values = {}
|
||||
for section in ("stringData", "data"):
|
||||
raw = document.get(section) or {}
|
||||
if isinstance(raw, dict):
|
||||
values.update(raw)
|
||||
|
||||
required = [
|
||||
"AUTHENTIK_SECRET_KEY",
|
||||
"AUTHENTIK_POSTGRESQL__PASSWORD",
|
||||
"AUTHENTIK_BOOTSTRAP_TOKEN",
|
||||
"AUTHENTIK_BOOTSTRAP_EMAIL",
|
||||
]
|
||||
missing = [key for key in required if not values.get(key)]
|
||||
if missing:
|
||||
print(f"Missing Authentik secret keys: {', '.join(missing)}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
for key in required:
|
||||
value = str(values[key])
|
||||
if "\n" in value or "\r" in value:
|
||||
print(f"Secret value for {key} cannot contain a newline", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print(f"{key}={value}")
|
||||
PY
|
||||
)" || exit 1
|
||||
|
||||
echo "Deploying standalone Authentik on the Debian host at ${install_dir}..."
|
||||
|
||||
ensure_local_docker_compose "AUTHENTIK" "${install_docker}"
|
||||
repair_local_docker_iptables
|
||||
|
||||
sudo mkdir -p \
|
||||
"${install_dir}" \
|
||||
"${data_dir}/postgresql" \
|
||||
"${data_dir}/redis" \
|
||||
"${data_dir}/media" \
|
||||
"${data_dir}/templates"
|
||||
sudo cp "${source_dir}/docker-compose.yml" "${install_dir}/docker-compose.yml"
|
||||
sudo tee "${install_dir}/.env" >/dev/null <<ENV_EOT
|
||||
AUTHENTIK_IMAGE=${image}
|
||||
AUTHENTIK_POSTGRES_IMAGE=${postgres_image}
|
||||
AUTHENTIK_REDIS_IMAGE=${redis_image}
|
||||
AUTHENTIK_SERVER_CONTAINER_NAME=${AUTHENTIK_SERVER_CONTAINER_NAME:-homelab-authentik-server}
|
||||
AUTHENTIK_WORKER_CONTAINER_NAME=${AUTHENTIK_WORKER_CONTAINER_NAME:-homelab-authentik-worker}
|
||||
AUTHENTIK_POSTGRES_CONTAINER_NAME=${AUTHENTIK_POSTGRES_CONTAINER_NAME:-homelab-authentik-postgres}
|
||||
AUTHENTIK_REDIS_CONTAINER_NAME=${AUTHENTIK_REDIS_CONTAINER_NAME:-homelab-authentik-redis}
|
||||
AUTHENTIK_HTTP_PORT=${http_port}
|
||||
AUTHENTIK_BIND_IP=${bind_ip}
|
||||
AUTHENTIK_PUBLIC_URL=${public_url%/}
|
||||
AUTHENTIK_WEB__BASE_URL=${public_url%/}
|
||||
AUTHENTIK_LISTEN__TRUSTED_PROXY_CIDRS=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,fe80::/10,::1/128
|
||||
AUTHENTIK_ERROR_REPORTING__ENABLED=false
|
||||
AUTHENTIK_POSTGRESQL__HOST=postgresql
|
||||
AUTHENTIK_POSTGRESQL__NAME=authentik
|
||||
AUTHENTIK_POSTGRESQL__USER=authentik
|
||||
AUTHENTIK_REDIS__HOST=redis
|
||||
AUTHENTIK_POSTGRES_DATA_DIR=${data_dir}/postgresql
|
||||
AUTHENTIK_REDIS_DATA_DIR=${data_dir}/redis
|
||||
AUTHENTIK_MEDIA_DIR=${data_dir}/media
|
||||
AUTHENTIK_TEMPLATES_DIR=${data_dir}/templates
|
||||
AUTHENTIK_NETWORK=${network}
|
||||
TZ=America/Mexico_City
|
||||
${rendered_secret_env}
|
||||
ENV_EOT
|
||||
sudo chmod 600 "${install_dir}/.env"
|
||||
|
||||
(
|
||||
cd "${install_dir}"
|
||||
sudo docker compose --env-file "${install_dir}/.env" pull
|
||||
sudo docker compose --env-file "${install_dir}/.env" up -d --remove-orphans
|
||||
sudo docker compose --env-file "${install_dir}/.env" ps
|
||||
)
|
||||
|
||||
until curl -fsS --connect-timeout 5 "http://127.0.0.1:${http_port}/-/health/live/" >/dev/null; do
|
||||
if ((elapsed >= 900)); then
|
||||
echo "Timed out waiting for Authentik on http://127.0.0.1:${http_port}/-/health/live/" >&2
|
||||
(cd "${install_dir}" && sudo docker compose --env-file "${install_dir}/.env" ps && sudo docker compose --env-file "${install_dir}/.env" logs --tail=160) >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
elapsed=$((elapsed + 5))
|
||||
done
|
||||
|
||||
echo "Authentik is reachable at http://127.0.0.1:${http_port}/ and ${public_url%/}/."
|
||||
}
|
||||
|
||||
deploy_matrix() {
|
||||
local mode="${LAB_MATRIX_DEPLOY:-true}"
|
||||
local install_dir="${LAB_MATRIX_INSTALL_DIR:-/home/jv/matrix-server}"
|
||||
|
|
@ -5730,6 +5877,11 @@ spec = {
|
|||
"title": "Heimdall deploy",
|
||||
"command": [jeannie, "__up-task", "heimdall-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "authentik-deploy",
|
||||
"title": "Authentik deploy",
|
||||
"command": [jeannie, "__up-task", "authentik-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "matrix-deploy",
|
||||
"title": "Matrix deploy",
|
||||
|
|
@ -5802,6 +5954,9 @@ up_task() {
|
|||
heimdall-deploy)
|
||||
deploy_heimdall
|
||||
;;
|
||||
authentik-deploy)
|
||||
deploy_authentik
|
||||
;;
|
||||
matrix-deploy)
|
||||
deploy_matrix
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -269,27 +269,10 @@ ensure_authentik_secret_file() {
|
|||
echo "Commit this encrypted file after validating the deployment; it contains no plaintext secret."
|
||||
}
|
||||
|
||||
apply_authentik_secret() {
|
||||
local secret_file
|
||||
|
||||
secret_file="$(authentik_secret_file)"
|
||||
ensure_authentik_secret_file
|
||||
|
||||
if ! command -v kubectl >/dev/null 2>&1; then
|
||||
echo "kubectl is required to apply the Authentik secret." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
kubectl --kubeconfig "${KUBECONFIG_PATH}" create namespace authentik --dry-run=client -o yaml |
|
||||
kubectl --kubeconfig "${KUBECONFIG_PATH}" apply -f -
|
||||
SOPS_AGE_KEY_FILE="$(sops_age_key_file)" sops -d "${secret_file}" |
|
||||
kubectl --kubeconfig "${KUBECONFIG_PATH}" apply -f -
|
||||
}
|
||||
|
||||
ensure_authentik_secret() {
|
||||
require_debian_server "authentik-secret"
|
||||
apply_authentik_secret >/dev/null
|
||||
echo "Authentik bootstrap secret is present in Kubernetes."
|
||||
ensure_authentik_secret_file >/dev/null
|
||||
echo "Authentik bootstrap secret file is present."
|
||||
}
|
||||
|
||||
authentik_secret() {
|
||||
|
|
@ -298,16 +281,21 @@ authentik_secret() {
|
|||
require_debian_server "authentik-secret"
|
||||
|
||||
case "${action}" in
|
||||
ensure | apply)
|
||||
apply_authentik_secret
|
||||
echo "Authentik bootstrap secret is ready."
|
||||
ensure)
|
||||
ensure_authentik_secret_file
|
||||
echo "Authentik bootstrap secret file is ready."
|
||||
;;
|
||||
apply)
|
||||
echo "The Authentik Kubernetes secret apply step is deprecated; Authentik now deploys as a standalone Compose stack." >&2
|
||||
ensure_authentik_secret_file
|
||||
echo "Authentik bootstrap secret file is ready."
|
||||
;;
|
||||
file)
|
||||
ensure_authentik_secret_file
|
||||
authentik_secret_file
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ./jeannie authentik-secret {ensure|apply|file}" >&2
|
||||
echo "Usage: ./jeannie authentik-secret {ensure|file}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Reference in New Issue