Skip to content

Commit 19114e6

Browse files
authored
Merge pull request #6047 from sbueringer/pr-add-ref-example
📖 book: Writing a ClusterClass: add ref example
2 parents 867319a + 15d587d commit 19114e6

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -484,22 +484,47 @@ metadata:
484484
name: docker-clusterclass-v0.1.0
485485
spec:
486486
...
487-
jsonPatches:
488-
- op: add
489-
path: /spec/template/spec/httpProxy/url
490-
valueFrom:
491-
# Use the url field of the httpProxy variable.
492-
variable: httpProxy.url
493-
- op: add
494-
path: /spec/template/spec/dnsServers
495-
valueFrom:
496-
# Use the entire dnsServers array.
497-
variable: dnsServers
498-
- op: add
499-
path: /spec/template/spec/dnsServer
500-
valueFrom:
501-
# Use the first item of the dnsServers array.
502-
variable: dnsServers[0]
487+
jsonPatches:
488+
- op: add
489+
path: /spec/template/spec/httpProxy/url
490+
valueFrom:
491+
# Use the url field of the httpProxy variable.
492+
variable: httpProxy.url
493+
- op: add
494+
path: /spec/template/spec/dnsServers
495+
valueFrom:
496+
# Use the entire dnsServers array.
497+
variable: dnsServers
498+
- op: add
499+
path: /spec/template/spec/dnsServer
500+
valueFrom:
501+
# Use the first item of the dnsServers array.
502+
variable: dnsServers[0]
503+
```
504+
505+
**Tips & Tricks**
506+
507+
Complex variables can be used to make references in templates configurable, e.g. the `identityRef` used in `AzureCluster`.
508+
Of course it's also possible to only make the name of the reference configurable, including restricting the valid values
509+
to a pre-defined enum.
510+
511+
```yaml
512+
apiVersion: cluster.x-k8s.io/v1beta1
513+
kind: ClusterClass
514+
metadata:
515+
name: azure-clusterclass-v0.1.0
516+
spec:
517+
...
518+
variables:
519+
- name: clusterIdentityRef
520+
schema:
521+
openAPIV3Schema:
522+
type: object
523+
properties:
524+
kind:
525+
type: string
526+
name:
527+
type: string
503528
```
504529

505530
### Using variable values in JSON patches

0 commit comments

Comments
 (0)