Skip to content

Commit

Permalink
Add notes and tips to Usage
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <turkenh@gmail.com>
  • Loading branch information
turkenh committed Sep 11, 2023
1 parent 196e10b commit 1bb8d5b
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions content/master/concepts/usages.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ as follows:
2. Deletion ordering by ensuring that a resource isn't deleted before the
deletion of its dependent resources.

See the [Usage for Deletion Protection](#usage-for-deletion-protection) for the
first use case and the [Usage for Deletion Ordering](#usage-for-deletion-ordering)
See the section [Usage for Deletion Protection](#usage-for-deletion-protection) for the
first use case and the section [Usage for Deletion Ordering](#usage-for-deletion-ordering)
for the second one.

## Enable usages
Expand Down Expand Up @@ -65,6 +65,17 @@ defines the using resource. Both fields are optional, but at least one of them
must be provided.
<!-- vale write-good.Passive = YES -->
{{<hint "important" >}}
<!-- vale write-good.Passive = NO -->
Usage relationships can be defined between `Managed Resources` and `Composites`.
<!-- vale write-good.TooWordy = NO -->
However, a `Composite` as the using resource (`spec.by`) would be ineffective unless
<!-- vale write-good.TooWordy = YES -->
`compositeDeletePolicy` `Foreground` is used because it wouldn't block deletion of its
child resources before its own deletion with the default deletion policy `Background`.
<!-- vale write-good.Passive = YES -->
{{< /hint >}}

### Usage for deletion protection

The following example prevents the deletion of the
Expand Down Expand Up @@ -140,7 +151,7 @@ spec:
baz: qux
```

Once the `Usage` controller resolves the selectors, it persists the resource
After the `Usage` controller resolves the selectors, it persists the resource
name in the
{{<hover label="selectors-resolved" line="10">}}resourceRef.name{{</hover>}}
field. The following example shows the `Usage` resource after the resolution of
Expand Down Expand Up @@ -220,3 +231,17 @@ spec:
resourceSelector:
matchControllerRef: true
```

{{<hint "tip" >}}

<!-- vale write-good.Passive = NO -->
When there are multiple resources of same type in a Composition, the
{{<hover label="composition" line="10">}}Usage{{</hover>}} resource must
uniquely identify the resource in use or the using one. This could be
accomplished by using extra labels and combining
{{<hover label="composition" line="23">}}matchControllerRef{{</hover>}}
with a `matchLabels` selector or directly patching the `resourceRef.name`
with the help of `ToEnvironmentFieldPath` and `FromEnvironmentFieldPath`
patches.
<!-- vale write-good.Passive = YES -->
{{< /hint >}}

0 comments on commit 1bb8d5b

Please sign in to comment.