# Authentik 部署指南 ## 目录结构 ``` authentik-deploy/ ├── 00-ns.yaml # Namespace ├── 01-postgres.yaml # PostgreSQL 数据库 ├── 02-secret.yaml # 密钥(密码) ├── auth-helm-values.yaml # Authentik Helm 配置 ├── 03-ingress.yaml # Ingress + TLS 证书 ├── install.sh # 一键安装脚本 └── README.md # 本文件 ``` ## 部署步骤 ### 1. 准备 确保集群已安装: - **Helm 3** - **cert-manager**(自动管理 HTTPS 证书) ```bash kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.0/cert-manager.yaml ``` ### 2. 修改配置 编辑 `02-secret.yaml`,替换为真实随机密码: ```bash # 生成随机密码 python3 -c "import secrets; print(secrets.token_urlsafe(32))" ``` 将输出填入 `authentik-secret-key` 和 `postgres-password`。 编辑 `03-ingress.yaml`,将 `YOUR_EMAIL@domain.com` 替换为你的邮箱。 ### 3. 执行部署 ```bash cd authentik-deploy chmod +x install.sh ./install.sh ``` 或手动按顺序执行: ```bash kubectl create ns auth kubectl apply -f 00-ns.yaml kubectl apply -f 01-postgres.yaml kubectl apply -f 02-secret.yaml helm repo add authentik https://charts.goauthentik.io && helm repo update helm install authentik authentik/authentik -n auth -f auth-helm-values.yaml kubectl apply -f 03-ingress.yaml ``` ### 4. 初始化 部署完成后访问: - **首次设置**: https://auth.violin-work.online/if/flow/initial/ - 设置管理员账号和密码 ### 5. 验证 ```bash kubectl get pods -n auth kubectl logs -n auth -l app.kubernetes.io/component=server --tail=20 ``` --- ## 后续:配置其他服务接入 Authentik(OIDC) ### 在 Authentik 中创建 Application 1. 登录 Authentik Admin → **Applications** 2. 点击 **Create**: - **Name**: OpenViking(或任意名称) - **Slug**: openviking - **Provider**: 创建 OIDC Provider(见下方) 3. 创建 Provider: - **Name**: OpenViking Provider - **Client ID**: openviking - **Client Secret**: 生成一个随机值 - **Redirect URIs**: `https://viking.violin-work.online/-/oauth-callback/openviking/`(根据实际调整) ### OpenViking 配置 OIDC 在 OpenViking 的配置文件中加入: ```json { "oidc": { "issuer": "https://auth.violin-work.online", "client_id": "openviking", "client_secret": "你的client_secret" } } ``` ### KubeSphere 配置 OIDC 在 KubeSphere Web 控制台: - **平台管理 → 访问控制 → 企业设置 → 第三方登录** - 填入 Authentik 的 OIDC 信息 --- ## 维护 ```bash # 更新 Authentik helm repo update && helm upgrade authentik authentik/authentik -n auth -f auth-helm-values.yaml # 卸载 helm uninstall authentik -n auth && kubectl delete ns auth ```