Skip to content

Commit e1eb67d

Browse files
committed
Add instructions for data-router
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent e63da43 commit e1eb67d

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

docs/uplink/ingress-for-tunnels.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,153 @@ spec:
282282
```
283283
284284
After applying these resources you should be able to access the data plane for both tunnels on their custom domain.
285+
286+
## Wildcard Ingress with the data-router
287+
288+
As an alternative to creating individual sets of Ingress records, DNS A/CNAME entries and TLS certificates for each tunnel, you can use the `data-router` to route traffic to the correct tunnel based on the hostname. This approach uses a wildcard DNS entry and a single TLS certificate for all tunnels.
289+
290+
The following example is adapted from the cert-manager documentation to use DigitalOcean's DNS servers, however you can find [instructions for issuers](https://cert-manager.io/docs/configuration/acme/dns01/) such as AWS Route53, Cloudflare, and Google Cloud DNS listed.
291+
292+
DNS01 challenges require a secret to be created containing the credentials for the DNS provider. The secret is referenced by the issuer resource.
293+
294+
```bash
295+
kubectl create secret generic \
296+
-n inlets digitalocean-dns \
297+
--from-file access-token=$HOME/do-access-token
298+
```
299+
300+
Create a separate `Issuer`, assuming a domain of `t.example.com`, where each tunnel would be i.e. `prometheus.t.example.com` or `api.t.example.com`:
301+
302+
```bash
303+
export NS="inlets"
304+
export ISSUER_NAME="inlets-wildcard"
305+
export DOMAIN="t.example.com"
306+
307+
cat <<EOF | kubectl apply -f -
308+
apiVersion: cert-manager.io/v1
309+
kind: Issuer
310+
metadata:
311+
name: $ISSUER_NAME
312+
namespace: $NS
313+
spec:
314+
acme:
315+
email: webmaster@$DOMAIN
316+
server: https://acme-v02.api.letsencrypt.org/directory
317+
privateKeySecretRef:
318+
name: $ISSUER_NAME
319+
solvers:
320+
- dns01:
321+
digitalocean:
322+
tokenSecretRef:
323+
name: digitalocean-dns
324+
key: access-token
325+
EOF
326+
```
327+
328+
Update values.yaml to enable the dataRouter and to specify the wildcard domain:
329+
330+
```yaml
331+
## The dataRouter is an option component to enable easy Ingress to connected tunnels.
332+
## Learn more under "Ingress for Tunnels" in the docs: https://docs.inlets.dev/
333+
dataRouter:
334+
enabled: true
335+
336+
# Leave out the asterix i.e. *.t.example.com would be: t.example.com
337+
wildcardDomain: "t.example.com"
338+
339+
tls:
340+
issuerName: "inlets-wildcard"
341+
342+
ingress:
343+
class: "nginx"
344+
annotations:
345+
# Apply basic rate limiting.
346+
nginx.ingress.kubernetes.io/limit-connections: "300"
347+
nginx.ingress.kubernetes.io/limit-rpm: "1000"
348+
```
349+
350+
Apply the updated values:
351+
352+
```bash
353+
helm upgrade --install inlets-uplink \
354+
oci://ghcr.io/openfaasltd/inlets-uplink-provider \
355+
--namespace inlets \
356+
--values ./values.yaml
357+
```
358+
359+
Create a tunnel with an Ingress Domain specified in the `.Spec` field:
360+
361+
```bash
362+
export TUNNEL_NS="tunnels"
363+
export DOMAIN="t.example.com"
364+
365+
cat <<EOF | kubectl apply -f -
366+
apiVersion: uplink.inlets.dev/v1alpha1
367+
kind: Tunnel
368+
metadata:
369+
name: fileshare
370+
namespace: $TUNNEL_NS
371+
spec:
372+
licenseRef:
373+
name: inlets-uplink-license
374+
namespace: $TUNNEL_NS
375+
ingressDomains:
376+
- fileshare.$DOMAIN
377+
EOF
378+
```
379+
380+
On a private computer, create a new directory, a file to serve and then run the built-in HTTP server:
381+
382+
```bash
383+
cd /tmp
384+
mkdir -p ./share
385+
cd ./share
386+
echo "Hello from inlets" > index.html
387+
388+
inlets-pro fileserver --port 8080 --allow-browsing --webroot ./
389+
```
390+
391+
Get the instructions to connect to the tunnel.
392+
393+
The `--domain` flag here is for your uplink control-plane, where tunnels connect, not the data-plane where ingress is served. This is usually i.e. `uplink.example.com`.
394+
395+
```bash
396+
export TUNNEL_NS="tunnels"
397+
export UPLINK_DOMAIN="uplink.example.com"
398+
399+
inlets-pro tunnel connect fileshare \
400+
--namespace $TUNNEL_NS \
401+
--domain $UPLINK_DOMAIN
402+
```
403+
404+
Add the `--upstream fileshare.t.example.com=fileshare` flag to the command you were given, then run it.
405+
406+
The command below is sample output, do not copy it directly.
407+
408+
```bash
409+
inlets-pro uplink client \
410+
--url=wss://uplink.example.com/tunnels/fileshare \
411+
--token=REDACTED \
412+
--upstream fileshare.t.example.com=http://127.0.0.1:8080
413+
```
414+
415+
Now, access the tunneled service via the wildcard domain i.e. `https://fileshare.t.example.com`.
416+
417+
You should see: "Hello from inlets" printed in your browser.
418+
419+
Finally, you can view the logs of the data-router, to see it resolving internal tunnel service names for various hostnames:
420+
421+
```bash
422+
kubectl logs -n inlets deploy/data-router
423+
424+
2024-01-24T11:29:16.965Z info data-router/main.go:51 Inlets (tm) Uplink - data-router:
425+
426+
2024-01-24T11:29:16.970Z info data-router/main.go:90 Listening on: 8080 Tunnel namespace: (all) Kubernetes version: v1.27.4+k3s1
427+
428+
I0124 11:29:58.858772 1 main.go:151] Host: fileshares.t.example.com Path: /
429+
I0124 11:29:58.858877 1 roundtripper.go:48] "No ingress found" hostname="fileshares.t.example.com" path="/"
430+
431+
I0124 11:30:03.588993 1 main.go:151] Host: fileshare.t.example.com Path: /
432+
I0124 11:30:03.589051 1 roundtripper.go:56] "Resolved" hostname="fileshare.t.example.com" path="/" tunnel="fileshare.tunnels:8000"
433+
```
434+

0 commit comments

Comments
 (0)