Skip to content

Commit 3dea9bc

Browse files
authored
copy edit
1 parent a99f795 commit 3dea9bc

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

vcluster/configure/vcluster-yaml/sync/to-host/advanced/custom-resources.mdx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ With multi-namespace-mode you only need to rewrite references that include a nam
7979
### JavaScript expression patches {#javascript-expression-patches}
8080
<!-- vale on -->
8181

82-
These are powerful JavaScript ES6 compatible expression patches that can be used to change a field while syncing. You define how it changes when syncing from the virtual cluster into the host cluster or when syncing from the host cluster into the virtual cluster. To add a suffix to certificate DNS names you can do:
82+
These are JavaScript ES6 compatible expression patches that can be used to change a field while syncing. You define how it changes when syncing from the virtual cluster into the host cluster or when syncing from the host cluster into the virtual cluster. To add a suffix to certificate DNS names you can:
83+
8384
```yaml
8485
sync:
8586
toHost:
@@ -95,14 +96,15 @@ sync:
9596
```
9697

9798
There is also a variable called `context` besides `value` that can be used to access vCluster specific data:
98-
* `context.vcluster.name`: Name of the virtual cluster
99-
* `context.vcluster.namespace`: Namespace of the virtual cluster
100-
* `context.vcluster.config`: Config of the virtual cluster, basically `vcluster.yaml` merged with the defaults
101-
* `context.hostObject`: Host object (can be null if not available)
102-
* `context.virtualObject`: Virtual object (can be null if not available)
103-
* `context.path`: The matched path on the object, useful when using wildcard path selectors (*)
99+
- `context.vcluster.name`: Name of the virtual cluster
100+
- `context.vcluster.namespace`: Namespace of the virtual cluster
101+
- `context.vcluster.config`: Config of the virtual cluster, basically `vcluster.yaml` merged with the defaults
102+
- `context.hostObject`: Host object (can be null if not available)
103+
- `context.virtualObject`: Virtual object (can be null if not available)
104+
- `context.path`: The matched path on the object, useful when using wildcard path selectors (*)
104105

105106
For example, to add `www.` to every DNS name specified in a cert-manager certificate in the path `spec.dnsNames`, you can use the following patch:
107+
106108
```yaml
107109
sync:
108110
toHost:
@@ -117,7 +119,8 @@ sync:
117119
reverseExpression: "value.startsWith('www.') ? value.slice(4) : value"
118120
```
119121
120-
With that patch, creating a new certificate within the vCluster like this:
122+
The patch creates a new certificate within the vCluster:
123+
121124
```yaml
122125
apiVersion: cert-manager.io/v1
123126
kind: Certificate
@@ -128,7 +131,8 @@ spec:
128131
- example.com
129132
```
130133
131-
Would create the following certificate in the host cluster:
134+
vCluster syncs the host cluster and applies your patch, creating this modified certificate:
135+
132136
```yaml
133137
apiVersion: cert-manager.io/v1
134138
kind: Certificate
@@ -139,7 +143,8 @@ spec:
139143
- www.example.com # the patch added www. to this field
140144
```
141145
142-
When you change now the certificate in the host cluster like this:
146+
If you directly edit the certificate in the host cluster and change the domain:
147+
143148
```yaml
144149
apiVersion: cert-manager.io/v1
145150
kind: Certificate
@@ -150,7 +155,8 @@ spec:
150155
- www.other-domain.com # changed from www.example.com
151156
```
152157
153-
vCluster would sync back the certificate like this:
158+
vCluster detects the change, applies the reverse patch, and updates the certificate in your virtual cluster:
159+
154160
```yaml
155161
apiVersion: cert-manager.io/v1
156162
kind: Certificate

0 commit comments

Comments
 (0)