Skip to content

Commit 5ae78ac

Browse files
authored
Merge pull request #31009 from mikemonteith/patch-1
Use --patch-file in documentation
2 parents 3a4a1ca + f7d717d commit 5ae78ac

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

content/en/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,9 @@ spec:
7070
7171
Patch your Deployment:
7272
73-
{{< tabs name="kubectl_patch_example" >}}
74-
{{{< tab name="Bash" codelang="bash" >}}
75-
kubectl patch deployment patch-demo --patch "$(cat patch-file.yaml)"
76-
{{< /tab >}}
77-
{{< tab name="PowerShell" codelang="posh" >}}
78-
kubectl patch deployment patch-demo --patch $(Get-Content patch-file.yaml -Raw)
79-
{{< /tab >}}}
80-
{{< /tabs >}}
73+
```shell
74+
kubectl patch deployment patch-demo --patch-file patch-file.yaml
75+
```
8176

8277
View the patched Deployment:
8378

@@ -183,7 +178,7 @@ spec:
183178
Patch your Deployment:
184179
185180
```shell
186-
kubectl patch deployment patch-demo --patch "$(cat patch-file-tolerations.yaml)"
181+
kubectl patch deployment patch-demo --patch-file patch-file-tolerations.yaml
187182
```
188183
189184
View the patched Deployment:
@@ -249,7 +244,7 @@ spec:
249244
In your patch command, set `type` to `merge`:
250245

251246
```shell
252-
kubectl patch deployment patch-demo --type merge --patch "$(cat patch-file-2.yaml)"
247+
kubectl patch deployment patch-demo --type merge --patch-file patch-file-2.yaml
253248
```
254249

255250
View the patched Deployment:
@@ -308,14 +303,9 @@ spec:
308303
309304
Patch your Deployment:
310305
311-
{{< tabs name="kubectl_retainkeys_example" >}}
312-
{{{< tab name="Bash" codelang="bash" >}}
313-
kubectl patch deployment retainkeys-demo --type merge --patch "$(cat patch-file-no-retainkeys.yaml)"
314-
{{< /tab >}}
315-
{{< tab name="PowerShell" codelang="posh" >}}
316-
kubectl patch deployment retainkeys-demo --type merge --patch $(Get-Content patch-file-no-retainkeys.yaml -Raw)
317-
{{< /tab >}}}
318-
{{< /tabs >}}
306+
```shell
307+
kubectl patch deployment retainkeys-demo --type merge --patch-file patch-file-no-retainkeys.yaml
308+
```
319309
320310
In the output, you can see that it is not possible to set `type` as `Recreate` when a value is defined for `spec.strategy.rollingUpdate`:
321311
@@ -339,14 +329,9 @@ With this patch, we indicate that we want to retain only the `type` key of the `
339329
340330
Patch your Deployment again with this new patch:
341331
342-
{{< tabs name="kubectl_retainkeys2_example" >}}
343-
{{{< tab name="Bash" codelang="bash" >}}
344-
kubectl patch deployment retainkeys-demo --type merge --patch "$(cat patch-file-retainkeys.yaml)"
345-
{{< /tab >}}
346-
{{< tab name="PowerShell" codelang="posh" >}}
347-
kubectl patch deployment retainkeys-demo --type merge --patch $(Get-Content patch-file-retainkeys.yaml -Raw)
348-
{{< /tab >}}}
349-
{{< /tabs >}}
332+
```shell
333+
kubectl patch deployment retainkeys-demo --type merge --patch-file patch-file-retainkeys.yaml
334+
```
350335
351336
Examine the content of the Deployment:
352337
@@ -425,10 +410,10 @@ The following commands are equivalent:
425410
426411
427412
```shell
428-
kubectl patch deployment patch-demo --patch "$(cat patch-file.yaml)"
413+
kubectl patch deployment patch-demo --patch-file patch-file.yaml
429414
kubectl patch deployment patch-demo --patch 'spec:\n template:\n spec:\n containers:\n - name: patch-demo-ctr-2\n image: redis'
430415
431-
kubectl patch deployment patch-demo --patch "$(cat patch-file.json)"
416+
kubectl patch deployment patch-demo --patch-file patch-file.json
432417
kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo-ctr-2","image": "redis"}]}}}}'
433418
```
434419

0 commit comments

Comments
 (0)