1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-12 21:39:30 +00:00

README: expand a bit on Watch API (#746)

This commit is contained in:
Silvio Moioli
2025-07-29 10:04:26 +02:00
committed by GitHub
parent a344ad448f
commit 9fd14ce23a

View File

@@ -375,6 +375,41 @@ response as `pages` and `count` respectively.
If a page number is out of bounds, an empty list is returned. If a page number is out of bounds, an empty list is returned.
### /v1/subscribe (Watch API)
Steve provides real-time updates for Kubernetes resources through a WebSocket-based Watch API, available at the `/v1/subscribe` endpoint. This API leverages the generic subscription framework from [rancher/apiserver](https://github.com/rancher/apiserver).
To test, connect to the endpoint using a websocket client like websocat:
```sh
websocat -k wss://127.0.0.1:9443/v1/subscribe
```
When using Steve as integrated in Rancher, you can connect by:
- Creating an API token:
- Open Rancher in a browser, log in
- Click on the user icon in the top-right corner
- Click on "Account and API Keys"
- Click on "Create API Key"
- Add a Description, click Create
- Copy the "Bearer Token" value
- Using the following lines:
```sh
read RANCHER_TOKEN
websocat --header="Cookie: R_SESS=$RANCHER_TOKEN" wss://my.rancher.server/v1/subscribe
```
Review the [rancher/apiserver](https://github.com/rancher/apiserver) README for protocol details.
In addition to regular Kubernetes resources, steve allows you to subscribe to
special steve resources. For example, to subscribe to counts, send a websocket
message like this:
```
{"resourceType":"count"}
```
Running the Steve server Running the Steve server
------------------------ ------------------------
@@ -493,26 +528,6 @@ resource for preference storage instead.
Counts keeps track of the number of resources and updates the count in a Counts keeps track of the number of resources and updates the count in a
buffered stream that the dashboard can subscribe to. buffered stream that the dashboard can subscribe to.
#### [Subscribe](https://github.com/rancher/apiserver/tree/master/pkg/subscribe)
Steve exposes a websocket endpoint on /v1/subscribe for sending streams of
events. Connect to the endpoint using a websocket client like websocat:
```sh
websocat -k wss://127.0.0.1:9443/v1/subscribe
```
Review the [apiserver](https://github.com/rancher/apiserver#subscribe) guide
for details.
In addition to regular Kubernetes resources, steve allows you to subscribe to
special steve resources. For example, to subscribe to counts, send a websocket
message like this:
```
{"resourceType":"count"}
```
### Schema Templates ### Schema Templates
Existing schemas can be customized using schema templates. You can customize Existing schemas can be customized using schema templates. You can customize