@@ -5,36 +5,31 @@ description: "Composite Resource Definitions or XRDs define custom API schemas"
5
5
---
6
6
7
7
Composite resource definitions (` XRDs ` ) define the schema for a custom API.
8
- Users create composite resources (` XRs ` ) and Claims ( ` XCs ` ) using the API
9
- schema defined by an ` XRD ` .
8
+ Users create composite resources (` XRs ` ) using the API schema defined by an
9
+ ` XRD ` .
10
10
11
11
12
12
{{< hint "note" >}}
13
13
14
14
Read the [ composite resources] ({{<ref "./composite-resources">}}) page for more
15
15
information about composite resources.
16
-
17
- Read the [ Claims] ({{<ref "./claims">}}) page for more
18
- information about Claims.
19
16
{{</hint >}}
20
17
21
18
22
- {{<expand "Confused about Compositions, XRDs, XRs and Claims ?" >}}
19
+ {{<expand "Confused about Compositions, XRDs, and XRs ?" >}}
23
20
Crossplane has four core components that users commonly mix up:
24
21
25
22
* [ Compositions] ({{<ref "./compositions" >}}) - A template to define how to create resources.
26
23
* Composite Resource Definition (` XRD ` ) - This page. A custom API specification.
27
24
* [ Composite Resource] ({{<ref "./composite-resources">}}) (` XR ` ) - Created by
28
25
using the custom API defined in a Composite Resource Definition. XRs use the
29
26
Composition template to create new managed resources.
30
- * [ Claims] ({{<ref "./claims" >}}) (` XRC ` ) - Like a Composite Resource, but
31
- with namespace scoping.
32
27
{{</expand >}}
33
28
34
29
Crossplane XRDs are like
35
30
[ Kubernetes custom resource definitions] ( https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/ ) .
36
- XRDs require fewer fields and add options related to Crossplane, like Claims and
37
- connection secrets.
31
+ XRDs require fewer fields and add options related to Crossplane, like connection
32
+ secrets.
38
33
39
34
## Creating a CompositeResourceDefinition
40
35
@@ -44,7 +39,6 @@ Creating a CompositeResourceDefinition consists of:
44
39
* [ Defining a custom API schema and version] ( #xrd-versions ) .
45
40
46
41
Optionally, CompositeResourceDefinitions also support:
47
- * [ Offering a Claim] ( #enable-claims ) .
48
42
* [ Defining connection secrets] ( #manage-connection-secrets ) .
49
43
* [ Setting composite resource defaults] ( #set-composite-resource-defaults ) .
50
44
@@ -82,7 +76,7 @@ creates a custom resource definition
82
76
``` shell {label="kubeapi",copy-lines="3"}
83
77
kubectl api-resources
84
78
NAME SHORTNAMES APIVERSION NAMESPACED KIND
85
- xmydatabases.example.org v1alpha1 false xmydatabases
79
+ xmydatabases.example.org v1alpha1 true xmydatabases
86
80
# Removed for brevity
87
81
```
88
82
@@ -106,12 +100,6 @@ Many XRDs may use the same `group` to create a logical collection of APIs.
106
100
<!-- vale write-good.Weasel = YES -->
107
101
For example a ` database ` group may have a ` relational ` and ` nosql ` kinds.
108
102
109
- {{<hint "tip" >}}
110
- Group names are cluster scoped. Choose group names that don't conflict with
111
- Providers.
112
- Avoid Provider names in the group.
113
- {{< /hint >}}
114
-
115
103
### XRD names
116
104
117
105
The ` names ` field defines how to refer to this specific XRD.
@@ -356,12 +344,9 @@ documentation has more examples.
356
344
##### Crossplane reserved fields
357
345
358
346
Crossplane doesn't allow the following fields in a schema:
359
- * ` spec.resourceRef`
360
- * `spec.resourceRefs`
361
- * `spec.claimRef`
362
- * `spec.writeConnectionSecretToRef`
347
+ * Any field under the object ` spec.crossplane`
348
+ * Any field under the object `status.crossplane`
363
349
* `status.conditions`
364
- * `status.connectionDetails`
365
350
366
351
Crossplane ignores any fields matching the reserved fields.
367
352
@@ -495,84 +480,23 @@ spec:
495
480
Changing or expanding the XRD schema requires restarting the [Crossplane pod]({{<ref "./pods#crossplane-pod">}}) to take effect.
496
481
{{< /hint >}}
497
482
498
- # ## Enable Claims
499
-
500
- Optionally, XRDs can allow Claims to use the XRD API.
501
-
502
- {{<hint "note" >}}
503
-
504
- Read the [Claims]({{<ref "./claims">}}) page for more
505
- information about Claims.
506
- {{</hint >}}
507
-
508
- XRDs offer Claims with a
509
- {{<hover label="claim" line="10">}}claimNames{{</hover >}} object.
510
-
511
- The {{<hover label="claim" line="10">}}claimNames{{</hover >}} defines a
512
- {{<hover label="claim" line="11">}}kind{{</hover >}} and
513
- {{<hover label="claim" line="12">}}plural{{</hover >}} like the XRD
514
- {{<hover label="claim" line="7">}}names{{</hover >}} object.
515
- Also like XRD
516
- {{<hover label="claim" line="7">}}names{{</hover >}}, use UpperCamelCase
517
- for the
518
- {{<hover label="claim" line="11">}}kind{{</hover >}} and lowercase for the
519
- {{<hover label="claim" line="12">}}plural{{</hover >}}.
520
-
521
- The Claim
522
- {{<hover label="claim" line="11">}}kind{{</hover >}} and
523
- {{<hover label="claim" line="12">}}plural{{</hover >}} must be unique. They
524
- can't match any other Claim or other XRD
525
- {{<hover label="claim" line="8">}}kind{{</hover >}}.
526
-
527
- {{<hint "tip" >}}
528
- Common Crossplane convention is to use
529
- {{<hover label="claim" line="10">}}claimNames{{</hover >}} that match the XRD
530
- {{<hover label="claim" line="7">}}names{{</hover >}}, but without the beginning
531
- " x."
532
- {{</hint >}}
533
-
534
- ` ` ` yaml {label="claim",copy-lines="none"}
535
- apiVersion: apiextensions.crossplane.io/v1
536
- kind: CompositeResourceDefinition
537
- metadata:
538
- name: xdatabases.custom-api.example.org
539
- spec:
540
- group: custom-api.example.org
541
- names:
542
- kind: xDatabase
543
- plural: xdatabases
544
- claimNames:
545
- kind: Database
546
- plural: databases
547
- versions:
548
- # Removed for brevity
549
- ` ` `
550
-
551
- {{<hint "important" >}}
552
- You can't change the
553
- {{<hover label="claim" line="10">}}claimNames{{</hover >}}
554
- after they're defined. You must delete and
555
- recreate the XRD to change the
556
- {{<hover label="claim" line="10">}}claimNames{{</hover >}}.
557
- {{</hint >}}
558
-
559
483
# ## Manage connection secrets
560
484
561
485
When a composite resource creates managed resources, Crossplane provides any
562
486
[connection secrets]({{<ref "./managed-resources#writeconnectionsecrettoref">}})
563
- to the composite resource or Claim . This requires the creators of composite
564
- resources and Claims to know the secrets provided by a managed resource.
565
- In other cases, Crossplane administrators may not want to expose some or all the
566
- generated connection secrets.
487
+ to the composite resource. This requires the creators of composite resources to
488
+ know the secrets provided by a managed resource. In other cases, Crossplane
489
+ administrators may not want to expose some or all the generated connection
490
+ secrets.
567
491
568
492
XRDs can define a list of
569
493
{{<hover label="key" line="10">}}connectionSecretKeys{{</hover>}}
570
- to limit what's provided to a composite resource or Claim .
494
+ to limit what's provided to a composite resource.
571
495
572
496
Crossplane only provides the keys listed in the
573
497
{{<hover label="key" line="10">}}connectionSecretKeys{{</hover>}}
574
- to the composite resource or Claim using this XRD. Any other connection
575
- secrets aren't passed to the composite resource or Claim .
498
+ to the composite resource using this XRD. Any other connection secrets aren't
499
+ passed to the composite resource.
576
500
577
501
{{<hint "important" >}}
578
502
The keys listed in the
@@ -591,7 +515,7 @@ For example, an XRD passes the keys
591
515
{{<hover label="key" line="12">}}password{{</hover>}} and
592
516
{{<hover label="key" line="13">}}address{{</hover>}}.
593
517
594
- Composite resources or Claims save these in the secret defined by their
518
+ Composite resources save these in the secret defined by their
595
519
` writeConnectionSecretToRef` field.
596
520
597
521
` ` ` yaml {label="key",copy-lines="none"}
@@ -621,61 +545,14 @@ For more information on connection secrets read the
621
545
[Connection Secrets knowledge base article]({{<ref "connection-details">}}).
622
546
623
547
# ## Set composite resource defaults
624
- XRDs can set default parameters for composite resources and Claims.
625
-
626
- <!-- vale off -->
627
- # ### defaultCompositeDeletePolicy
628
- <!-- vale on -->
629
- The `defaultCompositeDeletePolicy` defines the default value for the claim's
630
- ` compositeDeletePolicy` property if the user doesn't specify a value when creating
631
- the claim. The claim controller uses the `compositeDeletePolicy` property to specify
632
- the propagation policy when deleting the associated composite.
633
- The `compositeDeletePolicy` doesn't apply to standalone composites that don't have
634
- associated claims.
635
-
636
- Using a `defaultCompositeDeletePolicy : Background` policy causes the CRD for the claim to have
637
- the default value `Background` for the `compositeDeletePolicy` property.
638
- When a deleted claim has the `compositeDeletePolicy` property set to `Background`
639
- the claim controller deletes the composite resource using the propagation policy `background`
640
- and returns, relying on Kubernetes to delete the remaining child objects,
641
- like managed resources, nested composites and secrets.
642
-
643
- Using `defaultCompositeDeletePolicy : Foreground` causes the CRD for the claim to have
644
- the `compositeDeletePolicy` default value `Foreground`. When a deleted claim has the
645
- ` compositeDeletePolicy` property set to `Foreground` the controller
646
- deletes the associated composite using the propagation policy `foreground`. This causes Kubernetes
647
- to use foreground cascading deletion which deletes all child resources before deleting the
648
- parent resource. The claim controller waits for the composite deletion to finish before returning.
649
-
650
- When creating a claim the user can override the `defaultCompositeDeletePolicy` by including
651
- the `spec.compositeDeletePolicy` property with either the `Background` or `Foreground` value.
652
-
653
- The default value is `defaultCompositeDeletePolicy : Background`.
654
-
655
- Set
656
- {{<hover label="delete" line="6">}}defaultCompositeDeletePolicy: Foreground{{</hover>}}
657
- to change the XRD deletion policy.
658
-
659
- ` ` ` yaml {label="delete",copy-lines="none"}
660
- apiVersion: apiextensions.crossplane.io/v1
661
- kind: CompositeResourceDefinition
662
- metadata:
663
- name: xdatabases.custom-api.example.org
664
- spec:
665
- defaultCompositeDeletePolicy: Foreground
666
- group: custom-api.example.org
667
- names:
668
- # Removed for brevity
669
- versions:
670
- # Removed for brevity
671
- ` ` `
548
+ XRDs can set default parameters for composite resources.
672
549
673
550
<!-- vale off -->
674
551
# ### defaultCompositionRef
675
552
<!-- vale on -->
676
553
It's possible for multiple [Compositions]({{<ref "./compositions">}}) to
677
554
reference the same XRD. If more than one Composition references the same XRD,
678
- the composite resource or Claim must select which Composition to use.
555
+ the composite resource must select which Composition to use.
679
556
680
557
An XRD can define the default Composition to use with the
681
558
` defaultCompositionRef` value.
@@ -704,16 +581,16 @@ spec:
704
581
<!-- vale on -->
705
582
706
583
Changes to a Composition generate a new Composition revision. By default all
707
- composite resources and Claims use the updated Composition revision.
584
+ composite resources use the updated Composition revision.
708
585
709
586
Set the XRD `defaultCompositionUpdatePolicy` to `Manual` to prevent composite
710
- resources and Claims from automatically using the new revision.
587
+ resources from automatically using the new revision.
711
588
712
589
The default value is `defaultCompositionUpdatePolicy : Automatic`.
713
590
714
591
Set {{<hover label="compRev" line="6">}}defaultCompositionUpdatePolicy : Manual{{</hover>}}
715
- to set the default Composition update policy for composite resources and Claims
716
- using this XRD.
592
+ to set the default Composition update policy for composite resources and using
593
+ this XRD.
717
594
718
595
` ` ` yaml {label="compRev",copy-lines="none"}
719
596
apiVersion: apiextensions.crossplane.io/v1
@@ -732,11 +609,11 @@ spec:
732
609
<!-- vale off -->
733
610
# ### enforcedCompositionRef
734
611
<!-- vale on -->
735
- To require all composite resources or Claims to use a specific Composition use
736
- the `enforcedCompositionRef` setting in the XRD.
612
+ To require all composite resources to use a specific Composition use the
613
+ ` enforcedCompositionRef` setting in the XRD.
737
614
738
- For example, to require all composite resources and Claims using this XRD to use
739
- the Composition
615
+ For example, to require all composite resources using this XRD to use the
616
+ Composition
740
617
{{<hover label="enforceComp" line="6">}}myComposition{{</hover>}}
741
618
set
742
619
{{<hover label="enforceComp" line="6">}}enforcedCompositionRef.name: myComposition{{</hover>}}.
@@ -770,9 +647,6 @@ xdatabases.custom-api.example.org True True 22m
770
647
The `ESTABLISHED` field indicates Crossplane installed the Kubernetes custom
771
648
resource definition for this XRD.
772
649
773
- The `OFFERED` field indicates this XRD offers a Claim and Crossplane installed
774
- the Kubernetes custom resource definitions for the Claim.
775
-
776
650
# ## XRD conditions
777
651
Crossplane uses a standard set of `Conditions` for XRDs.
778
652
View the conditions of a XRD under their `Status` with
@@ -789,9 +663,6 @@ Status:
789
663
Reason: WatchingCompositeResource
790
664
Status: True
791
665
Type: Established
792
- Reason: WatchingCompositeResourceClaim
793
- Status: True
794
- Type: Offered
795
666
# Removed for brevity
796
667
` ` `
797
668
@@ -820,29 +691,3 @@ Type: Established
820
691
Status: False
821
692
Reason: TerminatingCompositeResource
822
693
` ` `
823
-
824
- <!-- vale off -->
825
- # ### WatchingCompositeResourceClaim
826
- <!-- vale on -->
827
- `Reason : WatchingCompositeResourceClaim` indicates Crossplane defined the new
828
- Kubernetes custom resource definitions related to the offered Claims and is
829
- watching for the creation of new Claims.
830
-
831
- ` ` ` yaml
832
- Type: Offered
833
- Status: True
834
- Reason: WatchingCompositeResourceClaim
835
- ` ` `
836
-
837
- <!-- vale off -->
838
- # ### TerminatingCompositeResourceClaim
839
- <!-- vale on -->
840
- `Reason : TerminatingCompositeResourceClaim` indicates Crossplane is deleting the
841
- custom resource definitions related to the offered Claims and is
842
- terminating the Claims controller.
843
-
844
- ` ` ` yaml
845
- Type: Offered
846
- Status: False
847
- Reason: TerminatingCompositeResourceClaim
848
- ` ` `
0 commit comments