Skip to content

Commit 8f79356

Browse files
mjudeikisclaude
andcommitted
fix(infrastructure): grant the runtime SA delete on templates + CRDs
The infraprovider e2e suite's first run (serving with the init-minted SA kubeconfig instead of the hub-minted cluster-admin one) exposed a real RBAC gap: the runtime ClusterRole granted no delete verb anywhere, so the retired-template sweep (controller deletes Templates on sight) and the finalize chain's per-template CRD deletion both 403 — the features work only under the cluster-admin hub-minted kubeconfig. Grant delete on templates and customresourcedefinitions; the role is idempotently overwritten on init, so existing deployments pick this up on their next init run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent e90f239 commit 8f79356

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

providers/infrastructure/install/identity.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,15 @@ func ensureClusterRole(ctx context.Context, cs kubernetes.Interface) error {
197197
want := &rbacv1.ClusterRole{
198198
ObjectMeta: metav1.ObjectMeta{Name: RuntimeRoleName},
199199
Rules: []rbacv1.PolicyRule{
200-
// Templates — read + status patch. The Template
201-
// controller patches status on every reconcile pass.
200+
// Templates — read + status patch, plus delete: the
201+
// controller enforces retirement of removed platform
202+
// templates by deleting them on sight
203+
// (controller/template/retired.go). Finalizer add/remove
204+
// (update) comes from the wildcard rule below.
202205
{
203206
APIGroups: []string{"infrastructure.kedge.faros.sh"},
204207
Resources: []string{"templates"},
205-
Verbs: []string{"get", "list", "watch"},
208+
Verbs: []string{"get", "list", "watch", "delete"},
206209
},
207210
{
208211
APIGroups: []string{"infrastructure.kedge.faros.sh"},
@@ -250,13 +253,13 @@ func ensureClusterRole(ctx context.Context, cs kubernetes.Interface) error {
250253
Resources: []string{"cachedresources"},
251254
Verbs: []string{"get", "list", "watch"},
252255
},
253-
// CRD reads so the controller can check Established
254-
// condition without trying to write CRDs (init owns
255-
// CRD writes).
256+
// CRDs: the controller authors the per-template CRD on
257+
// reconcile and deletes it in the finalize chain when a
258+
// Template is removed (deletePerTemplateCRD).
256259
{
257260
APIGroups: []string{"apiextensions.k8s.io"},
258261
Resources: []string{"customresourcedefinitions"},
259-
Verbs: []string{"get", "list", "watch", "create", "update"},
262+
Verbs: []string{"get", "list", "watch", "create", "update", "delete"},
260263
},
261264
},
262265
}

0 commit comments

Comments
 (0)