Skip to content

docs(examples): add kubernetes-session-teleport-headscale to teleport over a self-hosted Headscale tailnet - #1674

Merged
edenreich merged 4 commits into
mainfrom
docs/kubernetes-session-teleport-headscale
Nov 1, 2026
Merged

edenreich merged 4 commits into
mainfrom
docs/kubernetes-session-teleport-headscale

Conversation

@edenreich

@edenreich edenreich commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds examples/kubernetes-session-teleport-headscale, the Headscale twin of examples/kubernetes-session-teleport-netbird. It runs the same chain and the same checks on a self-hosted Headscale tailnet:

infer-local ──mTLS :52789──▶ infer-k8s ──mTLS :8443──▶ gateway (tokenless, or the Inference Gateway via task gateway:real)
  • Tailnet. Headscale v0.29.7 in the cluster, serving HTTPS from the cert-manager demo CA, with its embedded DERP relay and STUN as the only relays (derp.urls: []), so nothing leaves the cluster. MagicDNS names live under tailnet.internal.
  • Nodes. Each node joins with a tagged, ephemeral, reusable pre-auth key. infer-k8s, the gateway and the attacker run a tailscale/tailscale v1.104.4 sidecar in kernel mode, and infer-local runs one beside the cluster in compose. The sidecar rewrites the pod's shared resolv.conf, and override_local_dns: false keeps cluster names resolving.
  • Policy. headscale/policy.hujson holds two ACLs, tag:infer-local → tag:infer-k8s:52789 and tag:infer-k8s → tag:gateway:8443. The attacker's tag gets none.
  • Gateway node. tokenless carries the sidecar in its Deployment, and the operator's Gateway carries it through spec.pod.containers and spec.pod.volumes (operator v0.32.0, feat(pod): add sidecar containers and volumes to spec.pod operator#317). The NetworkPolicy gateway-wireguard-only admits only WireGuard to the gateway's pods, so port 8443 is reachable over the tailnet alone. task gateway:real removes the earlier gateway and its offline node before it creates the Gateway, so the new pod gets the name gateway. The operator installs with kubectl apply --server-side, because the v0.32.0 CRDs are too large for a client-side apply. gateway:real and local:up return only once infer-local reaches infer-k8s:52789.
  • TLS. The daemons terminate TLS themselves (binding.tls.mode: files, ECDSA P-256), which keeps mutual TLS and forward_env. Headscale v0.29 cannot provision tailscale serve certificates (hscontrol: implement tailscale cert and HTTPS serve juanfont/headscale#3554 is on its main branch only). The README covers tailscale serve as the Tailscale-only option without forward_env.
  • Tailscale. task up TAILNET=tailscale runs the same chain on your own Tailscale account, with your machine as infer-local on its Tailscale app. The choice is recorded in .state/, so later tasks need no flag. What changes:
    • Each cluster node gets its own auth key, minted through the Tailscale API from an OAuth client: tagged, ephemeral, reusable and pre-approved. The client carries only tag:infer-demo, which owns the node tags, because a client holding several tags is refused a key with just one of them.
    • Names become <node>.<tailnet>.ts.net, read from the Tailscale app. The manifests are rendered with sed, and the Headscale default is the identity.
    • infer-local is infer built from this checkout, with HOME under .state/ and its binding on loopback 52790, so your own ~/.infer and daemon stay untouched. local:up starts its daemon and waits until infer-k8s is reachable.
    • gateway:real and cleanup remove the demo's old nodes through the API, and cleanup revokes the keys. They only touch ephemeral devices named infer-k8s, gateway or attacker that carry nothing but the demo's tags.
    • The tasks never write your policy file. task tailscale:policy prints tailscale/policy.hujson with your login filled in.
  • x509 on the local hop too. infer-local's own binding serves binding.tls.mode: ca, so its CLI commands authenticate with a client certificate from the daemon's CA. Loopback alone would let any local process or web page drive the daemon.
  • Shared changes. The canary is now a UDP datagram from a throwaway container beside the cluster, since Tailscale mode has no Headscale metrics port. attack reads tailnet addresses from each pod's own sidecar. The tokenless reply says "reached over the tailnet".

The docs changes:

  • docs/examples.md lists the example.
  • docs/daemon.md "Daemons on other machines" links it, and mentions the Tailscale mode.

Closes #1665
Closes #1675

Test plan

  • Headscale, from scratch: task up workspaces sniff:start demo secret:check sniff:report attack tailnet:status teleport:back cleanup
    • tokenless answered over both mTLS hops, and DEMO_SECRET hashes match with the value in no pod spec.
    • The capture holds only WireGuard (495 packets on UDP 41641): 0 on 52789 and 8443, no secret and no reply, but the canary is there.
    • The attacker gets NXDOMAIN for both names, a timeout on the tailnet addresses, a refused connection on the pod addresses, and no peers.
    • Both hops fail with certificate required without the client certificate, and infer-local cannot resolve the gateway.
    • infer-k8s reaches both neighbours direct, the gateway at its own pod address, and the teleport back works.
  • Tailscale, from scratch on a free-plan tailnet: task up TAILNET=tailscale workspaces sniff:start demo secret:check sniff:report attack tailnet:status teleport:back cleanup
    • Three auth keys minted through the API, and infer-k8s, gateway and attacker online in the tailnet with their tags.
    • The Mac's daemon reaches infer-k8s.<tailnet>.ts.net directly, the turn goes through the gateway, and the DEMO_SECRET hashes match.
    • The capture holds 642 WireGuard packets, 0 on 52789 and 8443, no secret, no reply.
    • The attacker gets the same results as with Headscale. That tailnet's own grant lets the Mac reach the gateway, and mTLS refuses it.
    • cleanup leaves no demo node in the tailnet, no cluster, no containers, no daemon and no .state/.
  • task gateway:real PROVIDER=ollama_cloud MODEL=ollama_cloud/glm-5.3-flash on Headscale (twice) and on Tailscale
    • The Gateway pod joins as gateway through its spec.pod.containers sidecar, also after the earlier one is deleted.
    • task demo gets a real answer each time.
    • The provider key, the OAuth client secret and any tskey- appear 0 times in the task output.
  • task precommit:run

… over a self-hosted Headscale tailnet

The Headscale twin of kubernetes-session-teleport-netbird: infer-local, infer-k8s and the gateway are tailnet nodes
with tagged, ephemeral, reusable pre-auth keys, admitted hop by hop by two ACLs and running mutual TLS. Headscale
serves HTTPS from the demo CA and runs its embedded DERP and STUN, so no traffic uses a public relay.

The operator's Gateway cannot take a tailscale sidecar yet (inference-gateway/operator#316), so the gateway node is a
tailscale proxy that forwards TCP 8443 to the Service of tokenless or of the operator's Gateway, with TLS end to end.

Closes #1665
@edenreich
edenreich requested a review from a team as a code owner November 1, 2026 20:10
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 1, 2026
…th operator v0.32.0

Operator v0.32.0 takes sidecar containers and volumes in spec.pod, so the
Gateway joins the tailnet itself and the standalone tailscale proxy pod is
gone. tokenless carries the same sidecar in its Deployment, and the
NetworkPolicy gateway-wireguard-only admits only WireGuard to the gateway's
pods.

- operator:install pins v0.32.0 and applies server-side, since the CRDs
  outgrew a client-side apply.
- gateway:real deletes the earlier Gateway and infer-k8s and their offline
  nodes first, so the new pods get the plain names.
- gateway:real and local:up wait until infer-local reaches infer-k8s:52789.

Closes #1675
edenreich added a commit that referenced this pull request Nov 1, 2026
…es (#1676)

## Summary

An enabled daemon binding with neither a token nor TLS client
certificates uses this machine's local token,
`~/.infer/daemon/binding.token`, as `docs/daemon.md` describes. The
daemon and the `chat --daemon` TUI filled it in, but `LocalDialConfig`
did not. So on a machine without `infer init`, which seeds
`browser_use`'s fallback token, every `infer daemon` client command
(`workspaces`, `teleport`, `run`, `stop`) was refused with
`ErrNoBinding` while the daemon was up and listening.

`LocalDialConfig` now fills the local token first, so every local client
agrees with the daemon on it. `ErrNoBinding` is left for a binding that
is off, and its message says only that.

Found while testing the Tailscale mode of the session teleport example
(#1674), where infer-local runs on the host with its own `HOME`.

## Test plan

- [x] `TestLocalDialConfigDialsWithTheBindingsCredentials`: an enabled
binding with no token and no client certificates now dials with the
local token the daemon reads, instead of failing with `ErrNoBinding`
- [x] `go test ./internal/daemon/ ./cmd/daemon/
./internal/presentation/tui/daemonthread/ ./internal/tools/ ./cmd/chat/`
- [x] By hand, in a fresh `HOME` without `infer init` and a
`daemon.yaml` with only `binding.enabled` and a port: `infer daemon`,
then `infer daemon workspaces` lists the workspaces (refused before)
- [x] `task precommit:run`
…nt with TAILNET=tailscale

TAILNET=tailscale runs the same chain on your Tailscale tailnet, with your
own machine as infer-local on its Tailscale app. Headscale stays the default.

- tailscale:keys mints one tagged, ephemeral, reusable, pre-approved auth key
  per cluster node through the Tailscale API, from an OAuth client whose tag
  tag:infer-demo owns the node tags.
- The manifests are rendered with the tailnet's DNS name and control URL.
- infer-local runs infer built from this checkout under its own HOME, with a
  daemon that local:up starts and local:down stops.
- gateway:real and cleanup remove the demo's old nodes through the API, and
  cleanup revokes the keys. The tasks never write your policy file.
- infer-local's own binding serves tls.mode ca, so its commands authenticate
  with x509 too.
- The canary is a UDP datagram from a container beside the cluster, and
  attack reads tailnet addresses from each pod's own sidecar, so neither
  needs Headscale.
@edenreich
edenreich merged commit 9a6926b into main Nov 1, 2026
1 check passed
@edenreich
edenreich deleted the docs/kubernetes-session-teleport-headscale branch November 1, 2026 23:37
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.240.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 1, 2026
@edenreich edenreich moved this from Todo to Done in 2026 Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

1 participant