Skip to content

Commit d2618fb

Browse files
authored
Update reference.md
1 parent c172f54 commit d2618fb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/reference.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ It has several attributes:
3232
[qute templating engine](https://quarkus.io/guides/qute-reference), other resources can be referenced from the templates, see below.
3333
If the resource is namespace scoped and the namespace attribute is not specified in `.metadata` automatically the namespace of `Glue`
3434
is used.
35+
- **`resourceTemplate`** - a string template for the resource that allows the use of all features of Qute. See sample [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/SimpleBulk.yaml).
3536
- **`dependsOn`** - is a list of names of other child resources (not related resources). The resource is not reconciled until all the resources
3637
which it depends on are not reconciled and ready (if there is a `readyPostCondition` present).
3738
Note that during the cleanup phase (when a `Glue` is deleted) resources are cleaned up in reverse order.
@@ -44,6 +45,7 @@ It has several attributes:
4445
is makes the reconciliation much more efficient, since controller updates the resource only if truly changed. However,
4546
it is not possible to match resources because of some characteristics of Kubernetes API (default values, value conversions, etc)
4647
so you can always opt out the matching (use value `NONE`), and update the resource on every reconciliation.
48+
- **`bulk`** - a flag to indicate if the child resource is a bulk resource (see below), default is `false`.
4749

4850
#### Built-in conditions
4951

@@ -55,6 +57,41 @@ At the moment there are two types of built-in conditions provided:
5557
See accessing the related resource in [WebPage sample](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage/webpage.operator.yaml#L62-L64),
5658
and cross-referencing resources [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/TwoResourcesAndCondition.yaml#L23-L28).
5759

60+
#### Bulk Resources
61+
62+
Bulk is a type of child resource that handles a dynamic number of resources. For example, if you want to create many ConfigMaps based on some value in your custom resource.
63+
To use bulk resources set `bulk` flag of `childResource` to `true`. For now, **only** `resourceTemplate` is allowed in bulk resources, where you specify a yaml that contains
64+
a list of resources under `items` key. As for non-bulk resources, all the related resources, parent and other child resources which this resource `dependsOn`, are available in the template.
65+
66+
In the following sample, the number of created `ConfigMaps` is based on the `replicas` value from the `.spec` of the custom resource:
67+
68+
```yaml
69+
apiVersion: io.javaoperatorsdk.operator.glue/v1beta1
70+
kind: GlueOperator
71+
metadata:
72+
name: bulk-sample
73+
spec:
74+
parent:
75+
apiVersion: io.javaoperatorsdk.operator.glue/v1
76+
kind: TestCustomResource
77+
childResources:
78+
- name: configMaps
79+
bulk: true
80+
resourceTemplate: |
81+
items:
82+
{#for i in parent.spec.replicas}
83+
- apiVersion: v1
84+
kind: ConfigMap
85+
metadata:
86+
name: {parent.metadata.name}-{i}
87+
data:
88+
key: "value{i}"
89+
{/for}
90+
```
91+
92+
See the `GlueOperator` example [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glueoperator/BulkOperator.yaml) and a simple `Glue` example [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/c172f54943c5b6d0c8a4a6bf1a85a02113c2f2a9/src/test/resources/glue/SimpleBulk.yaml#L4).
93+
94+
5895
### Related resources
5996

6097
Related resources are resources that are not reconciled (not created, updated, or deleted) during reconciliation, but serve as an input for it.

0 commit comments

Comments
 (0)