Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions content/en/docs/reference/kubectl/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ For a stable output in a script:

## Subresources

* You can use the `--subresource` beta flag for kubectl commands like `get`, `patch`,
`edit` and `replace` to fetch and update subresources for all resources that
support them. Currently, only the `status` and `scale` subresources are supported.
* You can use the `--subresource` argument for kubectl subcommands such as `get`, `patch`,
`edit`, `apply` and `replace` to fetch and update subresources for all resources that
support them. In Kubernetes version {{< skew currentVersion >}}, only the `status`, `scale`
and `resize` subresources are supported.
* For `kubectl edit`, the `scale` subresource is not supported. If you use `--subresource` with
`kubectl edit` and specify `scale` as the subresource, the command will error out.
* The API contract against a subresource is identical to a full resource. While updating the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,16 +1094,6 @@ The following is an example procedure to upgrade from `v1beta1` to `v1`.
3. Remove `v1beta1` from the CustomResourceDefinition `status.storedVersions` field.

{{< note >}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could simplify the contents of this note to:

Here is an example of how to patch the `status` subresource for a CRD object using `kubectl`:

```bash
kubectl patch customresourcedefinitions <CRD_Name> --subresource='status' --type='merge' -p '{"status":{"storedVersions":["v1"]}}'
```

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's reasonable. Previously --subresource was new, so we needed explicit info when it's available. But since it's beta for all supported releases, we can just mention the example only.

The flag `--subresource` is used with the kubectl get, patch, edit, and replace commands to
fetch and update the subresources, `status` and `scale`, for all the API resources that
support them. This flag is available starting from kubectl version v1.24. Previously, reading
subresources (like `status`) via kubectl involved using `kubectl --raw`, and updating
subresources using kubectl was not possible at all. Starting from v1.24, the `kubectl` tool
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).

This page is part of the documentation for Kubernetes v{{< skew currentVersion >}}.
If you are running a different version of Kubernetes, consult the documentation for that release.

Here is an example of how to patch the `status` subresource for a CRD object using `kubectl`:
```bash
kubectl patch customresourcedefinitions <CRD_Name> --subresource='status' --type='merge' -p '{"status":{"storedVersions":["v1"]}}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,13 @@ kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"co

### Update an object's replica count using `kubectl patch` with `--subresource` {#scale-kubectl-patch}

{{< feature-state for_k8s_version="v1.24" state="alpha" >}}

The flag `--subresource=[subresource-name]` is used with kubectl commands like get, patch,
edit and replace to fetch and update `status` and `scale` subresources of the resources
(applicable for kubectl version v1.24 or more). This flag is used with all the API resources
(built-in and CRs) that have `status` or `scale` subresource. Deployment is one of the
examples which supports these subresources.
edit, apply and replace to fetch and update `status`, `scale` and `resize` subresource of the
resources you specify. You can specify a subresource for any of the Kubernetes API resources
(built-in and CRs) that have `status`, `scale` or `resize` subresource.

For example, a Deployment has a `status` subresource and a `scale` subresource, so you can
use `kubectl` to get or modify just the `status` subresource of a Deployment.

Here's a manifest for a Deployment that has two replicas:

Expand Down