Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aed108a781 |
No files matched your search
@@ -1,262 +0,0 @@
|
||||
# How can Home Assistant consume jobs from an external system?
|
||||
|
||||
Research for Gitea issue #47 (part of map #44). Researched 2026-11-23 against
|
||||
current Home Assistant (HA) docs, HA core source (`dev` branch), and RabbitMQ 4.x
|
||||
docs.
|
||||
|
||||
**Question:** What mechanisms does HA offer for receiving or pulling commands
|
||||
from an external system (hAPI in the cloud)? For each one: which side opens the
|
||||
connection, how it authenticates, how reliable it is and how results get
|
||||
acknowledged, and how much maintenance it needs.
|
||||
|
||||
## TL;DR
|
||||
|
||||
- **HA has no AMQP or RabbitMQ integration.** Neither `/integrations/amqp/` nor
|
||||
`/integrations/rabbitmq/` exists, and HA core has no such component. HA's
|
||||
only built-in message-bus client is MQTT.
|
||||
- **The HA MQTT docs say RabbitMQ's MQTT plugin is not supported:**
|
||||
"Neither ActiveMQ MQTT broker nor the RabbitMQ MQTT Plugin are supported, use
|
||||
a known working broker like Mosquitto instead."
|
||||
([HA MQTT](https://www.home-assistant.io/integrations/mqtt/)). Using RabbitMQ
|
||||
as the broker would mean running HA on a configuration it does not support.
|
||||
- **HA's MQTT client always connects with a clean session.** It sets
|
||||
`clean_start=True` on MQTT 5 and `clean_session=True` on 3.1.1
|
||||
([core `mqtt/client.py`](https://github.com/home-assistant/core/blob/dev/homeassistant/components/mqtt/client.py)).
|
||||
So any job published while HA is disconnected is dropped unless it is
|
||||
retained. A broker cannot queue jobs for HA while it is offline, whichever
|
||||
broker is used. MQTT QoS 1 only covers delivery on a live connection.
|
||||
- **None of the built-in options acknowledge at the job level.** For durable
|
||||
jobs, hAPI has to provide the durability: keep a job table in Postgres, and
|
||||
have HA report each result back to hAPI, either by calling hAPI or by
|
||||
returning it on the same call.
|
||||
- **Candidates by direction of connection:**
|
||||
- *HA opens the connection* (no inbound path to the home network needed):
|
||||
MQTT to a broker run by hAPI; REST polling of hAPI plus `rest_command`
|
||||
callbacks; or a custom integration.
|
||||
- *hAPI opens the connection* (needs the private link from #46, or Nabu Casa
|
||||
for webhooks): the WebSocket API, the REST API, or a webhook trigger.
|
||||
|
||||
## Mechanism by mechanism
|
||||
|
||||
### 1. MQTT integration (HA connects out to a broker)
|
||||
|
||||
- **Direction:** HA is the MQTT client. You give it the broker's "hostname
|
||||
(or IP address) and port"
|
||||
([HA MQTT](https://www.home-assistant.io/integrations/mqtt/)). If the broker
|
||||
runs in the cluster, HA connects outbound, so nothing has to accept inbound
|
||||
connections at home.
|
||||
- **Protocol:** "Home Assistant requires that your broker supports MQTT protocol
|
||||
version 5" (same page). Core supports 3.1, 3.1.1, and 5, and defaults to 5
|
||||
(`DEFAULT_PROTOCOL = PROTOCOL_5` in
|
||||
[`mqtt/const.py`](https://github.com/home-assistant/core/blob/dev/homeassistant/components/mqtt/const.py)).
|
||||
- **Auth:** username and password; broker certificate validation (Auto, or
|
||||
Custom with an uploaded CA); and an optional client certificate plus private
|
||||
key for mutual TLS. WebSockets transport is also available, with custom
|
||||
headers. Source: [HA MQTT](https://www.home-assistant.io/integrations/mqtt/).
|
||||
- **Receiving jobs:** the `mqtt` automation trigger fires "when a message is
|
||||
received on an MQTT topic". It has a `qos` option (0, 1, or 2; default 0), and
|
||||
JSON payloads are exposed as `trigger.payload_json`
|
||||
([MQTT trigger](https://www.home-assistant.io/triggers/mqtt/)).
|
||||
- **Returning results:** the `mqtt.publish` action, with `retain` and a
|
||||
templated payload ([HA MQTT](https://www.home-assistant.io/integrations/mqtt/)).
|
||||
A typical setup has HA publish to `hapi/results/<job_id>` or a single results
|
||||
topic.
|
||||
- **Reliability:**
|
||||
- *Clean sessions.* Session data is cleared on every connect (see TL;DR),
|
||||
so the broker does not queue jobs for HA across disconnects. A retained
|
||||
message survives, but the broker keeps only one per topic, which makes it
|
||||
the wrong tool for a queue.
|
||||
- *QoS.* QoS 1 gives at-least-once delivery while HA is connected. Duplicates
|
||||
are possible, so job handlers should be idempotent (key them on `job_id`).
|
||||
- *No job-level ack.* MQTT has no acknowledgement for "the job ran"; HA has to
|
||||
publish a result message for that.
|
||||
- *Liveness.* HA publishes a Birth message (`online`) and a Last Will message
|
||||
(`offline`) on `homeassistant/status`
|
||||
([HA MQTT](https://www.home-assistant.io/integrations/mqtt/)). hAPI can
|
||||
subscribe to know whether HA is connected and hold or fail jobs to match.
|
||||
- **Maintenance:** low on the HA side, since this is a first-class, actively
|
||||
maintained integration. On the cluster side, it means running and securing a
|
||||
broker (for example Mosquitto) with TLS and per-client credentials. The job
|
||||
automations are YAML or UI automations in HA.
|
||||
|
||||
### 1a. RabbitMQ's MQTT plugin as that broker
|
||||
|
||||
- **What RabbitMQ supports:** MQTT 3.1, 3.1.1, and 5.0. QoS 0 and 1 are
|
||||
supported, but QoS 2 is not. An MQTT 5 client that publishes at QoS 2 is
|
||||
disconnected with "reason code `155: QoS not supported`"; 3.x clients are
|
||||
downgraded to QoS 1. MQTT topics are routed through the `amq.topic` exchange,
|
||||
with `/` mapped to `.` and `+` mapped to `*`, so AMQP 0-9-1, AMQP 1.0, and
|
||||
STOMP clients can talk to MQTT clients. Auth options are username and
|
||||
password, or x.509 client certificates via `ssl_cert_login`
|
||||
([RabbitMQ MQTT](https://www.rabbitmq.com/docs/mqtt)).
|
||||
- **Retained-message caveats:** retained messages are stored node-local and not
|
||||
replicated, and "subscriptions using wildcard filters receive no retained
|
||||
messages" (same page).
|
||||
- **HA's position:** HA marks the plugin as not supported (quoted in the
|
||||
TL;DR). The HA page gives a reason only for ActiveMQ (retention bugs).
|
||||
*Inference:* the RabbitMQ wildcard limitation is probably the reason, because
|
||||
HA's MQTT discovery subscribes with wildcards and depends on retained config
|
||||
messages. hAPI jobs on fixed topics with no discovery might work, but nobody
|
||||
would support or test that setup, and the clean-session limit still applies.
|
||||
- **What RabbitMQ would add:** hAPI could use AMQP queues on the cloud side for
|
||||
its own durability and routing, bridging to HA over MQTT. That adds little
|
||||
over a Postgres job table plus Mosquitto, and it costs running RabbitMQ
|
||||
itself.
|
||||
|
||||
### 2. AMQP
|
||||
|
||||
- **No built-in integration.** HA's docs have no AMQP or RabbitMQ page (both
|
||||
URLs return 404), and HA core has no `amqp` or `rabbitmq` component (checked
|
||||
against the GitHub contents API for `homeassistant/components`).
|
||||
- **Only route:** a custom integration that embeds an AMQP client (see section
|
||||
6). The custom integration would own every reliability property: durable
|
||||
queues, manual acks after the HA action completes, and reconnects.
|
||||
|
||||
### 3. REST API (hAPI calls HA)
|
||||
|
||||
- **Direction:** inbound to HA at `/api/...`, so it needs the private link
|
||||
(#46) or some exposure of HA.
|
||||
- **Auth:** `Authorization: Bearer <long-lived access token>`
|
||||
([REST API](https://contributors.home-assistant.io/core/internals/rest-api/)).
|
||||
Long-lived tokens are "valid for 10 years" and act as the user who created
|
||||
them ([Auth API](https://contributors.home-assistant.io/core/internals/auth-api/)).
|
||||
The docs describe no way to scope a token, so it should be created for a
|
||||
dedicated, non-admin HA user. Some endpoints, such as firing events, are
|
||||
marked Admin.
|
||||
- **Semantics:** `POST /api/services/<domain>/<service>` "calls an action and
|
||||
waits until it is done". It returns the changed states, plus a
|
||||
`service_response` with `?return_response` for actions that produce data. A
|
||||
failing action returns 500, and every endpoint returns 503 during shutdown.
|
||||
This makes the call a synchronous request and result, so the HTTP response
|
||||
serves as the ack. hAPI retries on timeout or 5xx, which means actions must
|
||||
be idempotent.
|
||||
- **Maintenance:** none on the HA side. hAPI needs an HTTP client and a token
|
||||
secret.
|
||||
|
||||
### 4. WebSocket API (hAPI holds a socket open to HA)
|
||||
|
||||
- **Direction:** inbound to HA at `/api/websocket`
|
||||
([WebSocket API](https://contributors.home-assistant.io/core/internals/websocket-api/)).
|
||||
- **Auth:** the server sends `auth_required`, the client replies with `auth`
|
||||
containing an `access_token`, and the server answers `auth_ok` or
|
||||
`auth_invalid`. A long-lived token works.
|
||||
- **Semantics:**
|
||||
- *Commands.* Each command gets a `result` with the same `id`, carrying
|
||||
`success` true or false and an `error` with a `code`. `call_service`
|
||||
accepts `return_response: true`.
|
||||
- *Subscriptions.* `subscribe_events` and `subscribe_trigger` (Admin) let hAPI
|
||||
receive HA state changes and events in real time.
|
||||
- *Liveness.* `ping` and `pong` work as a heartbeat.
|
||||
- **Reliability:** each request gets a result on a live connection. If the
|
||||
connection drops, in-flight commands have unknown outcomes and hAPI must
|
||||
reconcile them.
|
||||
- **Maintenance:** a long-lived connection with reconnect logic in hAPI (one
|
||||
pod, or leader election). It is the richest option if hAPI also needs HA state
|
||||
for the Smart home domain.
|
||||
|
||||
### 5. Webhook trigger (hAPI calls HA)
|
||||
|
||||
- **Direction:** inbound. `local_only` defaults to true, so only the home
|
||||
network is accepted. With Home Assistant Cloud (Nabu Casa) "a webhook gets a
|
||||
public address", but only when local-only is off
|
||||
([Webhook trigger](https://www.home-assistant.io/triggers/webhook/)).
|
||||
- **Auth:** none beyond the ID: "A webhook doesn't need a password or a token."
|
||||
The docs say not to use webhooks for destructive or safety-critical actions,
|
||||
and give unlocking a door as an example.
|
||||
- **Semantics:** fire-and-forget. HA "almost always returns `200 OK`" so that
|
||||
webhook IDs can't be discovered, which means hAPI learns nothing about the
|
||||
outcome. Results have to come back through a separate channel, such as a
|
||||
`rest_command` to hAPI. Payloads are available as `trigger.json`,
|
||||
`trigger.data`, and `trigger.query`.
|
||||
- **Fit:** poor for hAPI given the "assume hostile internet" stance. A bearer ID
|
||||
with no per-call result is weaker than the REST or WebSocket APIs on the same
|
||||
network path.
|
||||
|
||||
### 6. REST polling plus `rest_command` (HA pulls from hAPI)
|
||||
|
||||
- **Direction:** HA opens every connection, so nothing inbound is needed at
|
||||
home.
|
||||
- **Pulling jobs:** the RESTful integration polls an endpoint every
|
||||
`scan_interval`, 30 s by default. It supports `basic` or `digest` auth, custom
|
||||
`headers` (so a bearer token works), and `verify_ssl`. JSON fields are exposed
|
||||
via `json_attributes`
|
||||
([RESTful](https://www.home-assistant.io/integrations/rest/)).
|
||||
- **Reporting results:** an automation that reacts to a state change does the
|
||||
job and then calls a `rest_command` to POST the result to hAPI.
|
||||
`rest_command` supports GET, PATCH, POST, PUT, and DELETE, a 10 s default
|
||||
timeout, and returns `status`, `content`, and `headers` through
|
||||
`response_variable`
|
||||
([RESTful Command](https://www.home-assistant.io/integrations/rest_command/)).
|
||||
- **Reliability:** latency equals the polling interval. A job queue built from
|
||||
sensor state and YAML templates is awkward, though acks are explicit because
|
||||
HA POSTs the result.
|
||||
- **Maintenance:** low infrastructure, but the job logic is spread across YAML
|
||||
that is hard to test.
|
||||
|
||||
### 7. Custom integration (`custom_components`)
|
||||
|
||||
- **What it is:** a Python package in `config/custom_components/<domain>/`
|
||||
whose `manifest.json` requires a `version` key for custom integrations
|
||||
([Integration manifest](https://developers.home-assistant.io/docs/creating_integration_manifest/)).
|
||||
It can run any client: an AMQP consumer, MQTT with a persistent session, a
|
||||
long-poll or SSE loop against hAPI, or an outbound WebSocket to hAPI. It
|
||||
calls HA actions directly and acks the job only after the action finishes.
|
||||
That makes it the only option where HA initiates the connection and still
|
||||
gets true at-least-once delivery with an explicit ack.
|
||||
- **Distribution changed in 2026.11:** "The Marketplace replaces the Home
|
||||
Assistant Community Store (HACS)". Custom repositories must be "a public
|
||||
repository on GitHub"
|
||||
([Marketplace](https://www.home-assistant.io/integrations/marketplace/)). A
|
||||
private integration hosted on the Owner's Gitea therefore cannot be installed
|
||||
or updated through the Marketplace; it would be copied into
|
||||
`custom_components` by hand or by a script.
|
||||
- **Maintenance:** highest. Changes to what custom integrations use from core
|
||||
are "deprecated for 12 months first", but the integration still has to keep
|
||||
up with HA releases; HA says to test against the beta
|
||||
([Publish a custom integration](https://contributors.home-assistant.io/marketplace/guides/integrations/)).
|
||||
|
||||
## Comparison
|
||||
|
||||
| Mechanism | Connection opened by | Auth | Job ack / result | Survives HA offline? | Upkeep |
|
||||
|---|---|---|---|---|---|
|
||||
| MQTT (Mosquitto in cluster) | HA (outbound) | user/pass, mTLS | HA publishes result message | No (clean session); hAPI must re-send | Low (plus broker) |
|
||||
| MQTT via RabbitMQ plugin | HA (outbound) | user/pass, x.509 | same | No | Unsupported by HA |
|
||||
| AMQP | n/a (no integration) | n/a | n/a | n/a | Needs custom integration |
|
||||
| REST API | hAPI (inbound) | Bearer long-lived token | Synchronous HTTP result | hAPI retries | Very low |
|
||||
| WebSocket API | hAPI (inbound) | access token in `auth` msg | `result` per `id` | hAPI reconnects and reconciles | Medium |
|
||||
| Webhook | hAPI (inbound) | secret ID only | None (always 200) | No | Low, weak security |
|
||||
| REST poll + `rest_command` | HA (outbound) | basic/digest/header token | HA POSTs result | Yes (job waits in hAPI) | Low infra, clunky YAML |
|
||||
| Custom integration | Either | anything | Explicit ack after action | Yes, if designed for it | High; no Marketplace for a Gitea repo |
|
||||
|
||||
## Implications for #55 (which bridge carries jobs)
|
||||
|
||||
- **Durability belongs in hAPI.** In every option, durability is cheapest as a
|
||||
hAPI-owned job table in Postgres (pending, sent, done, failed) with retry
|
||||
and idempotency keys. The transport only needs at-least-once delivery while
|
||||
connected and a result path back.
|
||||
- **If the private link (#46) exists:** calling HA's REST or WebSocket API from
|
||||
hAPI is the simplest path. It needs no broker and no HA-side code, and gives a
|
||||
synchronous result. HA would appear to hAPI as an external system that hAPI
|
||||
calls with a long-lived token belonging to a dedicated HA user.
|
||||
- **If HA must initiate:** MQTT to Mosquitto in the cluster is the supported
|
||||
path, with hAPI re-sending unacked jobs when it sees `online` on
|
||||
`homeassistant/status`. RabbitMQ is only worth it if hAPI wants AMQP for its
|
||||
own internal reasons, and its MQTT plugin is unsupported by HA.
|
||||
- **For HA to call hAPI** (to report results, or to poll), HA needs a hAPI
|
||||
credential. In GLOSSARY terms that makes it a **Bot** Principal.
|
||||
|
||||
## Sources
|
||||
|
||||
- HA MQTT integration: https://www.home-assistant.io/integrations/mqtt/
|
||||
- HA MQTT trigger: https://www.home-assistant.io/triggers/mqtt/
|
||||
- HA core MQTT client source: https://github.com/home-assistant/core/blob/dev/homeassistant/components/mqtt/client.py and `const.py`
|
||||
- RabbitMQ MQTT plugin: https://www.rabbitmq.com/docs/mqtt
|
||||
- HA REST API: https://contributors.home-assistant.io/core/internals/rest-api/
|
||||
- HA WebSocket API: https://contributors.home-assistant.io/core/internals/websocket-api/
|
||||
- HA Auth API: https://contributors.home-assistant.io/core/internals/auth-api/
|
||||
- HA Webhook trigger: https://www.home-assistant.io/triggers/webhook/
|
||||
- HA RESTful: https://www.home-assistant.io/integrations/rest/
|
||||
- HA RESTful Command: https://www.home-assistant.io/integrations/rest_command/
|
||||
- HA integration manifest: https://developers.home-assistant.io/docs/creating_integration_manifest/
|
||||
- HA Marketplace: https://www.home-assistant.io/integrations/marketplace/
|
||||
- Publishing a custom integration: https://contributors.home-assistant.io/marketplace/guides/integrations/
|
||||
@@ -0,0 +1,302 @@
|
||||
# Private connectivity between the home network and a Linode cluster
|
||||
|
||||
Research for Gitea issue #46 (part of map #44). Researched 2026-11-23.
|
||||
|
||||
## Question
|
||||
|
||||
What are the options for a private, authenticated link between the Owner's home
|
||||
network (Home Assistant, LAN Bots) and a self-managed Kubernetes cluster on
|
||||
Linode? Compare Tailscale (incl. the Kubernetes operator / subnet routers),
|
||||
Headscale, plain WireGuard site-to-site, and Linode VPC features: setup,
|
||||
security model, failure modes, how in-cluster Services are exposed over the
|
||||
link, and cost.
|
||||
|
||||
## TL;DR
|
||||
|
||||
- **Linode VPC can't do this.** It is a single-data-center private network
|
||||
with no VPN/on-prem attachment, no peering, and **no encryption**. Akamai
|
||||
has no managed site-to-site VPN product. VPC only matters for
|
||||
traffic inside the cluster. [VPC][akamai-vpc]
|
||||
- **Tailscale + the Kubernetes operator is the lowest-effort fit.** You can
|
||||
expose a Bot-facing Service to the tailnet with one annotation. Home Assistant
|
||||
joins via the community add-on, which can also act as a subnet router for
|
||||
other LAN Bots. Grants are deny-by-default, so you can limit LAN Bots
|
||||
to the Bot-facing Service only. The free Personal plan covers this load.
|
||||
- **Surprise: Tailnet Lock does not work with the operator.** Tailnet Lock is
|
||||
Tailscale's defense against a compromised coordination server, and the
|
||||
operator can't sign the proxy nodes it creates. The feature request is
|
||||
still open. So with the operator you have to trust Tailscale's control plane.
|
||||
[#13273][ts-13273]
|
||||
- **Headscale removes that third-party trust, but it isn't ready yet for the
|
||||
operator path.** Operator compatibility (OAuth clients on a v2 API) was
|
||||
merged in June 2026 for v0.30.0, but the latest release is still v0.29.7. You'd
|
||||
also have to host and secure the control server yourself.
|
||||
[#3334][hs-3334] [releases][hs-releases]
|
||||
- **Plain WireGuard has the smallest and most auditable surface**: a silent
|
||||
UDP port and static keys. But you do all key management, routing into the
|
||||
cluster, and HA by hand.
|
||||
|
||||
**Tentative recommendation** (a decision for the Owner, not made here):
|
||||
Tailscale with the operator, an L3 `tailscale` Service for the Bot-facing
|
||||
listener, tagged nodes, and a tight grants policy with `tests`. Keep the
|
||||
Bot-facing listener off the public Ingress entirely. If the Owner wants
|
||||
no third-party control plane, choose plain WireGuard (a single gateway now)
|
||||
or wait for Headscale v0.30.0.
|
||||
|
||||
## Options compared
|
||||
|
||||
| | Tailscale (SaaS) + operator | Headscale + Tailscale clients | Plain WireGuard | Linode VPC |
|
||||
|---|---|---|---|---|
|
||||
| Reaches home LAN? | Yes | Yes | Yes | **No** |
|
||||
| Encryption | WireGuard, keys never leave devices | Same | WireGuard | **None** (isolation only) |
|
||||
| Control plane | Tailscale-hosted | Self-hosted | None (static config) | n/a |
|
||||
| Inbound ports on cluster | None required (DERP relay fallback) | Control server must be reachable, and its DERP if embedded | One UDP port | n/a |
|
||||
| Expose k8s Service | Annotation / `loadBalancerClass: tailscale` / Ingress class | Same operator, **only once v0.30.0 ships** | DIY routing | n/a |
|
||||
| Access control | Grants/ACLs, deny-by-default, policy tests | ACLs/Grants supported | Cryptokey routing + your firewall rules | Cloud Firewall |
|
||||
| Cost | $0 (Personal: 6 users, 50 tagged resources) | $0 + hosting a server | $0 | $0 |
|
||||
|
||||
## Linode VPC and Cloud Firewall
|
||||
|
||||
- VPCs connect Linodes **within one data center**. They can't span data
|
||||
centers, and VPC peering isn't supported. [VPC][akamai-vpc]
|
||||
- "Traffic is isolated but not encrypted." There's no IPv6 on VPC interfaces.
|
||||
VPCs have no extra charge. [VPC][akamai-vpc]
|
||||
- The docs mention no VPN or on-prem attachment. I found no official Akamai
|
||||
site-to-site VPN product. The only guidance for on-prem links is community
|
||||
posts about running your own IPsec/strongSwan gateway on a Linode
|
||||
([community 21930][linode-c-21930]; low trust, used only to show that
|
||||
nothing first-party exists).
|
||||
- Cloud Firewall is stateful and free. It covers Linodes and NodeBalancers and
|
||||
allows max 25 rules per firewall. Rules apply to public and private traffic.
|
||||
For NodeBalancers, rules cover only the public IP, so backends need their own
|
||||
firewall. [Cloud Firewall][akamai-fw]
|
||||
|
||||
**Verdict:** VPC is useful for node-to-node traffic inside the cluster. It
|
||||
plays no part in the home link. Cloud Firewall is complementary: with WireGuard,
|
||||
it limits the UDP port to the home public IP (if that IP is stable).
|
||||
|
||||
## Tailscale (SaaS) with the Kubernetes operator
|
||||
|
||||
### Setup
|
||||
|
||||
- The operator is available on all plans. It covers ingress (tailnet → cluster
|
||||
workloads), egress (cluster → tailnet devices), API-server proxy, and
|
||||
subnet routers/exit nodes via a `Connector` resource.
|
||||
[operator][ts-operator]
|
||||
- Prerequisites: in the policy file, set `tagOwners` with
|
||||
`"tag:k8s-operator": ["autogroup:admin"]` and
|
||||
`"tag:k8s": ["tag:k8s-operator"]`. Create an OAuth client with read/write on
|
||||
Services, Devices Core, and Auth Keys, tagged `tag:k8s-operator`. The operator
|
||||
stores the credentials in the `operator-oauth` secret in the `tailscale`
|
||||
namespace. [quickstart][ts-quickstart]
|
||||
- If you want non-default proxy tags (e.g. `tag:hapi-bot`), `tag:k8s-operator`
|
||||
must own them, and the OAuth client must be allowed to use them. There's
|
||||
a known startup failure with multiple `defaultTags`
|
||||
([issue #15732][ts-15732]).
|
||||
|
||||
### Exposing in-cluster Services over the link
|
||||
|
||||
From [cluster ingress][ts-ingress]:
|
||||
|
||||
- **L3 (TCP/UDP):** annotate the Service with `tailscale.com/expose: "true"`, *or*
|
||||
set `type: LoadBalancer` + `loadBalancerClass: tailscale`. A proxy Pod DNATs
|
||||
its tailnet IP to the Service's ClusterIP.
|
||||
- **L7 (HTTP/S):** use `Ingress` with `ingressClassName: tailscale`. You get a
|
||||
MagicDNS name and a Let's Encrypt cert through Tailscale Serve.
|
||||
- These are **not public** by default. Public needs Funnel, which you should
|
||||
avoid for the Bot side.
|
||||
- HA: a `ProxyGroup` (`tailscale.com/proxy-group` annotation) runs multiple
|
||||
active proxies. Tailscale recommends it for production.
|
||||
|
||||
So a Bot-facing hAPI listener can be its own Service, reachable *only* via
|
||||
the tailnet. Persons hit the public Ingress, which never routes to it.
|
||||
|
||||
### Home side
|
||||
|
||||
- **Home Assistant:** the community add-on supports `advertise_routes`
|
||||
(subnet router), `accept_routes`, `advertise_tags`, `login_server` (custom
|
||||
control server, e.g. Headscale), and `userspace_networking`.
|
||||
[addon-tailscale docs][ha-addon]
|
||||
- **Other LAN Bots** that can't run Tailscale go through a subnet router (the
|
||||
HA add-on, or another always-on box). Devices behind a subnet router don't
|
||||
count toward the device limit. SNAT is on by default, so cluster-side traffic
|
||||
appears to come from the router, which loses per-Bot source IPs unless you set
|
||||
`--snat-subnet-routes=false` (Linux only, needs return routes for
|
||||
`100.64.0.0/10`). Route approval is separate from access: you need grants
|
||||
too. [subnet routers][ts-subnets]
|
||||
- Tailscale prefers installing the client directly on each device over
|
||||
subnet routing. [subnet routers][ts-subnets]
|
||||
|
||||
### Security model
|
||||
|
||||
- Data plane: WireGuard. Private keys never leave the device. DERP relays
|
||||
forward already-encrypted traffic they can't decrypt. Connections are usually
|
||||
direct, with peer relays and then DERP as fallback. [DERP][ts-derp]
|
||||
- Policy: deny-by-default grants (`src`/`dst`/`ip`). A `tests` section
|
||||
rejects policy updates that break assertions. Example intent: `src:
|
||||
["tag:home-bot"]`, `dst: ["tag:hapi-bot:443"]`. [policy syntax][ts-policy]
|
||||
- **Trust in the control plane:** Tailscale's coordination server distributes
|
||||
node keys, so a compromised control plane could inject nodes. Tailnet Lock
|
||||
closes that gap: nodes must be signed by trusted keys held on your devices.
|
||||
It's available on Personal. [Tailnet Lock][ts-lock]
|
||||
- **But the operator can't add its proxies to a locked tailnet** without manual
|
||||
signing of each proxy node key. Issue #13273 and PR #14404 are still open as
|
||||
of this research. [#13273][ts-13273] This trade-off is the main thing to
|
||||
weigh: operator convenience vs. control-plane-compromise resistance. One
|
||||
workaround: skip the operator and run a single `tailscaled` gateway
|
||||
(e.g. a Deployment with persisted state, or a node-level install) whose key
|
||||
is signed once, routing to the Bot-facing Service.
|
||||
|
||||
### Failure modes
|
||||
|
||||
- Tailscale control plane outage: existing connections generally keep working,
|
||||
but new nodes/key changes stall. (General property of the design. I didn't
|
||||
find a precise first-party statement for this, so check before relying on it.)
|
||||
- Proxy Pod restart blips the link unless you use `ProxyGroup` HA. [ingress][ts-ingress]
|
||||
- A subnet router going offline drops its routes, and there's no fallback to a
|
||||
less specific route. Run two routers for HA, without `--accept-routes` on
|
||||
them. [subnet routers][ts-subnets]
|
||||
- Let's Encrypt rate limits can bite L7 Ingress on frequent redeploys.
|
||||
[ingress][ts-ingress]
|
||||
|
||||
### Cost
|
||||
|
||||
Personal plan: $0, non-commercial, up to 6 users, unlimited user devices,
|
||||
**50 tagged resources** (then $1/mo each), 3 ACL groups. Operator proxies and
|
||||
tagged gateways count as tagged resources. That's ample here. [pricing][ts-pricing]
|
||||
|
||||
## Headscale
|
||||
|
||||
- An open-source, self-hosted implementation of the Tailscale control server.
|
||||
Its scope is deliberately narrow: **a single tailnet**, for self-hosters and
|
||||
hobbyists. [headscale][hs-home]
|
||||
- Supported: ACLs, Grants, Tailscale SSH, auto approvers, subnet routers, exit
|
||||
nodes, tags, OIDC (but OIDC groups can't be used in ACLs), embedded DERP, and
|
||||
Taildrop. Funnel/Serve and Tailnet Lock aren't listed as supported.
|
||||
[features][hs-features]
|
||||
- **Operator compatibility:** the operator chart has a `loginServer` value for a
|
||||
non-Tailscale control plane ([values.yaml][ts-values]). Headscale PR #3334
|
||||
("add OAuth clients and scopes to the v2 API") was merged on 2026-06-26 and
|
||||
closed issue #1202 ("OAuth Provider + Tailscale Kubernetes operator
|
||||
compatibility") under milestone v0.30.0. [#3334][hs-3334] [#1202][hs-1202]
|
||||
**The latest release is v0.29.7, so it hasn't shipped yet.** [releases][hs-releases]
|
||||
- The HA add-on supports `login_server`, so the home side works today.
|
||||
[ha-addon][ha-addon]
|
||||
- **Security trade-off:** you remove Tailscale Inc. from the trust base, but the
|
||||
control server becomes your crown jewel. It must be reachable by home and
|
||||
cluster nodes, so it's internet-exposed somewhere. Hosting it *inside* the
|
||||
cluster it protects creates a bootstrap/circular dependency. You also own
|
||||
its patching, backups, and DERP.
|
||||
- **Cost:** software is free. Hosting is a small Linode or a cluster
|
||||
workload, plus operations time.
|
||||
|
||||
## Plain WireGuard site-to-site
|
||||
|
||||
### Security model
|
||||
|
||||
- Cryptokey routing: each peer is a public key with a list of allowed IPs. Those
|
||||
act as the routing table for outbound traffic and the ACL for inbound, so
|
||||
firewall rules on source IP + interface are trustworthy. It uses Noise,
|
||||
Curve25519, ChaCha20-Poly1305, BLAKE2, and HKDF, and the codebase is
|
||||
small enough to audit. [wireguard.com][wg-home]
|
||||
- The server "does not even *respond at all*" to unauthenticated packets. It's
|
||||
silent to scanners, with a cookie mechanism under load. Handshakes occur
|
||||
every few minutes for rotating session keys. [protocol][wg-protocol]
|
||||
- Key distribution is out of scope: you exchange public keys out of band,
|
||||
like SSH keys. [wireguard.com][wg-home]
|
||||
|
||||
### Setup and exposing Services
|
||||
|
||||
- Home side: a WireGuard peer on an always-on LAN box (or router). It
|
||||
initiates toward the cluster's public UDP endpoint, with
|
||||
`PersistentKeepalive = 25` to hold the NAT mapping (off by default).
|
||||
[quickstart][wg-quick] The cluster doesn't need to know the home IP, because
|
||||
WireGuard roams to the last authenticated endpoint. [wireguard.com][wg-home]
|
||||
- Cluster side: you do all of it yourself. Options:
|
||||
- A WireGuard interface on one node (host-level), routing the tunnel subnet
|
||||
to the Bot-facing Service's ClusterIP or a dedicated internal IP.
|
||||
- A gateway Pod with `hostNetwork` or a UDP NodePort/LoadBalancer.
|
||||
Either way you handle iptables/nftables, return routes, and which node holds
|
||||
the endpoint.
|
||||
- Lock the UDP port down with Cloud Firewall (to the home public IP if it's
|
||||
stable). [Cloud Firewall][akamai-fw]
|
||||
|
||||
### Failure modes
|
||||
|
||||
- A single gateway node is a single point of failure, and HA needs your own
|
||||
failover (e.g. floating IP + keepalived). There's no built-in relay, so a home
|
||||
network with broken outbound UDP just fails. Losing a key means editing
|
||||
configs by hand on both sides.
|
||||
|
||||
### Cost
|
||||
|
||||
$0 (in-kernel software). You pay only in operator time.
|
||||
|
||||
## How this fits hAPI
|
||||
|
||||
- **Separation of Principals by network:** Persons → public Ingress. Bots →
|
||||
a distinct Bot-facing Service exposed only on the private link. Defense in
|
||||
depth: hAPI should still authenticate Bots at the application layer (the link
|
||||
is a network control, not Principal authentication).
|
||||
- With Tailscale/Headscale, tags give a stable identity per home device or
|
||||
subnet router. With SNAT on, hAPI sees only the router's address, so per-Bot
|
||||
identity must come from app-level credentials anyway.
|
||||
|
||||
## Open questions for the Owner
|
||||
|
||||
1. Is trusting Tailscale's hosted control plane acceptable, given Tailnet
|
||||
Lock is unavailable with the operator? If not: plain WireGuard now, or
|
||||
Headscale once v0.30.0 ships.
|
||||
2. Can each LAN Bot run a Tailscale client, or do most need a subnet router
|
||||
(which loses per-device source identity unless SNAT is disabled)?
|
||||
3. Is the home public IP stable (relevant to firewalling a WireGuard port)?
|
||||
|
||||
## Sources
|
||||
|
||||
- [akamai-vpc]: https://techdocs.akamai.com/cloud-computing/docs/vpc
|
||||
- [akamai-fw]: https://techdocs.akamai.com/cloud-computing/docs/cloud-firewall
|
||||
- [linode-c-21930]: https://www.linode.com/community/questions/21930/site-to-site-vpn (community, low trust)
|
||||
- [ts-operator]: https://tailscale.com/kb/1236/kubernetes-operator
|
||||
- [ts-quickstart]: https://tailscale.com/docs/kubernetes-operator/quickstart
|
||||
- [ts-ingress]: https://tailscale.com/kb/1439/kubernetes-operator-cluster-ingress
|
||||
- [ts-15732]: https://github.com/tailscale/tailscale/issues/15732
|
||||
- [ts-values]: https://github.com/tailscale/tailscale/blob/main/cmd/k8s-operator/deploy/chart/values.yaml
|
||||
- [ts-subnets]: https://tailscale.com/kb/1019/subnets
|
||||
- [ts-derp]: https://tailscale.com/kb/1232/derp-servers
|
||||
- [ts-policy]: https://tailscale.com/kb/1337/policy-syntax
|
||||
- [ts-lock]: https://tailscale.com/kb/1226/tailnet-lock
|
||||
- [ts-13273]: https://github.com/tailscale/tailscale/issues/13273
|
||||
- [ts-pricing]: https://tailscale.com/pricing
|
||||
- [ha-addon]: https://github.com/hassio-addons/addon-tailscale/blob/main/tailscale/DOCS.md
|
||||
- [hs-home]: https://headscale.net/stable/
|
||||
- [hs-features]: https://headscale.net/stable/about/features/
|
||||
- [hs-3334]: https://github.com/juanfont/headscale/pull/3334
|
||||
- [hs-1202]: https://github.com/juanfont/headscale/issues/1202
|
||||
- [hs-releases]: https://github.com/juanfont/headscale/releases
|
||||
- [wg-home]: https://www.wireguard.com/
|
||||
- [wg-protocol]: https://www.wireguard.com/protocol/
|
||||
- [wg-quick]: https://www.wireguard.com/quickstart/
|
||||
|
||||
[akamai-vpc]: https://techdocs.akamai.com/cloud-computing/docs/vpc
|
||||
[akamai-fw]: https://techdocs.akamai.com/cloud-computing/docs/cloud-firewall
|
||||
[linode-c-21930]: https://www.linode.com/community/questions/21930/site-to-site-vpn
|
||||
[ts-operator]: https://tailscale.com/kb/1236/kubernetes-operator
|
||||
[ts-quickstart]: https://tailscale.com/docs/kubernetes-operator/quickstart
|
||||
[ts-ingress]: https://tailscale.com/kb/1439/kubernetes-operator-cluster-ingress
|
||||
[ts-15732]: https://github.com/tailscale/tailscale/issues/15732
|
||||
[ts-values]: https://github.com/tailscale/tailscale/blob/main/cmd/k8s-operator/deploy/chart/values.yaml
|
||||
[ts-subnets]: https://tailscale.com/kb/1019/subnets
|
||||
[ts-derp]: https://tailscale.com/kb/1232/derp-servers
|
||||
[ts-policy]: https://tailscale.com/kb/1337/policy-syntax
|
||||
[ts-lock]: https://tailscale.com/kb/1226/tailnet-lock
|
||||
[ts-13273]: https://github.com/tailscale/tailscale/issues/13273
|
||||
[ts-pricing]: https://tailscale.com/pricing
|
||||
[ha-addon]: https://github.com/hassio-addons/addon-tailscale/blob/main/tailscale/DOCS.md
|
||||
[hs-home]: https://headscale.net/stable/
|
||||
[hs-features]: https://headscale.net/stable/about/features/
|
||||
[hs-3334]: https://github.com/juanfont/headscale/pull/3334
|
||||
[hs-1202]: https://github.com/juanfont/headscale/issues/1202
|
||||
[hs-releases]: https://github.com/juanfont/headscale/releases
|
||||
[wg-home]: https://www.wireguard.com/
|
||||
[wg-protocol]: https://www.wireguard.com/protocol/
|
||||
[wg-quick]: https://www.wireguard.com/quickstart/
|
||||
Reference in new issue
Block a user