From 9b9871f435fac8e773bad7ffc9b1893264da8900 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Fri, 29 Dec 2023 09:48:11 -0600 Subject: [PATCH] add funnel support --- .envrc_template | 3 ++- docker-compose-example/docker-compose.yml | 1 + image/start.sh | 5 +++++ k8s-example/deployment.yaml | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.envrc_template b/.envrc_template index 1c318ad..c5a9346 100644 --- a/.envrc_template +++ b/.envrc_template @@ -2,4 +2,5 @@ export TS_AUTHKEY="" export TS_HOSTNAME="" export TS_OPT="" -export TS_SERVE_PORT="" \ No newline at end of file +export TS_SERVE_PORT="" +export TS_FUNNEL_PORT="" \ No newline at end of file diff --git a/docker-compose-example/docker-compose.yml b/docker-compose-example/docker-compose.yml index d2933c1..1524fa7 100644 --- a/docker-compose-example/docker-compose.yml +++ b/docker-compose-example/docker-compose.yml @@ -8,6 +8,7 @@ services: TS_HOSTNAME: ${TS_HOSTNAME:-ts-docker} TS_STATE: "/var/lib/tailscale/tailscale.state" # store ts state in a local volume TS_SERVE_PORT: ${TS_SERVE_PORT:-} # optional port to proxy with tailscale serve (ex: '80') + TS_FUNNEL_PORT: ${TS_FUNNEL_PORT:-} # optional port to publish publicly with tailscale funnel (ex: '80') volumes: - ./ts_data:/var/lib/tailscale/ myservice: diff --git a/image/start.sh b/image/start.sh index 8cbef6f..e2642ca 100644 --- a/image/start.sh +++ b/image/start.sh @@ -12,4 +12,9 @@ if [ -n "${TS_SERVE_PORT}" ]; then tailscale serve --bg "${TS_SERVE_PORT}" fi fi +if [ -n "${TS_FUNNEL_PORT}" ]; then + if ! tailscale funnel status | grep -q -A1 '(Funnel on)' | grep -q "${TS_FUNNEL_PORT}"; then + tailscale funnel --bg "${TS_FUNNEL_PORT}" + fi +fi wait ${PID} diff --git a/k8s-example/deployment.yaml b/k8s-example/deployment.yaml index b545da4..d026bc6 100644 --- a/k8s-example/deployment.yaml +++ b/k8s-example/deployment.yaml @@ -21,6 +21,10 @@ spec: value: "tailscale-docker-k8s-simple" - name: TS_STATE value: "mem:" + - name: TS_SERVE_PORT + value: "${TS_SERVE_PORT:-}" + - name: TS_FUNNEL_PORT + value: "${TS_FUNNEL_PORT:-}" resources: limits: memory: "128Mi"