File tree Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ cat <<EOF >$DEMO_HOME/deployments.yaml
78
78
apiVersion: apps/v1
79
79
kind: Deployment
80
80
metadata:
81
+ labels:
82
+ old-label: old-value
81
83
name: deploy1
82
84
spec:
83
85
template:
95
97
apiVersion: apps/v1
96
98
kind: Deployment
97
99
metadata:
100
+ labels:
101
+ key: value
98
102
name: deploy2
99
103
spec:
100
104
template:
@@ -149,7 +153,7 @@ patches:
149
153
EOF
150
154
```
151
155
152
- The expected result is:
156
+ Two deployment will be patched, the expected result is:
153
157
154
158
<!-- @definedExpectedOutput @testAgainstLatestRelease -->
155
159
@@ -158,6 +162,8 @@ cat <<EOF >$DEMO_HOME/out_expected.yaml
158
162
apiVersion: apps/v1
159
163
kind: Deployment
160
164
metadata:
165
+ labels:
166
+ old-label: old-value
161
167
name: deploy1
162
168
spec:
163
169
template:
@@ -180,6 +186,8 @@ spec:
180
186
apiVersion: apps/v1
181
187
kind: Deployment
182
188
metadata:
189
+ labels:
190
+ key: value
183
191
name: deploy2
184
192
spec:
185
193
template:
@@ -214,5 +222,29 @@ Confirm expectations:
214
222
diff $DEMO_HOME/out_actual.yaml $DEMO_HOME/out_expected.yaml
215
223
```
216
224
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
+
You can’t perform that action at this time.
0 commit comments