From 54da987ff5b132b75ea051a0787ec686c7efeb64 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Fri, 29 Dec 2023 21:58:39 -0600 Subject: [PATCH] support extra args to tailscale up --- README.md | 1 + docker-compose-example/.env_template | 11 ++++++----- docker-compose-example/docker-compose.yml | 2 ++ image/start.sh | 2 +- k8s-example/deployment.yaml | 4 ++++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c35cee3..4f45492 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Expected environment variables: | `TS_HOSTNAME` | `my-app` | optional Tailscale hostname for the new node | | `TS_STATE_DIR` | `/var/lib/tailscale/` | required directory for storing Tailscale state, this should be mounted to the container for persistence | | `TS_TAILSCALED_EXTRA_ARGS` | `--verbose=1` | optional additional [flags](https://tailscale.com/kb/1278/tailscaled#flags-to-tailscaled) for `tailscaled` | +| `TS_EXTRA_ARGS` | `--ssh` | optional additional [flags](https://tailscale.com/kb/1241/tailscale-up) for `tailscale up` | | `TS_SERVE_PORT` | `8080` | optional application port to expose with [Tailscale Serve](https://tailscale.com/kb/1312/serve) | | `TS_FUNNEL` | `1` | if set (to anything), will proxy `TS_SERVE_PORT` **publicly** with [Tailscale Funnel](https://tailscale.com/kb/1223/funnel) | diff --git a/docker-compose-example/.env_template b/docker-compose-example/.env_template index ad85747..515c0f1 100644 --- a/docker-compose-example/.env_template +++ b/docker-compose-example/.env_template @@ -1,6 +1,7 @@ # Rename to .env -TS_AUTHKEY="" # Required Tailscale auth key -TS_HOSTNAME="" # Optional hostname for this node -TS_TAILSCALED_EXTRA_ARGS="" # Optional additional arguments for tailscaled -TS_SERVE_PORT="" # Optional backend port to proxy with tailscale serve -TS_FUNNEL="" # If set, serve publicly with tailscale funnel \ No newline at end of file +TS_AUTHKEY="" # Required Tailscale auth key +TS_HOSTNAME="" # Optional hostname for this node +TS_TAILSCALED_EXTRA_ARGS="" # Optional additional arguments for tailscaled +TS_EXTRA_ARGS="" # Optional additional arguments for tailscale up +TS_SERVE_PORT="" # Optional backend port to proxy with tailscale serve +TS_FUNNEL="" # If set, serve publicly with tailscale funnel \ No newline at end of file diff --git a/docker-compose-example/docker-compose.yml b/docker-compose-example/docker-compose.yml index 15dc660..fa4dc89 100644 --- a/docker-compose-example/docker-compose.yml +++ b/docker-compose-example/docker-compose.yml @@ -7,6 +7,8 @@ services: TS_AUTHKEY: ${TS_AUTHKEY:?err} # from https://login.tailscale.com/admin/settings/authkeys TS_HOSTNAME: ${TS_HOSTNAME:-ts-docker} TS_STATE_DIR: "/var/lib/tailscale/" # store ts state in a local volume + TS_TAILSCALED_EXTRA_ARGS: ${TS_TAILSCALED_EXTRA_ARGS:-} # optional extra args to pass to tailscaled + TS_EXTRA_ARGS: ${TS_EXTRA_ARGS:-} # optional extra flags to pass to tailscale up TS_SERVE_PORT: ${TS_SERVE_PORT:-} # optional port to proxy with tailscale serve (ex: '80') TS_FUNNEL: ${TS_FUNNEL:-} # if set, serve publicly with tailscale funnel volumes: diff --git a/image/start.sh b/image/start.sh index 484384b..47c969a 100644 --- a/image/start.sh +++ b/image/start.sh @@ -3,7 +3,7 @@ trap 'kill -TERM $PID' TERM INT echo "Starting Tailscale daemon" tailscaled --tun=userspace-networking --statedir="${TS_STATE_DIR}" ${TS_TAILSCALED_EXTRA_ARGS} & PID=$! -until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}"; do +until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}" ${TS_EXTRA_ARGS}; do sleep 0.1 done tailscale status diff --git a/k8s-example/deployment.yaml b/k8s-example/deployment.yaml index 3fb819e..19be3cb 100644 --- a/k8s-example/deployment.yaml +++ b/k8s-example/deployment.yaml @@ -21,6 +21,10 @@ spec: value: "${TS_HOSTNAME:-ts-docker}" - name: TS_STATE_DIR value: "/var/lib/tailscale" + - name: TS_TAILSCALED_EXTRA_ARGS + value: "${TS_TAILSCALED_EXTRA_ARGS:-}" + - name: TS_EXTRA_ARGS + value: "${TS_EXTRA_ARGS:-}" - name: TS_SERVE_PORT value: "${TS_SERVE_PORT:-}" - name: TS_FUNNEL