Commit 049f813
✨ (feat): When using Boxcutter feature-gate, use ClusterExtension ServiceAccount for revision operations (#2429)
* (feat): [Boxcutter] Use ClusterExtension ServiceAccount for revision operations
Implement serviceAccount-scoped token-based authentication for
ClusterExtensionRevision controller using annotation-based configuration.
- Add RevisionEngineFactory with CreateRevisionEngine(ctx, rev) interface
- Read ServiceAccount from annotations (no ClusterExtension dependency)
- Token-based auth using TokenInjectingRoundTripper
- ServiceAccount name and namespace in annotations for observability
- TrackingCache uses global client for caching/cleanup
- Comprehensive error path tests
ClusterExtensionRevision can exist independently.
Easy mode impersonation deferred until API is finalized.
Assisted-by: Cursor
* (doc) Add godoc comments to label constants
Adds documentation comments to all label/annotation constants explaining:
- What each constant represents
- Where they are applied (labels vs annotations)
- ServiceAccount constants document their relationship to ClusterExtension spec
Addresses code review feedback for improved maintainability.
* (fix) Add ClusterExtensionRevision permissions to upgrade test RBAC
The upgrade test ServiceAccount needs permissions to manage
ClusterExtensionRevisions when BoxcutterRuntime is enabled.
Without these permissions, the upgraded controller cannot create
or update ClusterExtensionRevision resources, causing the
ClusterExtension to fail reconciliation after upgrade.
* review changes
* (fix): e2e: add bind/escalate verbs for Boxcutter Server-Side Apply
Add `bind` and `escalate` RBAC verbs to e2e test ServiceAccount to support
Boxcutter applier's use of Kubernetes Server-Side Apply (SSA).
Experimental e2e tests fail when Boxcutter uses ServiceAccount-scoped clients
to apply bundle RBAC resources (ClusterRoles and ClusterRoleBindings):
```
clusterrolebindings.rbac.authorization.k8s.io is forbidden:
User "system:serviceaccount:olmv1-e2e:olm-sa" cannot bind ClusterRole:
RBAC: attempting to grant RBAC permissions not currently held
```
- Uses helm.sh/helm/v3 library
- Applies resources with traditional CREATE/UPDATE operations
- Kubernetes RBAC allows ClusterRoleBinding creation when the ServiceAccount
already has all the permissions being granted (permission matching)
- **Works WITHOUT `bind`/`escalate` verbs** ✅
- Uses pkg.package-operator.run/boxcutter machinery
- Applies resources with **Server-Side Apply (SSA)** (`client.Apply`)
- SSA enforces field-level ownership and **stricter RBAC enforcement**
- Kubernetes API server **requires explicit `bind` verb** for ClusterRoleBindings
- Permission matching fallback does NOT work reliably with SSA
- **REQUIRES `bind`/`escalate` verbs** ❌
Validated by running actual tests:
**Test 1: Main branch standard-e2e (Helm, NO bind/escalate)**
```bash
make test-e2e
```
Result: ✅ PASS (21 scenarios passed)
**Test 2: PR branch experimental-e2e (Boxcutter, NO bind/escalate)**
```bash
make test-experimental-e2e
```
Result: ❌ FAIL (cannot bind ClusterRole error)
**Test 3: PR branch experimental-e2e (Boxcutter, WITH bind/escalate)**
Result: ✅ PASS (all tests pass)
Add `bind` and `escalate` verbs to the e2e test RBAC template:
```yaml
- apiGroups: ["rbac.authorization.k8s.io"]
resources: [clusterroles, roles, clusterrolebindings, rolebindings]
verbs: [ update, create, list, watch, get, delete, patch, bind, escalate ]
```
These verbs allow the ServiceAccount to:
- `bind`: Create ClusterRoleBindings that reference roles with permissions
the ServiceAccount doesn't have
- `escalate`: Create ClusterRoles with permissions the ServiceAccount doesn't have
This is the documented requirement in `docs/concepts/permission-model.md` for
extension installers and aligns with Kubernetes RBAC best practices.
1. **Required for SSA**: Server-Side Apply has stricter RBAC enforcement
2. **Documented requirement**: OLMv1 docs specify bind/escalate as proper approach
3. **Industry best practice**: Operator installers should have these verbs
4. **Supports all operators**: Not just test-operator with matching permissions
5. **Maintains SSA benefits**: Field ownership, conflict resolution, GitOps support
- Kubernetes RBAC: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#privilege-escalation-prevention-and-bootstrapping
- OLMv1 Permission Model: docs/concepts/permission-model.md
- Boxcutter machinery: pkg.package-operator.run/boxcutter/machinery (uses client.Apply)
- Testing evidence: FINAL_TESTED_ANSWER.md, SERVER_SIDE_APPLY_ANSWER.md
Tested-by: Actual e2e test runs comparing Helm vs Boxcutter behavior
Signed-off-by: Camila <camil@example.com>
* Split rbac phase into two
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
---------
Signed-off-by: Camila <camil@example.com>
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
Co-authored-by: Per Goncalves da Silva <pegoncal@redhat.com>1 parent 1fa4169 commit 049f813
10 files changed
Lines changed: 527 additions & 72 deletions
File tree
- cmd/operator-controller
- hack/test
- internal/operator-controller
- applier
- controllers
- labels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | | - | |
48 | | - | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
| |||
653 | 650 | | |
654 | 651 | | |
655 | 652 | | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
656 | 672 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
671 | 676 | | |
672 | 677 | | |
673 | 678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
125 | 138 | | |
126 | 139 | | |
127 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
189 | 195 | | |
190 | 196 | | |
191 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
| |||
291 | 305 | | |
292 | 306 | | |
293 | 307 | | |
294 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
295 | 314 | | |
296 | 315 | | |
297 | 316 | | |
| |||
319 | 338 | | |
320 | 339 | | |
321 | 340 | | |
322 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
323 | 347 | | |
324 | 348 | | |
325 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
90 | 114 | | |
91 | 115 | | |
92 | 116 | | |
| |||
150 | 174 | | |
151 | 175 | | |
152 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
153 | 206 | | |
154 | 207 | | |
155 | 208 | | |
| |||
Lines changed: 17 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 58 | | |
64 | 59 | | |
65 | 60 | | |
| |||
139 | 134 | | |
140 | 135 | | |
141 | 136 | | |
142 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
256 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
257 | 264 | | |
258 | 265 | | |
259 | 266 | | |
| |||
0 commit comments