From b619f6f681eb8133120e864d1e4a9e5934ddbb58 Mon Sep 17 00:00:00 2001 From: panxiao81 Date: Thu, 17 Sep 2026 17:30:54 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E9=BD=90=20sandbox=20PSAT=20re?= =?UTF-8?q?viewer=20=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clusters/sandbox/README.md | 6 +++--- infrastructure/sandbox-cluster/README.md | 6 ++++-- platform/sandbox-spire/bootstrap/token-reviewer.yaml | 11 +++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/clusters/sandbox/README.md b/clusters/sandbox/README.md index 1f55762..527fb17 100644 --- a/clusters/sandbox/README.md +++ b/clusters/sandbox/README.md @@ -21,9 +21,9 @@ Root bootstrap 已完成。后续按依赖顺序分别引入: 第一阶段监控拆为 `monitoring-operator` 与依赖它的 `monitoring`,防止 VM CR 在 VictoriaMetrics Operator CRD Ready 前进入 reconciliation。 -SPIRE 阶段先由 `spire-bootstrap` 安装 CRD,并声明只允许 `tokenreviews.create` 的 -central Server reviewer。Agent ServiceAccount 留给后续 HelmRelease 创建,避免两个 -声明方争夺同一资源。随后运行 +SPIRE 阶段先由 `spire-bootstrap` 安装 CRD,并声明按上游 k8s_psat Server plugin +要求收窄的 reviewer:它可以调用 TokenReview,并只读查询用于证明的 Pod 与 Node。 +Agent ServiceAccount 留给后续 HelmRelease 创建,避免两个声明方争夺同一资源。随后运行 `infrastructure/sandbox-cluster/ansible/spire-bootstrap.yml`:playbook 从 sandbox 读取 reviewer token,在内存中组成受限 kubeconfig,再通过 stdin reconcile 到 central 集群的 `spire-server/spire-external-kubeconfigs` Secret。凭据不写入仓库、日志或控制机 diff --git a/infrastructure/sandbox-cluster/README.md b/infrastructure/sandbox-cluster/README.md index 3e47614..75111ee 100644 --- a/infrastructure/sandbox-cluster/README.md +++ b/infrastructure/sandbox-cluster/README.md @@ -111,7 +111,8 @@ server manifests 管理;root 使用 homelab CA 访问公开 Gitea 仓库,不 ## SPIRE 跨集群 bootstrap Sandbox 复用 homelab 的 SPIRE Server 与 `ddupan.top` trust domain。Flux 首先安装 -SPIRE CRD,并创建权限仅为 `authentication.k8s.io/tokenreviews.create` 的 reviewer。 +SPIRE CRD,并创建供 k8s_psat 使用的 reviewer。它按上游 Server chart 的权限模型调用 +TokenReview,并以 `get/list` 读取用于证明的 Pod 与 Node;不具有修改 workload 的权限。 在该 Kustomization Ready 后运行: ```bash @@ -124,7 +125,8 @@ Playbook 不把 reviewer token 或生成的 kubeconfig 落盘,而是将目标 `spire-server/spire-external-kubeconfigs` 由 Ansible 单独拥有;Flux 和人工操作不得写入。 第二次运行必须为零变更。 -Secret 的 `sandbox` key 仅供 SPIRE Server 的 external PSAT plugin 执行 TokenReview; +Secret 的 `sandbox` key 仅供 SPIRE Server 的 external PSAT plugin 验证 token 与对应的 +Pod/Node; `sandbox-controller` key 供 external controller-manager 读取 Pod/Node、reconcile SPIFFE CR 及执行 leader election。两者使用不同 ServiceAccount,不得合并权限或互换。 diff --git a/platform/sandbox-spire/bootstrap/token-reviewer.yaml b/platform/sandbox-spire/bootstrap/token-reviewer.yaml index e636f42..9b5d56c 100644 --- a/platform/sandbox-spire/bootstrap/token-reviewer.yaml +++ b/platform/sandbox-spire/bootstrap/token-reviewer.yaml @@ -24,7 +24,18 @@ rules: resources: - tokenreviews verbs: + - get + - list + - watch - create + - apiGroups: + - "" + resources: + - nodes + - pods + verbs: + - get + - list --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding