Research-Stack/4-Infrastructure/k3s-flake/scripts/deploy-services.sh
Brandon Schneider fd863af6fd Expand devcontainer with full Python stack, add MCP servers (Notion/AWS), strengthen Lean theorems
- .devcontainer/Dockerfile: add PostgreSQL client libs, OpenSSL/libffi headers, gfortran/BLAS for scipy, rclone; install full Python dependency set (boto3, psycopg2-binary, fastapi, uvicorn, notion-client, httpx, pytest, numpy, scipy, etc.) in uv-managed venv; add rclone S3 gateway init script as ENTRYPOINT
- .devcontainer/devcontainer.json: switch from build to pre-built image (localhost/research
2026-05-19 01:52:14 -05:00

42 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
###########################################################################
# deploy-services.sh
#
# Idempotent service deployer for the k3s unified topology.
# Called by the deploy-k3s-services systemd oneshot on the server node.
#
# Flow:
# 1. Wait for k3s cluster to be healthy
# 2. Create the K8s Secret for authentik from the sops-decrypted file
# 3. Apply all manifests via kubectl
# 4. k3s built-in Helm controller picks up the HelmChart CRD for authentik
###########################################################################
MANIFESTS_DIR="$(dirname "$0")/../manifests"
echo "[deploy] waiting for k3s cluster to be healthy..."
until kubectl cluster-info --request-timeout=5s >/dev/null 2>&1; do
sleep 3
done
echo "[deploy] cluster is healthy"
echo "[deploy] ensuring services namespace exists..."
kubectl get namespace services >/dev/null 2>&1 || kubectl create namespace services
# Authentik secrets from sops-decrypted file.
# The file format is an env file:
# secret-key=<value>
# postgresql-password=<value>
if [ -n "${AUTHENTIK_SECRETS:-}" ] && [ -f "$AUTHENTIK_SECRETS" ]; then
echo "[deploy] creating authentik-secrets from sops file..."
kubectl delete secret --ignore-not-found -n services authentik-secrets
kubectl create secret generic -n services authentik-secrets \
--from-env-file="$AUTHENTIK_SECRETS"
fi
echo "[deploy] applying all service manifests..."
kubectl apply -k "$MANIFESTS_DIR"
echo "[deploy] done"