Beta. The CRDs are v1, but until 1.0 a change that cannot be additive is named in the changelog. What that means.
Flags
| Flag | Default | |
|---|---|---|
--broker | tcp://localhost:1883 | tcp:// or mqtt://; mqtts://, ssl:// or tls:// for TLS. Credentials in the URL are refused. |
--broker-username | $KUBEASSISTANT_BROKER_USERNAME | Username for both connections. |
--broker-password-file | File holding the password, read on every connect, so a rotated Secret mounted as a volume applies at the next reconnect. | |
--broker-ca-file | PEM CAs to trust for a TLS broker, besides the system's. | |
--client-id | kubeassistant | The read connection is <client-id>-reader. |
--discovery-prefix | homeassistant | |
--leader-elect | false (true in the manifest) | One replica leads; only it connects to the broker. |
--leader-election-namespace | the pod's | Needed when running outside a cluster with --leader-elect. |
--sweep-settle, --sweep-allow-empty | 3s, false | The orphan sweep, below. |
--metrics-bind-address, --health-probe-bind-address | :8080, :8081 | /healthz and /readyz are on the probe address. |
--ha-url, --ha-token-file, --ha-control, --ha-sync-interval | unset, unset, false, 5s | Mirroring; it runs only when --ha-url is set, and on the leader only. |
The password can also come from $KUBEASSISTANT_BROKER_PASSWORD, which is how the shipped Deployment passes the Secret; giving both sources is an error. There is no flag for the password itself, because a flag's value is visible in the pod spec and the process list. An environment variable is read at start, so a rotated Secret needs a restart; mount the Secret as a volume and use --broker-password-file if it should not.
TLS
A mqtts:// broker with a publicly trusted certificate needs nothing more. For a private CA, mount the CA bundle and pass --broker-ca-file. homeassistant-go v1.0.0 takes no TLS configuration, so the operator adds the file to the process's system trust store (SSL_CERT_FILE) before connecting, and both connections trust exactly the same authorities. Client certificates (mutual TLS) are not supported yet (see the roadmap).
Leader election
With --leader-elect, replicas compete for the Lease kubeassistant.taumatix.dev in the operator's namespace. Only the leader connects to the broker, publishes, takes commands and sweeps. A standby holds no connection, so it cannot publish online or offline over the leader, and has no Last Will to fire if it dies. On a clean stop the leader reports offline, disconnects, then releases the Lease, and a standby takes over at once and reports online. If the leader is killed, the broker publishes its Last Will (offline) and a standby takes over once the Lease expires (15 seconds by default).
The orphan sweep
At startup the orphan sweep clears retained discovery configs that kubeassistant published and that no binding's status.devices accounts for. It refuses to run when no bindings exist at all, which usually means an unsynced cache; --sweep-allow-empty says the cluster really is empty.
Broker access
The operator holds two broker connections: it publishes as <client-id> and subscribes as <client-id>-reader, both with the same credentials, so a broker access list has to admit both. homeassistant-go drops the oldest message when a subscription's queue of 256 is full, which a burst of retained configs fills on a small CPU limit; the subscribing connection holds messages back instead. Commands arrive on kubeassistant/+/+/set and kubeassistant/+/+/+/set.
Everything published is retained on the broker. When the publishing connection drops without a clean disconnect, the broker publishes the operator's Last Will and Home Assistant shows every entity unavailable; when it comes back, the operator reports itself online and republishes every binding's configs, states and availability, so a broker restarted without persistence is repopulated.