mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 16:04:31 +00:00
Three independent lines of work landing in one commit because they were all on disk together end-of-session and the cross-file edits (TODO, knoe-system, junie/README) interleave cleanly: 1. **Queue #3 — image rename `knoe-authority` → `knoe-auth`** (Junie). Closes drift R6. The Maven artifact has been `knoe-auth.jar` since commit b355855; the deploy manifests now match. authority/Dockerfile.app (NEW) deploy/gcp/gke/knoe-auth-deployment.yaml (3 image tags renamed) deploy/opentofu/k3s/manifests/knoe/knoe-auth-deployment.yaml (2 image tags renamed) Makefile (docker-build-auth + docker-push-auth + REGISTRY/KNOE_AUTH_VERSION defaults) docs/plans/junie/03-image-rename-knoe-authority-to-knoe-auth.md (brief, kept as design record) 2. **Phase 2 OIDC provider — GKE deploy** (Junie). Source landed via the merge that brought claude/crazy-bose-fec256 back; the k3d sandbox shipped earlier today (commit93157b0). This commit completes the GKE path: Kong route `/auth` → knoe-auth, default values added, signing key wired via `knoe-auth-oidc` secret per the brief. supabase/helm/knoe-supabase/templates/kong/config.yaml (Kong route /auth, gated on .Values.knoeAuth.enabled) supabase/helm/knoe-supabase/values.yaml (knoeAuth.enabled=false default; studioIngress block — also fixes the helm lint issue noted in earlier commit03bb731) docs/plans/junie/phase2-oidc-gke-deploy.md (brief, kept as design record) 3. **k3d dev-user seed: `chrisfu` + `knoe_developer`** (Claude). Closes "I want auth as chrisfu@knoey.com to my local cnpg database" for the local dev loop. `etc/init_knoe_auth.sh --mode k3d` now runs `seed_dev_users_k3d()` after the schema bootstrap, creating: - `knoe_developer` group role with R/W on `knoe`+`public` (mirrors the GKE production layout from docs/db-access.md; was hand-rolled in production per the 2026-04-30 onboarding work, never baked into postInitTemplateSQL). - `chrisfu` LOGIN role with password `chrisfu-dev` (idempotent — resets on every `make k3d-knoe-up`, so the rebuild loop is deterministic). Granted into `knoe_developer`. From the host with port-forward up: PGPASSWORD=chrisfu-dev psql "postgresql://chrisfu@localhost:5432/knoe-db?sslmode=require" Cross-cutting doc updates: docs/TODO.md — Phase 2 GKE entry removed from "In progress" (now "(none — all items shipped or paused)"); queue #3 + reality table R6 removed; pg_oauth paused note flipped to "OIDC issuer now deployed to GKE — pg_oauth can resume"; Done section gets new entries for #3, Phase 2 GKE, and chrisfu seed. docs/knoe-system.md — Phase 2 GKE row → Shipped; pg_oauth → Ready; knoe-auth-deployment.yaml note "knoe-auth:latest" instead of "knoe-authority:latest"; "One-time cluster setup" mentions the chrisfu seed. docs/local-dev-knoe-auth.md — "Verify psql connectivity" rewritten to connect as chrisfu (was `knoe`); new "Reset / rebuild loop" section explaining idempotency. docs/plans/junie/README.md — two new rows under Shipped: brief 03 and phase2-oidc-gke-deploy. Verification (the bits I ran locally): - bash -n etc/init_knoe_auth.sh OK - The seed SQL is idempotent (DO blocks with EXISTS checks + ALTER ROLE on the password reset path) - The Kong /auth route is gated on .Values.knoeAuth.enabled — default false, no behavior change until someone flips it on per Junie's brief Out of scope for this commit: - Actually flipping knoeAuth.enabled=true on the live GKE chart and rolling out — Junie's brief covers the runbook; needs the knoe-auth-oidc K8s secret populated from 1Password first - Rebuilding + pushing the new knoe-auth:latest image — `make docker-push-auth` is wired, just hasn't been run yet - Round 1.5 OpenBao transit-key encryption (still queued) Co-authored-by: Junie <junie@jetbrains.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
331 lines
12 KiB
YAML
331 lines
12 KiB
YAML
---
|
|
# knoe-auth-deployment.yaml
|
|
# Deploys the knoe-auth pod (Spring Boot + KDC sidecar) to knoe-dev-0 / knoe-system.
|
|
# Based on deploy/opentofu/k3s/manifests/knoe/knoe-auth-deployment.yaml.
|
|
# Realm: KNOE.DEV (not PROLE.LOCAL)
|
|
# Image: pulled from Artifact Registry — built by knoe-auth CI pipeline.
|
|
#
|
|
# Apply: kubectl -n knoe-system apply -f deploy/gcp/gke/knoe-auth-deployment.yaml
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: knoe-auth
|
|
namespace: knoe-system
|
|
labels:
|
|
app: knoe-auth
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: knoe-auth
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: knoe-auth
|
|
spec:
|
|
initContainers:
|
|
# keytab-bootstrap: runs kadmin.local inside the shared KDC data volume
|
|
# to create the HTTP service principal and export the keytab before the
|
|
# Spring Boot container starts.
|
|
- name: keytab-bootstrap
|
|
image: us-west3-docker.pkg.dev/plenary-truck-485623-p7/knoe-system/knoe-auth:latest
|
|
imagePullPolicy: Always
|
|
command:
|
|
- /bin/bash
|
|
- -lc
|
|
- |
|
|
set -euo pipefail
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
realm="${KNOE_KDC_REALM:-KNOE.DEV}"
|
|
admin_principal="${KNOE_KDC_ADMIN_PRINCIPAL:-admin/admin}"
|
|
if [[ "${admin_principal}" != *"@"* ]]; then
|
|
admin_principal="${admin_principal}@${realm}"
|
|
fi
|
|
|
|
svc_principal="${KNOE_KERBEROS_SERVICE_PRINCIPAL:?Missing KNOE_KERBEROS_SERVICE_PRINCIPAL}"
|
|
if [[ "${svc_principal}" != *"@"* ]]; then
|
|
svc_principal="${svc_principal}@${realm}"
|
|
fi
|
|
|
|
keytab_out="/etc/knoe/keytabs/http.keytab"
|
|
mkdir -p "$(dirname "${keytab_out}")"
|
|
|
|
# If a pre-provisioned keytab is provided as a Secret, use it directly.
|
|
if [[ -f /mnt/keytab-secret/http.keytab ]]; then
|
|
cp /mnt/keytab-secret/http.keytab "${keytab_out}"
|
|
chmod 0400 "${keytab_out}" || true
|
|
exit 0
|
|
fi
|
|
|
|
if ! command -v kadmin.local >/dev/null 2>&1; then
|
|
echo "Installing Kerberos packages..."
|
|
echo "krb5-config krb5-config/default_realm string ${realm}" | debconf-set-selections || true
|
|
echo "krb5-config krb5-config/kerberos_servers string 127.0.0.1" | debconf-set-selections || true
|
|
echo "krb5-config krb5-config/admin_server string 127.0.0.1" | debconf-set-selections || true
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends krb5-kdc krb5-admin-server krb5-user dnsutils ca-certificates
|
|
rm -rf /var/lib/apt/lists/*
|
|
fi
|
|
|
|
mkdir -p /etc/krb5kdc /var/lib/krb5kdc
|
|
[[ -f /opt/knoe-kdc/krb5.conf ]] && cp /opt/knoe-kdc/krb5.conf /etc/krb5.conf
|
|
[[ -f /opt/knoe-kdc/kdc.conf ]] && cp /opt/knoe-kdc/kdc.conf /etc/krb5kdc/kdc.conf
|
|
[[ -f /opt/knoe-kdc/kadm5.acl ]] && cp /opt/knoe-kdc/kadm5.acl /etc/krb5kdc/kadm5.acl
|
|
|
|
if [[ -z "${KNOE_KDC_MASTER_PASSWORD:-}" ]]; then
|
|
echo "ERROR: Missing KNOE_KDC_MASTER_PASSWORD" >&2; exit 1
|
|
fi
|
|
if [[ -z "${KNOE_KDC_ADMIN_PASSWORD:-}" ]]; then
|
|
echo "ERROR: Missing KNOE_KDC_ADMIN_PASSWORD" >&2; exit 1
|
|
fi
|
|
|
|
if [[ ! -f /var/lib/krb5kdc/principal ]]; then
|
|
echo "Initializing realm database for ${realm}..."
|
|
kdb5_util create -s -r "${realm}" -P "${KNOE_KDC_MASTER_PASSWORD}"
|
|
fi
|
|
|
|
if ! kadmin.local -q "get_principal ${admin_principal}" >/dev/null 2>&1; then
|
|
kadmin.local -q "addprinc -pw ${KNOE_KDC_ADMIN_PASSWORD} ${admin_principal}"
|
|
fi
|
|
|
|
if ! kadmin.local -q "get_principal ${svc_principal}" >/dev/null 2>&1; then
|
|
echo "Creating service principal ${svc_principal}..."
|
|
kadmin.local -q "addprinc -randkey ${svc_principal}"
|
|
fi
|
|
|
|
kadmin.local -q "ktadd -k ${keytab_out} -norandkey ${svc_principal}"
|
|
chmod 0400 "${keytab_out}" || true
|
|
echo "Keytab written to ${keytab_out}"
|
|
env:
|
|
- name: KNOE_KDC_REALM
|
|
value: "KNOE.DEV"
|
|
- name: KNOE_KDC_ADMIN_PRINCIPAL
|
|
value: "admin/admin"
|
|
- name: KNOE_KDC_MASTER_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-kdc-secrets
|
|
key: master_password
|
|
- name: KNOE_KDC_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-kdc-secrets
|
|
key: admin_password
|
|
- name: KNOE_KERBEROS_SERVICE_PRINCIPAL
|
|
value: "HTTP/auth.knoe.dev"
|
|
volumeMounts:
|
|
- name: keytab
|
|
mountPath: /etc/knoe/keytabs
|
|
- name: keytab-secret
|
|
mountPath: /mnt/keytab-secret
|
|
readOnly: true
|
|
- name: knoe-kdc-config
|
|
mountPath: /opt/knoe-kdc
|
|
- name: knoe-kdc-data
|
|
mountPath: /var/lib/krb5kdc
|
|
- name: knoe-kdc-etc
|
|
mountPath: /etc/krb5kdc
|
|
|
|
containers:
|
|
# ── Spring Boot / knoe-auth ──────────────────────────────────────────
|
|
- name: knoe-auth
|
|
image: us-west3-docker.pkg.dev/plenary-truck-485623-p7/knoe-system/knoe-auth:latest
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- name: http
|
|
containerPort: 8080
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8080
|
|
initialDelaySeconds: 20
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8080
|
|
initialDelaySeconds: 60
|
|
periodSeconds: 30
|
|
env:
|
|
- name: KNOE_AUTH_COOKIE_DOMAIN
|
|
value: ".knoe.dev"
|
|
- name: KNOE_AUTH_SESSION_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-secrets
|
|
key: sessionSecret
|
|
# ── Kerberos ───────────────────────────────────────────────────
|
|
- name: KNOE_KERBEROS_SERVICE_PRINCIPAL
|
|
value: "HTTP/auth.knoe.dev@KNOE.DEV"
|
|
- name: KNOE_KERBEROS_KEYTAB_PATH
|
|
value: "/etc/knoe/keytabs/http.keytab"
|
|
- name: KNOE_KERBEROS_REALM
|
|
value: "KNOE.DEV"
|
|
# ── Google OAuth2 (enrollment corroboration) ───────────────────
|
|
- name: GOOGLE_CLIENT_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-google-oidc
|
|
key: client_id
|
|
optional: true
|
|
- name: GOOGLE_CLIENT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-google-oidc
|
|
key: client_secret
|
|
optional: true
|
|
# ── Database (CNPG via cluster-internal service) ───────────────
|
|
- name: KNOE_DB_URL
|
|
value: "jdbc:postgresql://knoe-db-rw.knoe-db-0.svc.cluster.local:5432/knoe"
|
|
- name: KNOE_DB_USER
|
|
value: "knoe"
|
|
- name: KNOE_DB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-db-app
|
|
key: password
|
|
optional: true
|
|
# ── Enrollment ────────────────────────────────────────────────
|
|
- name: KNOE_ENROLL_INVITE_TTL_HOURS
|
|
value: "72"
|
|
- name: KNOE_ENROLL_OTP_TTL_MINUTES
|
|
value: "10"
|
|
- name: KNOE_ENROLL_OTP_MAX_ATTEMPTS
|
|
value: "3"
|
|
- name: KNOE_ENROLL_TOTP_ISSUER
|
|
value: "Knoe.DEV"
|
|
- name: KNOE_AUTH_BASE_URL
|
|
value: "https://api.knoe.dev/auth"
|
|
# ── OIDC Provider (Path B) ────────────────────────────────────
|
|
- name: KNOE_AUTH_OIDC_ENABLED
|
|
value: "true"
|
|
- name: KNOE_AUTH_OIDC_ISSUER
|
|
value: "https://api.knoe.dev/auth"
|
|
- name: KNOE_AUTH_OIDC_CLIENT_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-oidc
|
|
key: client-id
|
|
optional: true
|
|
- name: KNOE_AUTH_OIDC_CLIENT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-oidc
|
|
key: client-secret
|
|
optional: true
|
|
- name: KNOE_AUTH_OIDC_SIGNING_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-auth-oidc
|
|
key: signing-key
|
|
optional: true
|
|
# ── Provisioning ─────────────────────────────────────────────
|
|
- name: KNOE_PROVISIONING_POLL_INTERVAL_MS
|
|
value: "10000"
|
|
- name: KNOE_GITEA_URL
|
|
value: "https://git.knoe.dev"
|
|
- name: KNOE_GITEA_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-gitea-admin
|
|
key: token
|
|
optional: true
|
|
volumeMounts:
|
|
- name: keytab
|
|
mountPath: /etc/knoe/keytabs
|
|
readOnly: true
|
|
- name: knoe-kdc-config
|
|
mountPath: /etc/krb5.conf
|
|
subPath: krb5.conf
|
|
readOnly: true
|
|
|
|
# ── MIT Kerberos KDC sidecar ─────────────────────────────────────────
|
|
- name: kdc
|
|
image: us-west3-docker.pkg.dev/plenary-truck-485623-p7/knoe-system/knoe-auth:latest
|
|
imagePullPolicy: Always
|
|
command: ["/bin/bash", "/opt/knoe-kdc/entrypoint.sh"]
|
|
env:
|
|
- name: KNOE_KDC_REALM
|
|
value: "KNOE.DEV"
|
|
- name: KNOE_KDC_ADMIN_PRINCIPAL
|
|
value: "admin/admin"
|
|
- name: KNOE_KDC_MASTER_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-kdc-secrets
|
|
key: master_password
|
|
- name: KNOE_KDC_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: knoe-kdc-secrets
|
|
key: admin_password
|
|
ports:
|
|
- name: krb5-udp
|
|
containerPort: 88
|
|
protocol: UDP
|
|
- name: krb5-tcp
|
|
containerPort: 88
|
|
protocol: TCP
|
|
- name: kpasswd-udp
|
|
containerPort: 464
|
|
protocol: UDP
|
|
- name: kpasswd-tcp
|
|
containerPort: 464
|
|
protocol: TCP
|
|
- name: kadmin
|
|
containerPort: 749
|
|
protocol: TCP
|
|
volumeMounts:
|
|
- name: knoe-kdc-config
|
|
mountPath: /opt/knoe-kdc
|
|
- name: knoe-kdc-data
|
|
mountPath: /var/lib/krb5kdc
|
|
- name: knoe-kdc-etc
|
|
mountPath: /etc/krb5kdc
|
|
|
|
volumes:
|
|
- name: keytab
|
|
emptyDir: {}
|
|
- name: keytab-secret
|
|
secret:
|
|
secretName: knoe-auth-keytab
|
|
optional: true
|
|
- name: knoe-kdc-config
|
|
configMap:
|
|
name: knoe-kdc-config
|
|
defaultMode: 0755
|
|
- name: knoe-kdc-data
|
|
emptyDir: {}
|
|
- name: knoe-kdc-etc
|
|
emptyDir: {}
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: knoe-auth
|
|
namespace: knoe-system
|
|
labels:
|
|
app: knoe-auth
|
|
spec:
|
|
selector:
|
|
app: knoe-auth
|
|
ports:
|
|
- name: http
|
|
port: 80
|
|
targetPort: 8080
|
|
- name: krb5-tcp
|
|
port: 88
|
|
targetPort: 88
|
|
protocol: TCP
|
|
- name: krb5-udp
|
|
port: 88
|
|
targetPort: 88
|
|
protocol: UDP
|
|
- name: kadmin
|
|
port: 749
|
|
targetPort: 749
|
|
protocol: TCP
|
|
type: ClusterIP
|