Skip to content

Commit 781573a

Browse files
weltekialexellis
authored andcommitted
Docs for uplink REST API
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent 71dbf64 commit 781573a

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed

docs/uplink/rest-api.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Inlets Uplink REST API
2+
3+
Inlets uplink tunnels and namespaces can be managed through a REST API.
4+
5+
A quick note on TLS: when you expose the uplink API over the Internet, you should enable HTTPS to prevent snooping and tampering.
6+
7+
## Installation
8+
9+
The Uplink Client API can be enabled through the helm chart. Update the `values.yaml`:
10+
11+
```yaml
12+
clientApi:
13+
enable: true
14+
15+
# Domain used for client API ingress
16+
domain: clientapi.example.com
17+
```
18+
19+
## Authentication
20+
21+
The Inlets Uplink client API supports authentication through API tokens.
22+
23+
The authentication token can be retrieved from the cluster at any time by an administrator.
24+
25+
```sh
26+
export TOKEN=$(kubectl get secret -n inlets client-api-token \
27+
-o jsonpath="{.data.client-api-token}" \
28+
| base64 --decode)
29+
```
30+
31+
## Tunnels
32+
33+
### Get a tunnel
34+
35+
```sh
36+
curl -i \
37+
-H "Authorization: Bearer ${TOKEN}" \
38+
"$CLIENT_API/v1/tunnels/$NAME?namespace=$NAMESPACE"
39+
```
40+
41+
Adding the query parameter `metrics=1` includes additional tunnel metrics in the response like RX and TX and TCP connection rate.
42+
43+
Path parameters:
44+
45+
* `name` - Name of the tunnel.
46+
47+
Query parameters:
48+
49+
* `namespace` - Namespace where the tunnel should be looked up.
50+
* `metrics` - Include tunnel metrics in the response.
51+
52+
### List tunnels
53+
54+
```sh
55+
curl -i \
56+
-H "Authorization: Bearer ${TOKEN}" \
57+
"$CLIENT_API/v1/tunnels?namespace=$NAMESPACE"
58+
```
59+
60+
Query parameters:
61+
62+
* `namespace` - Namespace where the tunnel should be looked up.
63+
64+
### Create a tunnel
65+
66+
```sh
67+
curl -i \
68+
-X POST \
69+
-H "Authorization: Bearer ${TOKEN}" \
70+
"$CLIENT_API/v1/tunnels"
71+
-d '{ "name": "acmeco", "namespace": "acmeco", "tcpPorts": [ 80, 443 ] }'
72+
```
73+
74+
### Update a tunnel
75+
76+
```sh
77+
curl -i \
78+
-X PUT \
79+
-H "Authorization: Bearer ${TOKEN}" \
80+
"$CLIENT_API/v1/tunnels"
81+
-d '{ "name": "acmeco", "namespace": "acmeco", "tcpPorts": [ 80, 443, 4222 ] }'
82+
```
83+
84+
### Delete a tunnel
85+
86+
```sh
87+
curl -i \
88+
-X DELETE \
89+
-H "Authorization: Bearer ${TOKEN}" \
90+
"$CLIENT_API/v1/tunnels/$NAME?namespace=$NAMESPACE"
91+
```
92+
93+
Path parameters:
94+
95+
* `name` - Name of the tunnel.
96+
97+
Query parameters:
98+
99+
* `namespace` - Namespace where the tunnel should be looked up.
100+
101+
102+
## Namespace management
103+
104+
The inlets uplink client API includes REST endpoints for listing, creating and deleting namespaces. Namespaces created through the API are automatically labeled for use with inlets uplink.
105+
The `kube-system` and `inlets` namespace can not be used as tunnel namespaces.
106+
107+
### List uplink namespace
108+
109+
List all inlets uplink namespaces. This endpoint will list all namespaces with a label `inlets.dev/uplink=1`.
110+
111+
```sh
112+
curl -i \
113+
-H "Authorization: Bearer ${TOKEN}" \
114+
"$CLIENT_API/v1/namespace
115+
```
116+
117+
### Create a namespace
118+
119+
```sh
120+
curl -i \
121+
-X POST \
122+
-H "Authorization: Bearer ${TOKEN}" \
123+
"$CLIENT_API/v1/tunnels/$NAME?namespace=$NAMESPACE"
124+
-d '{ "name": "acmeco" }'
125+
```
126+
127+
Every namespace created through the API will have the `inlets.dev/uplink=1` label set.
128+
129+
The API supports adding additional namespace labels and annotations:
130+
131+
```json
132+
{
133+
"name": "acmeco",
134+
"annotations": {
135+
"customer": "acmeco"
136+
},
137+
"labels": {
138+
"customer": "acmeco"
139+
}
140+
}
141+
```
142+
143+
### Delete a namespace
144+
145+
```sh
146+
curl -i \
147+
-X DELETE \
148+
-H "Authorization: Bearer ${TOKEN}" \
149+
"$CLIENT_API/v1/namespace/$NAME"
150+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ nav:
120120
- Connect to tunnels: uplink/connect-to-tunnels.md
121121
- Monitor tunnels: uplink/monitoring-tunnels.md
122122
- Ingress for tunnels: uplink/ingress-for-tunnels.md
123+
- REST API: uplink/rest-api.md
123124
- Reference:
124125
- Overview: reference/index.md
125126
- Inlets Operator: reference/inlets-operator.md

0 commit comments

Comments
 (0)