Skip to content

Commit 466b67b

Browse files
committed
doc: Document the new stunnerctl commands (status and auth)
1 parent 7c6ca5d commit 466b67b

File tree

2 files changed

+124
-33
lines changed

2 files changed

+124
-33
lines changed

cmd/stunnerctl/README.md

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ go build -o stunnerctl cmd/stunnerctl/main.go
2626

2727
## Usage
2828

29-
Type `stunnerctl` to get a glimpse of the features provided. Below are some common usage examples.
29+
Type `stunnerctl` to get a glimpse of the sub-commands and features provided.
30+
31+
### Config
32+
33+
The `config` sub-command is used to load or watch running dataplane configs from the STUNner config discovery service (CDS) running in a remote Kubernetes cluster. Usually the CDS server role is fulfilled by the [STUNner gateway operator](https://github.com/l7mp/stunner-gateway-operator) but you can choose any CDS service you want (see the `--cds-server-*` CLI flags in the help). The main use of this command is to check the active dataplane configuration for troubleshooting connectivity problems.
3034

3135
- Dump a summary of the running config of the STUNner gateway called `udp-gateway` deployed into the `stunner` namespace:
3236

@@ -42,15 +46,21 @@ Type `stunnerctl` to get a glimpse of the features provided. Below are some comm
4246
Endpoints: [10.76.1.3, 10.80.7.104]
4347
```
4448

45-
- Dump a the running config of all gateways in the `stunner` namespace in JSON format (YAML is also available using `-o yaml`):
49+
- The same, but using the alternative Kubernetes config file `~/my-config.conf` to access the cluster. The rest of the usual `kubectl` flags (`--context`, `--token`, etc.) are also available to select the cluster to connect to.
50+
51+
``` console
52+
stunnerctl --kubeconfig ~/my-config.conf -n stunner config udp-gateway
53+
```
54+
55+
- Dump the running config of all gateways in the `stunner` namespace in JSON format (YAML is also available using `-o yaml`):
4656

4757
```console
4858
stunnerctl -n stunner config -o json
4959
{"version":"v1","admin":{"name":"stunner/tcp-gateway",...}}
5060
{"version":"v1","admin":{"name":"stunner/udp-gateway",...}}}
5161
```
5262

53-
- Watch all STUNner configs as they are being refreshed and dump only the name of the STUNner gateway whose config changes:
63+
- Watch STUNner configs as they are being refreshed by the operator and dump only the name of the gateway whose config changes:
5464

5565
```console
5666
stunnerctl config --all-namespaces -o jsonpath='{.admin.name}' -w
@@ -59,8 +69,6 @@ Type `stunnerctl` to get a glimpse of the features provided. Below are some comm
5969
...
6070
```
6171

62-
## Fallback
63-
6472
For those who don't have the Go toolchain available to run `go install`, STUNner provides a minimalistic `stunnerctl` replacement called `stunnerctl.sh`.
6573
This script requires nothing else than `bash`, `kubectl`, `curl` and `jq` to work.
6674

@@ -80,19 +88,15 @@ Listener 1
8088
Public port: 3478
8189
```
8290

83-
## Last resort
84-
85-
You can also use `kubectl port-forward` to load or watch STUNner configs manually.
86-
Open a port-forwarded connection to the STUNner gateway operator:
91+
You can also use `kubectl port-forward` to load or watch STUNner configs manually. Open a port-forwarded connection to the STUNner gateway operator:
8792

8893
``` console
8994
export CDS_SERVER_NAME=$(kubectl get pods -l stunner.l7mp.io/config-discovery-service=enabled --all-namespaces -o jsonpath='{.items[0].metadata.name}')
9095
export CDS_SERVER_NAMESPACE=$(kubectl get pods -l stunner.l7mp.io/config-discovery-service=enabled --all-namespaces -o jsonpath='{.items[0].metadata.namespace}')
9196
kubectl -n $CDS_SERVER_NAMESPACE port-forward pod/${CDS_SERVER_NAME} 63478:13478 &
9297
```
9398

