Skip to content

Commit cc9dd34

Browse files
docs: update patchMultipleObject example to filter with labelSelector (#5700)
* Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md * Update patchMultipleObjects.md
1 parent 2aaa42f commit cc9dd34

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

examples/patchMultipleObjects.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ cat <<EOF >$DEMO_HOME/deployments.yaml
7878
apiVersion: apps/v1
7979
kind: Deployment
8080
metadata:
81+
labels:
82+
old-label: old-value
8183
name: deploy1
8284
spec:
8385
template:
@@ -95,6 +97,8 @@ spec:
9597
apiVersion: apps/v1
9698
kind: Deployment
9799
metadata:
100+
labels:
101+
key: value
98102
name: deploy2
99103
spec:
100104
template:
@@ -149,7 +153,7 @@ patches:
149153
EOF
150154
```
151155
152-
The expected result is:
156+
Two deployment will be patched, the expected result is:
153157
154158
<!-- @definedExpectedOutput @testAgainstLatestRelease -->
155159
@@ -158,6 +162,8 @@ cat <<EOF >$DEMO_HOME/out_expected.yaml
158162
apiVersion: apps/v1
159163
kind: Deployment
160164
metadata:
165+
labels:
166+
old-label: old-value
161167
name: deploy1
162168
spec:
163169
template:
@@ -180,6 +186,8 @@ spec:
180186
apiVersion: apps/v1
181187
kind: Deployment
182188
metadata:
189+
labels:
190+
key: value
183191
name: deploy2
184192
spec:
185193
template:
@@ -214,5 +222,29 @@ Confirm expectations:
214222
diff $DEMO_HOME/out_actual.yaml $DEMO_HOME/out_expected.yaml
215223
```
216224
217-
To see how to do this with JSON patches,
218-
try the [JSON patch] demo.
225+
Let us do one more try.
226+
Redefine a kustomization file. This time only patch one deployment whose label is "key: value".
227+
228+
```
229+
cat <<EOF >$DEMO_HOME/kustomization.yaml
230+
resources:
231+
- deployments.yaml
232+
233+
patches:
234+
- path: patch.yaml
235+
target:
236+
kind: Deployment
237+
labelSelector: key=value
238+
EOF
239+
```
240+
241+
Run the build:
242+
```
243+
kustomize build $DEMO_HOME
244+
```
245+
246+
Confirm expectations:
247+
```
248+
Only deploy2 is patched since its label matches "labelSelector: key=value". No change for deploy1.
249+
```
250+

0 commit comments

Comments
 (0)