Commit 04d9226
committed
Fix namespace-scoped RBAC Role name conflicts with kustomize
When using namespace-scoped RBAC markers with different namespaces,
controller-gen would generate multiple Roles with the same name in
different namespaces. This caused kustomize to fail with "namespace
transformation produces ID conflict" when applying a global namespace
transformation, as both Roles would end up in the same namespace with
identical names.
Changes:
- Append namespace to Role name for namespace-scoped Roles
(e.g., "manager-role-infrastructure" for namespace "infrastructure")
- ClusterRoles maintain original name without suffix
- Updated documentation to clarify the naming behavior
- Added test scenario covering the reported issue with different
resource types in different namespaces (apps/deployments in
infrastructure namespace, core/secrets in users namespace)
This ensures uniqueness when kustomize transforms namespaces, preventing
the ID conflict error.1 parent 0d64ab9 commit 04d9226
File tree
4 files changed
+42
-6
lines changed- pkg/rbac
- testdata
4 files changed
+42
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
350 | | - | |
| 353 | + | |
351 | 354 | | |
352 | 355 | | |
353 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
149 | 166 | | |
150 | 167 | | |
151 | 168 | | |
| |||
158 | 175 | | |
159 | 176 | | |
160 | 177 | | |
161 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
162 | 194 | | |
163 | 195 | | |
164 | 196 | | |
| |||
168 | 200 | | |
169 | 201 | | |
170 | 202 | | |
171 | | - | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments