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 <stirabos@redhat.com>
This commit is contained in:
Simone Tiraboschi
2021-07-29 13:42:46 +02:00
parent 55d33c1311
commit eca82e08f9
@@ -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/<your CRD name here>/status \
--data '[{"op": "replace", "path": "/status/storedVersions", "value":["v1"]}]'
```
{{< /note >}}