94-
If all goes well, you can now connect to the STUNner config discovery API served by the gateway operator directly, just using `curl`.
95-
The below will load the config of the `udp-gateway` in the `stunner` namespace:
99+
If all goes well, you can now connect to the STUNner CDS API served by the gateway operator through the port-forwarded tunnel opened by `kubectl` just using `curl`. The below will load the config of the `udp-gateway` in the `stunner` namespace:
96100

97101
``` console
98102
curl -s http://127.0.0.1:63478/api/v1/configs/stunner/udp-gateway
@@ -104,6 +108,52 @@ If you happen to have a WebSocket client like the wonderful [`websocat`](https:/
104108
websocat ws://127.0.0.1:63478/api/v1/configs/stunner/udp-gateway?watch=true -
105109
```
106110

111+
### Status
112+
113+
The `status` sub-command reports the status of the dataplane pods for a gateway, especially the runtime state of the `stunnerd` daemon.
114+
115+
- Find all dataplane pods for the `udp-gateway` in the `stunner` namespace and dump a status summary:
116+
117+
``` console
118+
stunnerctl -n stunner status udp-gateway
119+
stunner/udp-gateway-856c9f4dc9-524hc:
120+
stunner/udp-gateway:{logLevel="all:INFO",health-check="http://:8086"}
121+
static-auth:{realm="stunner.l7mp.io",username="<SECRET>",password="<SECRET>"}
122+
listeners:1/clusters:1
123+
allocs:3/status=READY
124+
stunner/udp-gateway-856c9f4dc9-c7wcq:
125+
stunner/udp-gateway:{logLevel="all:INFO",health-check="http://:8086"}
126+
static-auth:{realm="stunner.l7mp.io",username="<SECRET>",password="<SECRET>"}
127+
listeners:1/clusters:1
128+
allocs:2/status=READY
129+
```
130+
131+
- Same but report only the runtime status of the `stunnerd` pods in the `stunner` namespace:
132+
133+
``` console
134+
stunnerctl -n stunner status -o jsonpath='{.status}'
135+
READY
136+
TERMINATING
137+
```
138+
139+
### Authentication
140+
141+
The `auth` sub-command can be used to obtain a TURN credential or a full ICE server config for connecting to a specific gateway. The authentication service API is usually served by a separate [STUNner authentication server](https://github.com/l7mp/stunner-auth-service) deployed alongside the gateway operator. The main use of this command is to feed an ICE agent manually with the ICE server config to connect to a specific STUNner gateway.
142+
143+
- Obtain a full ICE server config for `udp-gateway` deployed into the `stunner` namespace:
144+
145+
``` console
146+
stunnerctl -n stunner auth udp-gateway
147+
{"iceServers":[{"credential":"pass-1","urls":["turn:10.104.19.179:3478?transport=udp"],"username":"user-1"}],"iceTransportPolicy":"all"}
148+
```
149+
150+
- Request a plain [TURN credential](https://datatracker.ietf.org/doc/html/draft-uberti-behave-turn-rest-00) using the authentication service deployed into the `stunner-system-prod` namespace:
151+
152+
``` console
153+
stunnerctl -n stunner auth udp-gateway --auth-turn-credential --auth-service-namespace=stunner-system-prod
154+
{"password":"pass-1","ttl":86400,"uris":["turn:10.104.19.179:3478?transport=udp"],"username":"user-1"}
155+
```
156+
107157
## License
108158

109159
Copyright 2021-2023 by its authors. Some rights reserved. See [AUTHORS](../../AUTHORS).

docs/cmd/stunnerctl.md

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ The prominent use of `stunnerctl` is to load or watch STUNner dataplane configur
55

66
## Installation
77

8-
On Linux and macOS, Use [this script](/cmd/getstunner/getstunner.sh) to download the latest version of the `stunnerctl` binary:
9-
10-
```console
11-
curl -sL https://raw.githubusercontent.com/l7mp/stunner/main/cmd/getstunner/getstunner.sh | sh -
12-
export PATH=$HOME/.l7mp/bin:$PATH
13-
```
14-
> [!NOTE]
15-
> The script installs `turncat` too.
16-
17-
Install the `stunnerctl` binary using the standard Go toolchain and add it to `$PATH`.
8+
Install the `stunnerctl` binary using the standard Go toolchain and add it to `$PATH`.
189

1910
```console
2011
go install github.com/l7mp/stunner/cmd/stunnerctl@latest
@@ -35,7 +26,11 @@ go build -o stunnerctl cmd/stunnerctl/main.go
3526

3627
## Usage
3728

38-
Type `stunnerctl` to get a glimpse of the features provided. Below are some common usage examples.
29+
Type `stunnerctl` to get a glimpse of the sub-commands and features provided.
30+
31+
### Config
32+
33+
The `config` sub-command is used to load or watch running dataplane configs from the STUNner config discovery service (CDS) running in a remote Kubernetes cluster. Usually the CDS server role is fulfilled by the [STUNner gateway operator](https://github.com/l7mp/stunner-gateway-operator) but you can choose any CDS service you want (see the `--cds-server-*` CLI flags in the help). The main use of this command is to check the active dataplane configuration for troubleshooting connectivity problems.
3934

4035
- Dump a summary of the running config of the STUNner gateway called `udp-gateway` deployed into the `stunner` namespace:
4136

@@ -51,15 +46,21 @@ Type `stunnerctl` to get a glimpse of the features provided. Below are some comm
5146
Endpoints: [10.76.1.3, 10.80.7.104]
5247
```
5348

54-
- Dump a the running config of all gateways in the `stunner` namespace in JSON format (YAML is also available using `-o yaml`):
49+
- The same, but using the alternative Kubernetes config file `~/my-config.conf` to access the cluster. The rest of the usual `kubectl` flags (`--context`, `--token`, etc.) are also available to select the cluster to connect to.
50+
51+
``` console
52+
stunnerctl --kubeconfig ~/my-config.conf -n stunner config udp-gateway
53+
```
54+
55+
- Dump the running config of all gateways in the `stunner` namespace in JSON format (YAML is also available using `-o yaml`):
5556

5657
```console
5758
stunnerctl -n stunner config -o json
5859
{"version":"v1","admin":{"name":"stunner/tcp-gateway",...}}
5960
{"version":"v1","admin":{"name":"stunner/udp-gateway",...}}}
6061
```
6162

62-
- Watch all STUNner configs as they are being refreshed and dump only the name of the STUNner gateway whose config changes:
63+
- Watch STUNner configs as they are being refreshed by the operator and dump only the name of the gateway whose config changes:
6364

6465
```console
6566
stunnerctl config --all-namespaces -o jsonpath='{.admin.name}' -w
@@ -68,16 +69,14 @@ Type `stunnerctl` to get a glimpse of the features provided. Below are some comm
6869
...
6970
```
7071

71-
## Fallback
72-
7372
For those who don't have the Go toolchain available to run `go install`, STUNner provides a minimalistic `stunnerctl` replacement called `stunnerctl.sh`.
7473
This script requires nothing else than `bash`, `kubectl`, `curl` and `jq` to work.
7574

7675
The below will dump the running config of `tcp-gateway` deployed into the `stunner` namespace:
7776

7877
```console
7978
cd stunner
80-
cmd/stunnerctl/stunnerctl.sh running-config stunner/stunner-gateway
79+
cmd/stunnerctl/stunnerctl.sh running-config stunner/tcp-gateway
8180
STUN/TURN authentication type: static
8281
STUN/TURN username: user-1
8382
STUN/TURN password: pass-1
@@ -89,19 +88,15 @@ Listener 1
8988
Public port: 3478
9089
```
9190

92-
## Last resort
93-
94-
You can use `kubectl port-forward` to load or watch STUNner configs manually.
95-
Open a port-forwarded connection to the STUNner gateway operator:
91+
You can also use `kubectl port-forward` to load or watch STUNner configs manually. Open a port-forwarded connection to the STUNner gateway operator:
9692

9793
``` console
9894
export CDS_SERVER_NAME=$(kubectl get pods -l stunner.l7mp.io/config-discovery-service=enabled --all-namespaces -o jsonpath='{.items[0].metadata.name}')
9995
export CDS_SERVER_NAMESPACE=$(kubectl get pods -l stunner.l7mp.io/config-discovery-service=enabled --all-namespaces -o jsonpath='{.items[0].metadata.namespace}')
10096
kubectl -n $CDS_SERVER_NAMESPACE port-forward pod/${CDS_SERVER_NAME} 63478:13478 &
10197
```
10298

103-
If all goes well, you can now connect to the STUNner config discovery API served by the gateway operator directly, just using `curl`.
104-
The below will load the config of the `udp-gateway` in the `stunner` namespace:
99+
If all goes well, you can now connect to the STUNner CDS API served by the gateway operator through the port-forwarded tunnel opened by `kubectl` just using `curl`. The below will load the config of the `udp-gateway` in the `stunner` namespace:
105100

106101
``` console
107102
curl -s http://127.0.0.1:63478/api/v1/configs/stunner/udp-gateway
@@ -113,6 +108,52 @@ If you happen to have a WebSocket client like the wonderful [`websocat`](https:/
113108
websocat ws://127.0.0.1:63478/api/v1/configs/stunner/udp-gateway?watch=true -
114109
```
115110

111+
### Status
112+
113+
The `status` sub-command reports the status of the dataplane pods for a gateway, especially the runtime state of the `stunnerd` daemon.
114+
115+
- Find all dataplane pods for the `udp-gateway` in the `stunner` namespace and dump a status summary:
116+
117+
``` console
118+
stunnerctl -n stunner status udp-gateway
119+
stunner/udp-gateway-856c9f4dc9-524hc:
120+
stunner/udp-gateway:{logLevel="all:INFO",health-check="http://:8086"}
121+
static-auth:{realm="stunner.l7mp.io",username="<SECRET>",password="<SECRET>"}
122+
listeners:1/clusters:1
123+
allocs:3/status=READY
124+
stunner/udp-gateway-856c9f4dc9-c7wcq:
125+
stunner/udp-gateway:{logLevel="all:INFO",health-check="http://:8086"}
126+
static-auth:{realm="stunner.l7mp.io",username="<SECRET>",password="<SECRET>"}
127+
listeners:1/clusters:1
128+
allocs:2/status=READY
129+
```
130+
131+
- Same but report only the runtime status of the `stunnerd` pods in the `stunner` namespace:
132+
133+
``` console
134+
stunnerctl -n stunner status -o jsonpath='{.status}'
135+
READY
136+
TERMINATING
137+
```
138+
139+
### Authentication
140+
141+
The `auth` sub-command can be used to obtain a TURN credential or a full ICE server config for connecting to a specific gateway. The authentication service API is usually served by a separate [STUNner authentication server](https://github.com/l7mp/stunner-auth-service) deployed alongside the gateway operator. The main use of this command is to feed an ICE agent manually with the ICE server config to connect to a specific STUNner gateway.
142+
143+
- Obtain a full ICE server config for `udp-gateway` deployed into the `stunner` namespace:
144+
145+
``` console
146+
stunnerctl -n stunner auth udp-gateway
147+
{"iceServers":[{"credential":"pass-1","urls":["turn:10.104.19.179:3478?transport=udp"],"username":"user-1"}],"iceTransportPolicy":"all"}
148+
```
149+
150+
- Request a plain [TURN credential](https://datatracker.ietf.org/doc/html/draft-uberti-behave-turn-rest-00) using the authentication service deployed into the `stunner-system-prod` namespace:
151+
152+
``` console
153+
stunnerctl -n stunner auth udp-gateway --auth-turn-credential --auth-service-namespace=stunner-system-prod
154+
{"password":"pass-1","ttl":86400,"uris":["turn:10.104.19.179:3478?transport=udp"],"username":"user-1"}
155+
```
156+
116157
## License
117158

118159
Copyright 2021-2023 by its authors. Some rights reserved. See [AUTHORS](../../AUTHORS).

0 commit comments

Comments
 (0)