From eca82e08f9cafadefe534a6b417b7c6a5c7b4136 Mon Sep 17 00:00:00 2001 From: Simone Tiraboschi Date: Thu, 29 Jul 2021 13:42:46 +0200 Subject: [PATCH] Concretely explain how to patch CRD status Current documentation simply suggest "Remove v1beta1 from the CustomResourceDefinition status.storedVersions field." but this cannot be done just with kubectl and it's not so intuitive. Adding an example to make it more clear. Signed-off-by: Simone Tiraboschi --- .../custom-resource-definition-versioning.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md b/content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md index 05e60449c4..b1f283000d 100644 --- a/content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md +++ b/content/en/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning.md @@ -1038,8 +1038,8 @@ procedure. *Option 1:* Use the Storage Version Migrator -1. Run the [storage Version migrator](https://github.com/kubernetes-sigs/kube-storage-version-migrator) -2. Remove the old version from the CustomResourceDefinition `status.storedVersions` field. +1. Run the [storage Version migrator](https://github.com/kubernetes-sigs/kube-storage-version-migrator) +2. Remove the old version from the CustomResourceDefinition `status.storedVersions` field. *Option 2:* Manually upgrade the existing objects to a new stored version @@ -1050,6 +1050,16 @@ The following is an example procedure to upgrade from `v1beta1` to `v1`. 2. Write an upgrade procedure to list all existing objects and write them with the same content. This forces the backend to write objects in the current storage version, which is `v1`. -2. Remove `v1beta1` from the CustomResourceDefinition `status.storedVersions` field. +3. Remove `v1beta1` from the CustomResourceDefinition `status.storedVersions` field. +{{< note >}} +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. +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: +```bash +kubectl proxy & +curl --header "Content-Type: application/json-patch+json" \ + --request PATCH http://localhost:8001/apis/apiextensions.k8s.io/v1/customresourcedefinitions//status \ + --data '[{"op": "replace", "path": "/status/storedVersions", "value":["v1"]}]' +``` +{{< /note >}}