Skip to content

Commit a96f8f7

Browse files
authored
Merge pull request #36817 from windsonsea/crdver
[zh]Sync custom-resource-definition-versioning.md
2 parents 5dc911a + de0436c commit a96f8f7

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

content/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ procedure.
14211421
2. Remove the old version from the CustomResourceDefinition `status.storedVersions` field.
14221422
-->
14231423

1424-
*选项 1:* 使用存储版本迁移程序(Storage Version Migrator)
1424+
**选项 1:** 使用存储版本迁移程序(Storage Version Migrator)
14251425

14261426
1. 运行[存储版本迁移程序](https://github.com/kubernetes-sigs/kube-storage-version-migrator)
14271427
2. 从 CustomResourceDefinition 的 `status.storedVersions` 字段中去掉
@@ -1432,7 +1432,7 @@ procedure.
14321432

14331433
The following is an example procedure to upgrade from `v1beta1` to `v1`.
14341434
-->
1435-
*选项 2:* 手动将现有对象升级到新的存储版本
1435+
**选项 2:** 手动将现有对象升级到新的存储版本
14361436

14371437
以下是从 `v1beta1` 升级到 `v1` 的示例过程。
14381438

@@ -1450,21 +1450,34 @@ The following is an example procedure to upgrade from `v1beta1` to `v1`.
14501450
这会强制后端使用当前存储版本(即 `v1`)写入对象。
14511451
3. 从 CustomResourceDefinition 的 `status.storedVersions` 字段中删除 `v1beta1`。
14521452

1453+
{{< note >}}
1454+
<!--
1455+
The flag `--subresource` is used with the kubectl get, patch, edit, and replace commands to
1456+
fetch and update the subresources, `status` and `scale`, for all the API resources that
1457+
support them. This flag is available starting from kubectl version v1.24. Previously, reading
1458+
subresources (like `status`) via kubectl involved using `kubectl --raw`, and updating
1459+
subresources using kubectl was not possible at all. Starting from v1.24, the `kubectl` tool
1460+
can be used to edit or patch the `status` subresource on a CRD object. See [How to patch a Deployment using the subresource flag](/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#scale-kubectl-patch).
1461+
-->
1462+
`--subresource` 标志在 kubectl get、patch、edit 和 replace 命令中用于获取和更新所有支持它们的
1463+
API 资源的子资源、`status` 和 `scale`。此标志从 kubectl 版本 v1.24 开始可用。
1464+
以前通过 kubectl 读取子资源(如 `status`)涉及使用 `kubectl --raw`,并且根本不可能使用 kubectl 更新子资源。
1465+
从 v1.24 开始,`kubectl` 工具可用于编辑或修补有关 CRD 对象的 `status` 子资源。
1466+
请参阅[如何使用子资源标志修补 Deployment](/zh-cn/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#scale-kubectl-patch)。
1467+
14531468
<!--
1454-
The `kubectl` tool currently cannot be used to edit or patch the `status` subresource on a CRD: see the [Kubectl Subresource Support KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2590-kubectl-subresource) for more details.
1469+
This page is part of the documentation for Kubernetes v{{< skew currentVersion >}}.
1470+
If you are running a different version of Kubernetes, consult the documentation for that release.
14551471

1456-
The easier way to patch the status subresource from the CLI is directly interacting with the API server using the `curl` tool, in this example:
1472+
Here is an example of how to patch the `status` subresource for a CRD object using `kubectl`:
14571473
-->
1458-
{{< note >}}
1459-
`kubectl` 工具目前不能用于编辑或修补 CRD 上的 `status` 子资源:请参阅
1460-
[kubectl Subresource Support KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2590-kubectl-subresource)
1461-
了解更多细节。
1474+
此页面是 Kubernetes v{{< skew currentVersion >}} 文档的一部分。
1475+
如果你运行的是不同版本的 Kubernetes,请查阅相应版本的文档。
1476+
1477+
以下是如何使用 `kubectl` 为一个 CRD 对象修补 `status` 子资源的示例:
14621478

1463-
从 CLI 给 `status` 子资源打补丁的更简单的方法是使用 `curl` 工具直接与 API 服务器交互,示例:
14641479
```bash
1465-
kubectl proxy &
1466-
curl --header "Content-Type: application/json-patch+json" \
1467-
--request PATCH http://localhost:8001/apis/apiextensions.k8s.io/v1/customresourcedefinitions/<your CRD name here>/status \
1468-
--data '[{"op": "replace", "path": "/status/storedVersions", "value":["v1"]}]'
1480+
kubectl patch customresourcedefinitions <CRD_Name> --subresource='status' --type='merge' -p '{"status":{"storedVersions":["v1"]}}'
14691481
```
1470-
{{< /note >}}
1482+
{{< /note >}}
1483+

0 commit comments

Comments
 (0)