Skip to content

Commit ca7e053

Browse files
authored
Merge pull request #915 from negz/arr-back
[v2] Move manual RBAC documentation to compositions page
2 parents b0585a0 + 80f9dbd commit ca7e053

File tree

3 files changed

+74
-29
lines changed

3 files changed

+74
-29
lines changed

content/v2.0-preview/composition/compositions.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,64 @@ spec:
269269
# Removed for brevity
270270
```
271271

272+
### Grant access to composed resources
273+
274+
Crossplane uses its [service account](https://kubernetes.io/docs/concepts/security/service-accounts/)
275+
to create the composed resources that a function pipeline returns.
276+
277+
Crossplane's service account has access to create, update, and delete any
278+
resource installed by a [provider]({{<ref "../packages/providers">}}), or
279+
defined by an XRD. This includes all
280+
[MRs]({{<ref "../managed-resources/managed-resources">}}) and
281+
[XRs]({{<ref "composite-resources">}}). It also has access to some types of
282+
Kubernetes resources that it needs to function - for example it can create
283+
deployments.
284+
285+
You must grant Crossplane access to compose any other kind of resource. You do
286+
this by creating an [RBAC ClusterRole](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
287+
288+
<!-- vale write-good.TooWordy = NO -->
289+
<!-- TooWordy thinks "aggregate" is too wordy, but it's the name of the concept. -->
290+
The ClusterRole must aggregate to Crossplane's primary ClusterRole using
291+
[ClusterRole aggregation](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles).
292+
<!-- vale write-good.TooWordy = YES -->
293+
294+
Here's a ClusterRole that grants Crossplane access to manage
295+
[CloudNativePG](https://cloudnative-pg.io) PostgreSQL clusters.
296+
297+
``` yaml
298+
apiVersion: rbac.authorization.k8s.io/v1
299+
kind: ClusterRole
300+
metadata:
301+
name: cnpg:aggregate-to-crossplane
302+
labels:
303+
rbac.crossplane.io/aggregate-to-crossplane: "true"
304+
rules:
305+
- apiGroups:
306+
- postgresql.cnpg.io
307+
resources:
308+
- clusters
309+
verbs:
310+
- "*"
311+
```
312+
313+
<!-- vale write-good.TooWordy = NO -->
314+
<!-- TooWordy thinks "aggregate" is too wordy, but it's the name of the concept. -->
315+
The `rbac.crossplane.io/aggregate-to-crossplane: "true"` label is critical. It
316+
configures the role to aggregate to Crossplane's primary cluster role.
317+
<!-- vale write-good.TooWordy = YES -->
318+
319+
{{<hint "note" >}}
320+
The [RBAC manager]({{<ref "../guides/pods#rbac-manager-pod">}}) automatically
321+
grants Crossplane access to MRs and XRs. The RBAC manager uses
322+
[escalate access](https://kubernetes.io/docs/concepts/security/rbac-good-practices/#escalate-verb)
323+
to grant Crossplane access that the RBAC manager doesn't have.
324+
325+
The RBAC manager is an optional Crossplane component that's enabled by default.
326+
**If you disable the RBAC manager, you must manually grant Crossplane access to
327+
_any_ kind of resource you wish to compose - including XRs and MRs.**
328+
{{< /hint >}}
329+
272330
## Test a composition
273331
274332
You can preview the output of any composition using the Crossplane CLI. You
@@ -545,8 +603,8 @@ which composed resources it should create or update.
545603

546604
If the function needs __extra resources__ to determine the desired state it can
547605
request any cluster-scoped resource Crossplane already has access to, either by
548-
by name or labels through the returned RunFunctionResponse. Crossplane then
549-
calls the function again including the requested __extra resources__ and the
606+
name or labels through the returned RunFunctionResponse. Crossplane then calls
607+
the function again including the requested __extra resources__ and the
550608
__context__ returned by the Function itself alongside the same __input__,
551609
__observed__ and __desired state__ of the previous RunFunctionRequest. Functions
552610
can iteratively request __extra resources__ if needed, but to avoid endlessly

content/v2.0-preview/get-started/get-started-with-composition.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,13 @@ Functions can change the results of earlier functions in the pipeline.
660660
Crossplane uses the result returned by the last function.
661661
{{</hint>}}
662662

663+
{{<hint "tip">}}
664+
If you edit this composition to include a different kind of resource you might
665+
need to grant Crossplane access to compose it. Read
666+
[the composition documentation]({{<ref "../composition/compositions#grant-access-to-composed-resources">}})
667+
to learn how to grant Crossplane access.
668+
{{</hint>}}
669+
663670
## Use the custom resource
664671

665672
Crossplane now understands `App` custom resources.

content/v2.0-preview/whats-new/_index.md

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -207,32 +207,12 @@ compose-pg@{animate: true}
207207
This opens composition to exciting new use cases - for example building custom
208208
app models with Crossplane.
209209

210-
### Beware Crossplane's default access
211-
212-
Crossplane by default can only access a limited set of kubernetes resources beyond what gets configured by any providers.
213-
214-
To grant access to additional resource resource types, create additional `ClusterRoles` and include them in the default Crossplane `ClusterRole` through [aggregation](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles). Crossplane's default ClusterRole aggregates using a selector for the label `rbac.crossplane.io/aggregate-to-crossplane: "true"`
215-
216-
If you don't include this you may experience RBAC issues composing third party custom resources.
217-
218-
Here is an example of allowing Crossplane handle the lifecycle of CloudNativePG PostgreSQL `Cluster`.
219-
220-
``` yaml
221-
apiVersion: rbac.authorization.k8s.io/v1
222-
kind: ClusterRole
223-
metadata:
224-
name: cnpg:aggregate-to-crossplane
225-
labels:
226-
app: crossplane
227-
rbac.crossplane.io/aggregate-to-crossplane: "true"
228-
rules:
229-
- apiGroups:
230-
- postgresql.cnpg.io
231-
resources:
232-
- clusters
233-
verbs:
234-
- "*"
235-
```
210+
{{<hint "tip">}}
211+
You must grant Crossplane access to compose resources that aren't Crossplane
212+
resources like MRs or XRs. Read
213+
[the composition documentation]({{<ref "../composition/compositions#grant-access-to-composed-resources">}})
214+
to learn how to grant Crossplane access.
215+
{{</hint>}}
236216

237217
## Backward compatibility
238218

@@ -263,4 +243,4 @@ upgrade from v1.x to Crossplane v2 without breaking changes.
263243
Existing Compositions will require minor updates to work with Crossplane v2
264244
style XRs. A migration guide will be available closer to the final release of
265245
Crossplane v2.
266-
<!-- vale gitlab.FutureTense = YES -->
246+
<!-- vale gitlab.FutureTense = YES -->

0 commit comments

Comments
 (0)