为 sandbox 接入 OpenBao External Secrets
This commit is contained in:
@@ -51,7 +51,7 @@ few things Terraform must not own.**
|
||||
| secrets engine mounts (`kv`, `pki`, `ssh-client-signer`) | the daemon, Raft, TLS files, systemd |
|
||||
| PKI role, issuing/CRL URLs, cluster paths, **ACME** | `bao operator init` / unseal (manual, PGP-wrapped) |
|
||||
| SSH signing role (`ai-agent`) | **PKI root CA + SSH CA signing key** |
|
||||
| OIDC auth *mount* and *role* | OIDC **client secret** (`auth/oidc/config`) |
|
||||
| OIDC/Kubernetes auth mount、config 与 role | OIDC **client secret** (`auth/oidc/config`) |
|
||||
| all policies | snapshot token + script + systemd timer |
|
||||
| | host-level CA trust distribution (`openbao_ssh_ca_trust`) |
|
||||
|
||||
@@ -92,6 +92,12 @@ then `VAULT_ADDR`/`VAULT_TOKEN`), mirroring how `smtp-relay/terraform` uses
|
||||
native `openbao/openbao` provider is published only to the OpenTofu registry and
|
||||
cannot be resolved by the HashiCorp `terraform` CLI.
|
||||
|
||||
Sandbox 集群使用独立的 `auth/kubernetes-sandbox`。其 API 地址、公开 Kubernetes CA、
|
||||
ESO role 与只读 `kv/k8s/opensandbox-api` policy 全部由 Terraform 管理;CA 位于
|
||||
`terraform/certs/sandbox-kubernetes-ca.crt`。集群重建并轮换 CA 后,先更新该文件并
|
||||
apply,再让 Flux 恢复 ESO reconciliation。该 backend 不保存 reviewer JWT,而是使用
|
||||
ESO 的短期登录 JWT 执行 TokenReview。
|
||||
|
||||
## DNS
|
||||
|
||||
`bao.ad.ddupan.top` is an **internal-only** name — not a public Cloudflare record and
|
||||
|
||||
@@ -59,3 +59,33 @@ resource "vault_kubernetes_auth_backend_role" "external_secrets" {
|
||||
# in a long TTL and every extra hour is a longer-lived credential in memory.
|
||||
token_ttl = 3600
|
||||
}
|
||||
|
||||
# A Kubernetes auth mount can validate identities from only the API server it is
|
||||
# configured against. The sandbox cluster therefore cannot reuse auth/kubernetes,
|
||||
# whose TokenReview endpoint belongs to homelab.
|
||||
resource "vault_auth_backend" "sandbox_kubernetes" {
|
||||
type = "kubernetes"
|
||||
path = "kubernetes-sandbox"
|
||||
}
|
||||
|
||||
resource "vault_kubernetes_auth_backend_config" "sandbox" {
|
||||
backend = vault_auth_backend.sandbox_kubernetes.path
|
||||
kubernetes_host = "https://10.60.0.13:6443"
|
||||
kubernetes_ca_cert = file("${path.module}/certs/sandbox-kubernetes-ca.crt")
|
||||
disable_local_ca_jwt = true
|
||||
|
||||
# Deliberately omit token_reviewer_jwt. OpenBao uses the login JWT for
|
||||
# TokenReview; the sandbox external-secrets ServiceAccount is bound only to
|
||||
# system:auth-delegator and all issued JWTs remain short-lived.
|
||||
}
|
||||
|
||||
resource "vault_kubernetes_auth_backend_role" "sandbox_external_secrets" {
|
||||
backend = vault_auth_backend.sandbox_kubernetes.path
|
||||
role_name = "external-secrets"
|
||||
|
||||
bound_service_account_names = ["external-secrets"]
|
||||
bound_service_account_namespaces = ["external-secrets"]
|
||||
|
||||
token_policies = [vault_policy.sandbox_external_secrets.name]
|
||||
token_ttl = 3600
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIBdjCCAR2gAwIBAgIBADAKBggqhkjOPQQDAjAjMSEwHwYDVQQDDBhrM3Mtc2Vy
|
||||
dmVyLWNhQDE3ODk2NTI4NTcwHhcNMjYwOTE3MTI0NzM3WhcNMzYwOTE0MTI0NzM3
|
||||
WjAjMSEwHwYDVQQDDBhrM3Mtc2VydmVyLWNhQDE3ODk2NTI4NTcwWTATBgcqhkjO
|
||||
PQIBBggqhkjOPQMBBwNCAAR4SbqzTXZnlZdUPz7viN6+dYbB1Maw44Qiepn9r5XG
|
||||
sOzkYkN8t1aG3Ugo8TqQ3xJaKkM89n1Rluj0vbOhiNajo0IwQDAOBgNVHQ8BAf8E
|
||||
BAMCAqQwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyLSGoKAKAJuiniuRdBLG
|
||||
XYaDQC8wCgYIKoZIzj0EAwIDRwAwRAIgFkVzyUZexk/ynnxBEOg+3foJv3WKqAei
|
||||
hTSRjO1gL0UCIFbBKR7BMrJJAgW3DJFeeBM+b+tTg93jNx55qZACbFOL
|
||||
-----END CERTIFICATE-----
|
||||
@@ -35,3 +35,10 @@ resource "vault_policy" "external_secrets" {
|
||||
name = "external-secrets"
|
||||
policy = file("${path.module}/policies/external-secrets.hcl")
|
||||
}
|
||||
|
||||
# The sandbox cluster has its own Kubernetes auth backend and a deliberately
|
||||
# narrower KV view than the homelab ESO instance.
|
||||
resource "vault_policy" "sandbox_external_secrets" {
|
||||
name = "sandbox-external-secrets"
|
||||
policy = file("${path.module}/policies/sandbox-external-secrets.hcl")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Read only the shared OpenSandbox control-plane API key. The same Bao object is
|
||||
# consumed by the server in sandbox and, later, by the scheduler in homelab.
|
||||
path "kv/data/k8s/opensandbox-api" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
|
||||
path "kv/metadata/k8s/opensandbox-api" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
Reference in New Issue
Block a user