[zh] Update update-api-object-kubectl-patch.md
sign off xin.li<xin.li@daocloud.io>
This commit is contained in:
+10
-23
@@ -254,7 +254,7 @@ Patch your Deployment:
|
|||||||
对 Deployment 执行 patch 操作:
|
对 Deployment 执行 patch 操作:
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl patch deployment patch-demo --patch "$(cat patch-file-containers.yaml)"
|
kubectl patch deployment patch-demo --patch-file patch-file-tolerations.yaml"
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -368,7 +368,7 @@ In your patch command, set `type` to `merge`:
|
|||||||
在 patch 命令中,将 `type` 设置为 `merge`:
|
在 patch 命令中,将 `type` 设置为 `merge`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl patch deployment patch-demo --type merge --patch "$(cat patch-file-2.yaml)"
|
kubectl patch deployment patch-demo --type merge --patch-file patch-file-2.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -450,14 +450,9 @@ spec:
|
|||||||
<!-- Patch your Deployment: -->
|
<!-- Patch your Deployment: -->
|
||||||
修补你的 Deployment:
|
修补你的 Deployment:
|
||||||
|
|
||||||
{{< tabs name="kubectl_retainkeys_example" >}}
|
```shell
|
||||||
{{{< tab name="Bash" codelang="bash" >}}
|
kubectl patch deployment patch-demo --patch-file patch-file.yaml
|
||||||
kubectl patch deployment retainkeys-demo --type merge --patch "$(cat patch-file-no-retainkeys.yaml)"
|
```
|
||||||
{{< /tab >}}
|
|
||||||
{{< tab name="PowerShell" codelang="posh" >}}
|
|
||||||
kubectl patch deployment retainkeys-demo --type merge --patch $(Get-Content patch-file-no-retainkeys.yaml -Raw)
|
|
||||||
{{< /tab >}}}
|
|
||||||
{{< /tabs >}}
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
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`:
|
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`:
|
||||||
@@ -497,14 +492,9 @@ Patch your Deployment again with this new patch:
|
|||||||
|
|
||||||
使用新的 patch 重新修补 Deployment:
|
使用新的 patch 重新修补 Deployment:
|
||||||
|
|
||||||
{{< tabs name="kubectl_retainkeys2_example" >}}
|
```shell
|
||||||
{{{< tab name="Bash" codelang="bash" >}}
|
kubectl patch deployment retainkeys-demo --type merge --patch-file patch-file-no-retainkeys.yaml
|
||||||
kubectl patch deployment retainkeys-demo --type merge --patch "$(cat patch-file-retainkeys.yaml)"
|
```
|
||||||
{{< /tab >}}
|
|
||||||
{{< tab name="PowerShell" codelang="posh" >}}
|
|
||||||
kubectl patch deployment retainkeys-demo --type merge --patch $(Get-Content patch-file-retainkeys.yaml -Raw)
|
|
||||||
{{< /tab >}}}
|
|
||||||
{{< /tabs >}}
|
|
||||||
|
|
||||||
<!-- Examine the content of the Deployment: -->
|
<!-- Examine the content of the Deployment: -->
|
||||||
检查 Deployment 的内容:
|
检查 Deployment 的内容:
|
||||||
@@ -625,10 +615,10 @@ The following commands are equivalent:
|
|||||||
以下命令是等价的:
|
以下命令是等价的:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl patch deployment patch-demo --patch "$(cat patch-file.yaml)"
|
kubectl patch deployment patch-demo --patch-file patch-file.yaml"
|
||||||
kubectl patch deployment patch-demo --patch 'spec:\n template:\n spec:\n containers:\n - name: patch-demo-ctr-2\n image: redis'
|
kubectl patch deployment patch-demo --patch 'spec:\n template:\n spec:\n containers:\n - name: patch-demo-ctr-2\n image: redis'
|
||||||
|
|
||||||
kubectl patch deployment patch-demo --patch "$(cat patch-file.json)"
|
kubectl patch deployment patch-demo --patch-file patch-file.json"
|
||||||
kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo-ctr-2","image": "redis"}]}}}}'
|
kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo-ctr-2","image": "redis"}]}}}}'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -681,6 +671,3 @@ Strategic merge patch is not supported for custom resources.
|
|||||||
* [使用配置文件执行 Kubernetes 对象的指令式管理](/zh/docs/tasks/manage-kubernetes-objects/imperative-config)
|
* [使用配置文件执行 Kubernetes 对象的指令式管理](/zh/docs/tasks/manage-kubernetes-objects/imperative-config)
|
||||||
* [使用配置文件对 Kubernetes 对象进行声明式管理](/zh/docs/tasks/manage-kubernetes-objects/declarative-config/)
|
* [使用配置文件对 Kubernetes 对象进行声明式管理](/zh/docs/tasks/manage-kubernetes-objects/declarative-config/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user