1
1
---
2
2
title : Compositions
3
3
weight : 30
4
- aliases :
4
+ aliases :
5
5
- composition
6
6
- composition-functions
7
7
- /knowledge-base/guides/composition-functions
8
8
description : " Compositions are a template for creating Crossplane resources"
9
9
---
10
10
11
11
Compositions are a template for creating multiple managed resources as a single
12
- object.
12
+ object.
13
13
14
14
A Composition _ composes_ individual managed resources together into a larger,
15
15
reusable, solution.
16
16
17
17
An example Composition may combine a virtual machine, storage resources and
18
18
networking policies. A Composition template links all these individual
19
- resources together.
19
+ resources together.
20
20
21
21
Here's an example Composition. When you create an
22
22
{{<hover label =" intro " line =" 8 " >}}AcmeBucket{{</hover >}} composite resource
@@ -57,12 +57,12 @@ Crossplane has four core components that users commonly mix up:
57
57
58
58
* Compositions - This page. A template to define how to create resources.
59
59
* [Composite Resource Definition]({{<ref "./composite-resource-definitions">}})
60
- (` XRD`) - A custom API specification.
60
+ (` XRD`) - A custom API specification.
61
61
* [Composite Resource]({{<ref "./composite-resources">}}) (`XR`) - Created by
62
62
using the custom API defined in a Composite Resource Definition. XRs use the
63
- Composition template to create new managed resources.
63
+ Composition template to create new managed resources.
64
64
* [Claims]({{<ref "./claims" >}}) (`XRC`) - Like a Composite Resource, but
65
- with namespace scoping.
65
+ with namespace scoping.
66
66
{{</expand >}}
67
67
68
68
# # Create a Composition
@@ -83,8 +83,8 @@ resource (XR).
83
83
{{<hint "tip" >}}
84
84
The Crossplane community has built lots of functions that let you template
85
85
Crossplane resources using
86
- [CUE](https://github.com/crossplane-contrib/function-cue),
87
- [KCL](https://github.com/crossplane-contrib/function-kcl),
86
+ [CUE](https://github.com/crossplane-contrib/function-cue),
87
+ [KCL](https://github.com/crossplane-contrib/function-kcl),
88
88
Helm-like
89
89
[Go templates](https://github.com/crossplane-contrib/function-go-templating) or
90
90
legacy Crossplane
@@ -111,7 +111,7 @@ but the feature is no longer maintained. Crossplane doesn't accept new
111
111
112
112
See the [CLI documentation]({{<ref "../cli/command-reference#beta-convert">}})
113
113
to learn how to use the `crossplane beta convert` command to convert a legacy
114
- ` Resources` Composition to the `Pipeline` mode.
114
+ ` Resources` Composition to the `Pipeline` mode.
115
115
{{< /hint >}}
116
116
117
117
@@ -134,7 +134,7 @@ kind: Function
134
134
metadata:
135
135
name: function-patch-and-transform
136
136
spec:
137
- package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.1.4
137
+ package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2
138
138
` ` `
139
139
140
140
{{< hint "tip" >}}
@@ -155,7 +155,7 @@ During the install a Function reports `INSTALLED` as `True` and `HEALTHY` as
155
155
` ` ` shell {copy-lines="1"}
156
156
kubectl get functions
157
157
NAME INSTALLED HEALTHY PACKAGE AGE
158
- function-patch-and-transform True Unknown xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.1.4 10s
158
+ function-patch-and-transform True Unknown xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2 10s
159
159
` ` `
160
160
161
161
After the Function install completes and it's ready for use the `HEALTHY` status
@@ -174,36 +174,36 @@ composite resource owns.
174
174
Crossplane knows what Function to call when a composite resource changes by
175
175
looking at the Composition the composite resource uses.
176
176
177
- To use composition functions set the Composition
177
+ To use composition functions set the Composition
178
178
{{<hover label="single" line="6">}}mode{{</hover>}} to
179
179
{{<hover label="single" line="6">}}Pipeline{{</hover>}}.
180
180
181
- Define a {{<hover label="single" line="7">}}pipeline{{</hover>}} of
182
- {{<hover label="single" line="8">}}steps{{</hover>}}. Each
183
- {{<hover label="single" line="8">}}step{{</hover>}} calls a Function.
181
+ Define a {{<hover label="single" line="7">}}pipeline{{</hover>}} of
182
+ {{<hover label="single" line="8">}}steps{{</hover>}}. Each
183
+ {{<hover label="single" line="8">}}step{{</hover>}} calls a Function.
184
184
185
- Each {{<hover label="single" line="8">}}step{{</hover>}} uses a
185
+ Each {{<hover label="single" line="8">}}step{{</hover>}} uses a
186
186
{{<hover label="single" line="9">}}functionRef{{</hover>}} to reference the
187
- {{<hover label="single" line="10">}}name{{</hover>}} of the Function to call.
187
+ {{<hover label="single" line="10">}}name{{</hover>}} of the Function to call.
188
188
189
189
{{<hint "important" >}}
190
- Compositions using {{<hover label="single" line="6">}}mode : Pipeline{{</hover>}}
191
- can't specify resource templates with a `resources` field.
190
+ Compositions using {{<hover label="single" line="6">}}mode : Pipeline{{</hover>}}
191
+ can't specify resource templates with a `resources` field.
192
192
193
193
Use function "Patch and Transform" to create resource templates.
194
194
{{< /hint >}}
195
195
196
196
197
- Some Functions also allow you to specify an
198
- {{<hover label="single" line="11">}}input{{</hover>}}.
197
+ Some Functions also allow you to specify an
198
+ {{<hover label="single" line="11">}}input{{</hover>}}.
199
199
The function defines the
200
200
{{<hover label="single" line="13">}}kind{{</hover>}} of input.
201
201
202
202
This example uses
203
203
[Function Patch and Transform]({{<ref "../guides/function-patch-and-transform">}}).
204
204
Function Patch and Transform implements Crossplane resource
205
- templates.
206
- The input kind is {{<hover label="single" line="13">}}Resources{{</hover>}},
205
+ templates.
206
+ The input kind is {{<hover label="single" line="13">}}Resources{{</hover>}},
207
207
and it accepts {{<hover label="single" line="14">}}resources{{</hover>}} as input.
208
208
209
209
` ` ` yaml {label="single",copy-lines="none"}
@@ -239,7 +239,7 @@ calls them all. It calls them in the order they appear in the pipeline.
239
239
Crossplane passes each Function in the pipeline the result of the previous
240
240
Function. This enables powerful combinations of Functions. In this example,
241
241
Crossplane calls {{<hover label="double" line="10">}}function-cue{{</hover>}} to
242
- create an S3 bucket. Crossplane then passes the bucket to
242
+ create an S3 bucket. Crossplane then passes the bucket to
243
243
{{<hover label="double" line="23">}}function-auto-ready{{</hover>}}, which marks the
244
244
composite resource as ready when the bucket becomes ready.
245
245
@@ -272,22 +272,22 @@ spec:
272
272
273
273
# ## Enable composite resources
274
274
275
- A Composition is only a template defining how to create managed
275
+ A Composition is only a template defining how to create managed
276
276
resources. A Composition limits which Composite Resources can use this
277
- template.
277
+ template.
278
278
279
- A Composition's {{<hover label="typeref" line="6">}}compositeTypeRef{{</hover>}}
280
- defines which Composite Resource type can use this Composition.
279
+ A Composition's {{<hover label="typeref" line="6">}}compositeTypeRef{{</hover>}}
280
+ defines which Composite Resource type can use this Composition.
281
281
282
282
{{<hint "note" >}}
283
- Read more about Composite Resources in the
284
- [Composite Resources page]({{<ref "./composite-resources" >}}).
283
+ Read more about Composite Resources in the
284
+ [Composite Resources page]({{<ref "./composite-resources" >}}).
285
285
{{< /hint >}}
286
286
287
- Inside a Composition's
287
+ Inside a Composition's
288
288
{{<hover label="typeref" line="5">}}spec{{</hover>}}
289
- define the Composite Resource
290
- {{<hover label="typeref" line="7">}}apiVersion{{</hover>}} and
289
+ define the Composite Resource
290
+ {{<hover label="typeref" line="7">}}apiVersion{{</hover>}} and
291
291
{{<hover label="typeref" line="8">}}kind{{</hover>}}
292
292
that the Composition allows to use this template.
293
293
@@ -306,26 +306,26 @@ spec:
306
306
# ## Store connection details
307
307
308
308
Some managed resources generate unique details like usernames, passwords, IP
309
- addresses, ports or other connection details.
309
+ addresses, ports or other connection details.
310
310
311
311
When resources inside a Composition create connection details Crossplane creates
312
312
a Kubernetes secret object for each managed resource generating connection
313
- details.
313
+ details.
314
314
315
315
{{<hint "note">}}
316
- This section discusses creating Kubernetes secrets.
316
+ This section discusses creating Kubernetes secrets.
317
317
Crossplane also supports using external secret stores like
318
- [HashiCorp Vault](https://www.vaultproject.io/).
318
+ [HashiCorp Vault](https://www.vaultproject.io/).
319
319
320
320
Read the [external secrets store guide]({{<ref "../guides/vault-as-secret-store">}}) for more information on using Crossplane
321
- with an external secret store.
321
+ with an external secret store.
322
322
{{</hint >}}
323
323
324
324
# ### Composite resource combined secret
325
325
326
326
Crossplane can combine all the secrets generated by the resources inside a
327
327
Composition into a single Kubernetes secret and optionally copy the secret
328
- object for claims.
328
+ object for claims.
329
329
330
330
Set the value of `writeConnectionSecretsToNamespace` to the namespace where
331
331
Crossplane should store the combined secret object.
@@ -344,7 +344,7 @@ spec:
344
344
345
345
Inside the `spec` of each resource producing connection details, define the
346
346
` writeConnectionSecretToRef` , with a `namespace` and `name` of the secret object
347
- for the resource.
347
+ for the resource.
348
348
349
349
If a `writeConnectionSecretToRef` isn't defined, Crossplane doesn't write any
350
350
keys to the secret.
@@ -389,10 +389,10 @@ Remember to create a unique name for each secret.
389
389
390
390
# ### External secret stores
391
391
392
- Crossplane
393
- [External Secret Stores]({{<ref "../guides/vault-as-secret-store" >}})
392
+ Crossplane
393
+ [External Secret Stores]({{<ref "../guides/vault-as-secret-store" >}})
394
394
write secrets and connection details to external secret stores like HashiCorp
395
- Vault.
395
+ Vault.
396
396
397
397
{{<hint "important" >}}
398
398
External Secret Stores are an alpha feature.
@@ -403,7 +403,7 @@ Stores by default.
403
403
404
404
Use `publishConnectionDetailsWithStoreConfigRef` in place of
405
405
` writeConnectionSecretsToNamespace` to define the `StoreConfig` to save
406
- connection details to.
406
+ connection details to.
407
407
408
408
For example, using a `StoreConfig` with the `name` "vault," use
409
409
` publishConnectionDetailsWithStoreConfigRef.name` matching the
@@ -421,13 +421,13 @@ apiVersion: apiextensions.crossplane.io/v1
421
421
kind: Composition
422
422
# Removed for Brevity
423
423
spec:
424
- publishConnectionDetailsWithStoreConfigRef:
424
+ publishConnectionDetailsWithStoreConfigRef:
425
425
name: vault
426
426
# Removed for brevity
427
427
` ` `
428
428
429
429
For more details read the
430
- [External Secret Stores]({{<ref "../guides/vault-as-secret-store" >}})
430
+ [External Secret Stores]({{<ref "../guides/vault-as-secret-store" >}})
431
431
integration guide.
432
432
433
433
# # Test a composition
@@ -451,7 +451,7 @@ Running `crossplane render` requires [Docker](https://www.docker.com).
451
451
{{< /hint >}}
452
452
453
453
Provide a composite resource, composition and composition functions to render
454
- the output locally.
454
+ the output locally.
455
455
456
456
` ` ` shell
457
457
crossplane render xr.yaml composition.yaml functions.yaml
@@ -545,7 +545,7 @@ kind: Function
545
545
metadata:
546
546
name: function-patch-and-transform
547
547
spec:
548
- package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.1.4
548
+ package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2
549
549
` ` `
550
550
{{</expand>}}
551
551
@@ -576,7 +576,7 @@ metadata:
576
576
annotations:
577
577
render.crossplane.io/runtime: Development
578
578
spec:
579
- package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.1.4
579
+ package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2
580
580
` ` `
581
581
582
582
{{<hint "tip">}}
@@ -616,18 +616,18 @@ xsqlinstances.aws.platformref.upbound.io XSQLInstance aws.platformref.upboun
616
616
` ` `
617
617
618
618
The `XR-KIND` lists the Composite Resource `kind` that's allowed to use the
619
- Composition template.
619
+ Composition template.
620
620
The `XR-APIVERSION` lists the Composite Resource API versions allowed to use the
621
- Composition template.
621
+ Composition template.
622
622
623
623
{{<hint "note" >}}
624
624
The output of `kubectl get composition` is different than `kubectl get
625
- composite`.
625
+ composite`.
626
626
627
627
` kubectl get composition` lists all available Compositions.
628
628
629
629
` kubectl get composite` lists all created Composite Resources and their related
630
- Composition.
630
+ Composition.
631
631
{{< /hint >}}
632
632
633
633
# # Composition validation
@@ -657,18 +657,18 @@ If using `mode: Pipeline` (Composition Functions):
657
657
# ## Composition schema aware validation
658
658
659
659
Crossplane also performs schema aware
660
- validation of Compositions. Schema validation checks that `patches`,
661
- ` readinessChecks` and `connectionDetails` are valid according to the resource
662
- schemas. For example, checking that the source and destination fields of a patch
660
+ validation of Compositions. Schema validation checks that `patches`,
661
+ ` readinessChecks` and `connectionDetails` are valid according to the resource
662
+ schemas. For example, checking that the source and destination fields of a patch
663
663
are valid according to the source and destination resource schema.
664
664
665
665
{{<hint "note" >}}
666
666
Composition schema aware validation is a beta feature. Crossplane enables
667
- beta features by default.
667
+ beta features by default.
668
668
669
669
Disable schema aware validation by setting the
670
670
` --enable-composition-webhook-schema-validation=false` flag on the Crossplane
671
- pod.
671
+ pod.
672
672
673
673
The [Crossplane Pods]({{<ref "./pods#edit-the-deployment">}}) page has
674
674
more information on enabling Crossplane flags.
@@ -698,12 +698,12 @@ The following modes are available:
698
698
{{< /table >}}
699
699
700
700
Change the validation mode for a Composition with the
701
- {{<hover label="mode" line="5">}}crossplane.io/composition-schema-aware-validation-mode{{</hover>}}
701
+ {{<hover label="mode" line="5">}}crossplane.io/composition-schema-aware-validation-mode{{</hover>}}
702
702
annotation.
703
703
704
704
If not specified, the default mode is `warn`.
705
705
706
- For example, to enable `loose` mode checking set the annotation value to
706
+ For example, to enable `loose` mode checking set the annotation value to
707
707
{{<hover label="mode" line="5">}}loose{{</hover>}}.
708
708
709
709
` ` ` yaml {copy-lines="none",label="mode"}
@@ -827,7 +827,7 @@ Crossplane errors if stability isn't reached after 5 iterations.
827
827
A _composed_ resource is a resource created by a composite resource. Composed
828
828
resources are usually Crossplane managed resources (MRs), but they can be any
829
829
kind of Crossplane resource. For example a composite resource could also create
830
- a ProviderConfig, or another kind of composite resource.
830
+ a ProviderConfig, or another kind of composite resource.
831
831
<!-- vale write-good.Weasel = YES -->
832
832
{{</hint>}}
833
833
@@ -986,4 +986,4 @@ context.
986
986
Crossplane can write context too. If you enable the alpha
987
987
[composition environment]({{<ref "environment-configs">}}) feature Crossplane
988
988
writes the environment to the top-level context field
989
- ` apiextensions.crossplane.io/environment` .
989
+ ` apiextensions.crossplane.io/environment` .
0 commit comments