Operations¶
This is the runbook: it assumes you have read the README's Quick start and now want to run byre for real. Field-level detail for each backend is in backends.md, and the failure-by-failure guide is troubleshooting.md.
Deploy¶
make image-push IMAGE_REGISTRY=<registry>/<team> # builds, pushes, and records dist/images.txt
# fill the image reference in deploy/ (see below), then:
kubectl -n byre-system create secret generic byre-pool-key --from-file=id_key=/path/to/key
# On an upgrade, apply the CRD *first*, as its own step. Helm installs crds/ once and never updates
# them, so `helm upgrade` cannot carry a new status field; and a schema that lacks one does not fail
# loudly -- the API server prunes the write, the controller reads back zero, and recovery falls back
# to the instance's creation time. That is how 0.8.3 would have reaped live leases on first deploy.
kubectl apply -f deploy/crd/byreleases.yaml
kubectl apply -k deploy/
kubectl -n byre-system set image deploy/byre byre="$(sed -n 's/^IMAGE_REF=//p' dist/images.txt)"
make image-verify # digest and registry must match the running pod
kubectl -n byre-system rollout status deploy/byre
The image reference in deploy/deployment.yaml is a placeholder (<registry>/byre@sha256:<digest>),
not a working default: this project has no registry of its own, and a bare name (byre) sends kubelet to
Docker Hub for library/byre — an ImagePullBackOff that reads like a broken manifest. Fill it in either
with an overlay whose images: block names the reference exactly as written in the manifest
(kustomize matches the string literally, because sha256:<digest> is not a digest it can parse), or with
kubectl -n byre-system set image deploy/byre byre=<registry>/byre@sha256:<digest>.
Pin by digest, not by tag. A tag is a mutable pointer: the same tag can be re-pushed with different
content, and with imagePullPolicy: IfNotPresent the node keeps its cached layers, so the Deployment
reports the new tag while the process is still the old build. A digest is a content hash — if the content
changes, the value changes, and a pull cannot silently answer with something else. /healthz prints the
version compiled into the binary, which is how you tell which build is actually running.
The release page carries the digest to pin¶
Every tagged release publishes images.txt beside the binaries: IMAGE_REF is the reference a
Deployment should carry, IMAGE_DIGEST is what the registry answered for that tag when the release
was built. scripts/record-release-image.sh writes it by asking the registry (HEAD
/v2/<image>/manifests/<tag>), then fetching the manifest and hashing it, because a header is a claim
about a body and the two disagreeing means neither is safe to pin.
It is not covered by SHA256SUMS, deliberately: SHA256SUMS covers what a rebuild reproduces,
and images.txt records a registry's answer at one moment — a value no rebuild can reproduce. A
release whose tag was never pushed fails that step instead of publishing a guessed digest, so push
the image for the tag before pushing the tag. PUSHED_AT says unknown for the same reason: a
registry manifest carries no push timestamp, and an invented one would be the field everyone later
trusts.
Deploy from the release asset, not from whatever dist/ holds on the machine doing the rollout:
curl -fsSLO <release-page-url>/images.txt # the asset, not a local build's record
kubectl -n byre-system set image deploy/byre byre="$(sed -n 's/^IMAGE_REF=//p' images.txt)"
make image-verify IMAGES=images.txt # digest AND registry prefix, against the running pod
make image-verify exits 2 when it cannot qualify the check — a bare digest with no registry to
compare against — because "could not check" must not read as "checked and fine". Comparing only the
digest is not enough: when the same blobs already exist under another registry name, containerd
downloads nothing, imageID keeps reporting the old repository, and the pod is not running what the
release page names.
The pool key Secret is deliberately not part of kubectl apply -k deploy/ — creating it from a file
here would put a private key in git. Create it before the first rollout, in the same namespace:
Skipping it does not fail loudly: the Deployment's volume on that Secret is not optional, so the Pod sits
in CreateContainerConfigError and never starts. That is the intended failure mode — the alternative
(making the volume optional) lets the gateway start with no key and fail every acquire with a misleading
SSH error instead.
deploy/ creates: ServiceAccount, Role/RoleBinding (in the target namespace), Deployment (SSH front end
on 2222, health on 8099), Service (ClusterIP 2222). The configuration comes from a ConfigMap; the pool
key comes from the Secret above. Both are examples — copy, then edit.
Image registries: two tiers¶
Two registries serve this cluster and they are not interchangeable. Below, <your-gitea-host>:<port>
is your Gitea instance's container registry endpoint — the one releases are published to — and
<internal-registry-host>:<port> is a throwaway registry that lives on the cluster network.
| registry | role | auth | what belongs there |
|---|---|---|---|
<your-gitea-host>:<port> (Gitea container registry) |
release source of truth | token — write:package to push, read:package to pull |
anything a workload runs: versioned tags, digests, traceable to a repository |
<internal-registry-host>:<port> (registry:2, self-signed CA) |
scratch space | none — anonymous push is allowed | one-off experiments, manual builds, images nobody will need next month |
The rule is one line: anything that reaches production comes from the Gitea registry. An image in
the scratch registry is temporary by default and may be deleted without notice. The scratch registry
is kept rather than retired because it already speaks the v2 API, which is cheaper than teaching
everyone docker save / ctr import for the occasional hand-built image.
Repository names differ¶
Gitea requires owner/image — two path segments, where owner is a user or an organisation, and the
image name is independent of any repository name. The migration therefore renamed single-segment
repositories:
| scratch registry | Gitea |
|---|---|
byre |
byre/byre |
gitea/runner:6.0.0 |
byre/runner:6.0.0 |
hermes-sandbox-desktop:ssh-uid10000-v19 |
byre/sandbox-desktop:ssh-uid10000-v19 |
library/ci-go:1.23 |
byre/ci-go:1.23 |
library/golang:1.23-alpine |
byre/golang:1.23-alpine |
Container packages are not linked to a repository (repo_id = 0): they appear under the
organisation's packages page (/byre/-/packages/container/<image>), and the repository's Packages tab
stays empty. Deleting a repository does not delete its images, and deleting an image is an
organisation-level action.
Pulling from Gitea inside the cluster¶
Nothing on the nodes has to change. The registry presents a Let's Encrypt certificate for
<your-domain>, which every node already trusts (openssl s_client -verify_return_error returns 0 on
every node), so registries.yaml needs no CA entry for it — and therefore no systemctl restart k3s.
The existing entry for the scratch registry stays because that registry is self-signed.
This is deliberate: a credential inside registries.yaml is a credential on every node's disk. Pull
credentials belong in a kubernetes.io/dockerconfigjson Secret instead, which is what
imagePullSecrets is for:
kubectl -n <namespace> create secret docker-registry gitea-registry \
--docker-server=<your-gitea-host>:<port> \
--docker-username=<gitea user> \
--docker-password=<token with read:package only>
Then reference it from the workload (spec.imagePullSecrets) or, for every pod in a namespace, from
the default ServiceAccount. Three namespaces need it: byre-system, hermes (CI runner, sandbox
templates) and agent-sandbox-system.
The pull token is a dedicated one: read:package and nothing else. A token that can push lets its
holder replace what production runs, and there is no reason for a node to hold one.
Proving a pull actually went to Gitea¶
A Successfully pulled image event is not proof: when the same digest is already present locally — the
scratch registry and Gitea hold byte-identical blobs — containerd downloads nothing, and the node may
even report the old repository name in imageID. The honest check uses an image whose layers exist
only in Gitea:
kubectl -n hermes run pullprobe --image=<your-gitea-host>:<port>/byre/pullprobe:v1 \
--overrides='{"spec":{"imagePullSecrets":[{"name":"gitea-registry"}],"nodeName":"<node>","restartPolicy":"Never"}}'
kubectl -n hermes get pod pullprobe -o jsonpath='{.status.containerStatuses[0].imageID}'
byre/pullprobe:v1 is a 162-byte layer kept for exactly this purpose. The container has no shell, so a
pod that ends in Failed (exec /bin/sh) is expected; what matters is imageID naming
<your-gitea-host>:<port> after a non-zero download. Delete the pod when done.
Build and publish the image¶
make image # byre:<git describe>; lands in the local daemon only
make image-push IMAGE_REGISTRY=<registry>/<team> # pushes <registry>/<team>/byre:<tag>; see the digest below
# then fill the placeholder in both places — they are matched as a string, see deploy/kustomization.yaml:
# deploy/deployment.yaml:39 image: <registry>/byre@sha256:<digest>
# deploy/kustomization.yaml images: name: <registry>/byre@sha256:<digest>, newName: …, digest: …
make image-push pushes through scripts/publish-image.sh, which then writes the digest the registry
assigned into dist/images.txt — IMAGE_REF (the reference to pin), IMAGE_TAG, IMAGE_DIGEST and
PUSHED_AT — and appends IMAGE_DIGEST= to dist/build-info.txt when that release asset already
exists. A push that returns no digest exits non-zero instead of leaving a file that only looks complete.
make image-verify compares the running pod's imageID with that digest and exits non-zero on a
mismatch: that is the check that catches a re-pushed tag whose layers the node already had.
Two steps above are not optional and both fail in ways that do not mention them. make image only feeds
the local container runtime, and the manifest ships <registry>/byre@sha256:<digest> — a placeholder that
kubelet cannot resolve, so an unfilled deploy/ stops in ImagePullBackOff. A missing byre-pool-key
Secret is worse: the volume is not optional (deploy/deployment.yaml:77-80), so the pod never starts
and sits in CreateContainerConfigError.
The image is a static binary on Alpine; nothing else is installed. The image's own user is 10001:10001,
while the shipped Deployment runs the container as uid 65532 with fsGroup: 10001
(deploy/deployment.yaml:23,27). The fsGroup is what makes the 0400 Secret mount readable — the
ownership, not the uid, decides — and that pairing was verified on a real cluster in
docs/acceptance/2026-11-17-deploy.md. The two numbers should be the same; until the manifest is unified
on 10001, describe the container by what the image says and by the fsGroup that makes it work.
The host key¶
The gateway's own SSH host key lives on the byre-hostkey PVC (host_key:
/var/lib/byre/hostkey/id_ed25519). On first start the file does not exist and the gateway creates it,
logging the fingerprint (generated a new host key and persisted it). Distribute that fingerprint to
clients; from then on restarts keep the same identity.
To supply your own key instead, mount a Secret at that path — an existing file is never rewritten.
Rotation (deliberate):
kubectl -n byre-system scale deploy/byre --replicas=0
kubectl -n byre-system exec <debug-pod> -- rm /var/lib/byre/hostkey/id_ed25519 # or replace the file
kubectl -n byre-system scale deploy/byre --replicas=1
kubectl -n byre-system logs deploy/byre | grep fingerprint # publish the new one
# on every client:
ssh-keygen -R '[<gateway-host>]:<port>'
If the build host cannot reach a base-image registry, build the binary first and use the prebuilt
variant, which pulls nothing (FROM scratch):
CGO_ENABLED=0 GOOS=linux go build -trimpath -o bin/byre ./cmd/byre
podman build -f Dockerfile.prebuilt -t <registry>/byre:<tag> . # docker works the same way
Pin the image by digest, not by tag: with imagePullPolicy: IfNotPresent a re-pushed tag keeps the
node's cached layers, so the Deployment reports the new tag while the running process is still the old
build (/healthz shows the truth — it prints the version stamped into the binary).
podman push --digestfile /tmp/digest <registry>/byre:<tag>
kubectl -n byre-system set image deploy/byre byre=<registry>/byre@<digest>
The grant that is not in the overlay¶
kubectl apply -k deploy/ installs the gateway in its own namespace. Creating and deleting the
instances it leases happens in a different namespace, and kustomize's namespace: rewrites every
object at once, so that grant is a separate apply (deploy/instances-rbac.example.yaml).
Skipping it produces the most misleading failure this project has: /healthz is green, the pool never
warms, and every checkout returns 403 — which reads as "the backend is down". Check it first when the
gateway is alive but cannot hand out instances:
kubectl -n <instances-ns> auth can-i patch <plural-resource> --as system:serviceaccount:<gateway-ns>:byre
<plural-resource> is the resource from the backend's provider block, and the API group is whatever
that block names — the gateway hardcodes neither. The deployment this project was written on uses
sandboxclaims from extensions.agents.x-k8s.io; that is one claim API among many, not a requirement.
If pool_size > 0, the gateway will start creating instances immediately. Set pool_size: 0 in the
ConfigMap for a first smoke test if you do not want warm capacity yet; the value is explicit now (a
literal 0 is no longer rewritten to the default of 2), so /readyz is green by construction in that mode.
An explicit grace: 0s is kept as written too: a zero reconnect window is accepted, it just means a
disconnect ends the lease share. And the setting only applies to drivers that implement Create —
endpoints and command never warm anything.
The ConfigMap generated by kustomize carries a content hash in its name (byre-config-<hash>). Do not
write kubectl get cm byre-config into a runbook — it 404s. Read the name from the Deployment:
kubectl -n byre-system get deploy byre -o jsonpath='{.spec.template.spec.volumes[?(@.name=="config")].configMap.name}'
Validate a configuration before shipping it¶
Exits non-zero and lists every violation (not the first one) when the file is wrong: unknown fields,
an unknown or missing provision value, fields that this provision requires but the file omits,
duplicate fingerprints, malformed endpoints, missing required values, an explicit zero where zero cannot
work (ttl, ssh.port, ready_timeout), and a fingerprint that decodes to something other than 32 bytes.
It checks the configuration, not the cluster: under -check-config the Kubernetes drivers are
validated and built without API clients, so this runs on a workstation with no credentials. Whether
the cluster would accept the objects is a separate question — that one is answered by the
auth can-i check above and by the first acquire.
It also cannot see intent. deploy/config.example.yaml passes with rc=0 while every value is still a
<placeholder> and the fingerprint is 32 zero bytes: the validator checks shapes (base64, host:port, a
known provision), not whether you meant to edit the file.
It also probes host_key: an existing path must be a file, and a missing one must be creatable in its
nearest existing ancestor, because a first start that cannot write the generated key dies halfway.
host_key itself is required: without it every restart changes the fingerprint clients pin, and every
client with strict host-key checking stops connecting. -allow-ephemeral-hostkey exists for tests and lab
runs only; it is a command-line flag, never a config key, so a deployment cannot opt out by editing its own
ConfigMap. Even with the flag, the omission is printed as a warning.
Health¶
Three paths exist on :8099:
| endpoint | question | used by |
|---|---|---|
GET :8099/healthz |
is the process alive? prints ok <version> from the binary |
livenessProbe |
GET :8099/readyz |
can this process provision instances? | readinessProbe |
GET :8099/metrics |
Prometheus text | scraping |
/readyz is 200 when there is no pool, or at least one instance is warm, or the last fill created one; it
is 503 otherwise and its body names the pool target, the warm count and the last error (ADR-0011). The
bundled manifest uses /healthz for liveness and /readyz for readiness — a rollout that cannot
provision stays red instead of going green behind a broken pool. What /readyz still does not say: the
instances it hands out may be broken in ways only a real session reveals (see
the grant that is not in the overlay and ADR-0005).
The port is compiled in: &http.Server{Addr: ":8099"} in cmd/byre/main.go:147, with no config key and
no flag. Two consequences: a second gateway on the same host cannot start — it binds its SSH listener,
logs health endpoint failed: listen tcp :8099: bind: address already in use and shuts down — and the
Deployment must never schedule two replicas per node (it is single-replica by design anyway).
The complete metric list:
| metric | type | meaning |
|---|---|---|
byre_up |
gauge | always 1 while the process serves |
byre_build_info{version,commit,build_date} |
gauge | what is actually running (/healthz prints the same stamp) |
byre_leases_active |
gauge | leases with at least one open connection |
byre_leases_idle |
gauge | leases without connections, waiting for the reaper |
byre_leases_adopted |
counter | leases recovered from existing instances at startup |
byre_leases_adopted_pending |
gauge | adopted leases no connection has picked up yet |
byre_oldest_idle_lease_age_seconds |
gauge | oldest idle lease; growing past ttl+grace means the reaper is stuck |
byre_pool_target{backend} |
gauge | warm capacity this backend is trying to hold (0 = no pool) |
byre_pool_warm{backend} |
gauge | warm instances per backend; 0 for drivers without a pool (endpoints, command) |
byre_pool_inflight{backend} |
gauge | creations in progress |
byre_pool_fill_seconds |
histogram | duration of one fill, including the failures inside it |
byre_pool_fill_errors_total |
counter | failed instance creations during a fill |
byre_handshake_fail_total |
counter | readiness probes where the port answered but SSH did not |
byre_release_errors_total |
counter | failed release attempts (one release may count up to three) |
byre_acquire_total{backend,result} |
counter | acquisitions by outcome: reuse, pool, created, error |
byre_process_resident_memory_bytes |
gauge | RSS from /proc; the number the memory limit is judged by |
Alerting: use byre_pool_warm < byre_pool_target and only when byre_pool_target > 0 — a static
backend has no pool and a naive comparison fires forever.
Turning on the lease store¶
By default the lease table lives in memory: a restart empties it, and every identity cold-starts while the
instance it was using is still running. Setting lease.store: crd moves the table into ByreLease objects,
so a restart — or a second replica — reads the same truth (ADR-0013).
Preconditions, both checkable before touching any config:
kubectl get crd byreleases.byre.io
kubectl auth can-i list byreleases.byre.io -n <namespace> \
--as=system:serviceaccount:<namespace>:byre
If the CRD is missing, apply deploy/ (it includes crd/byreleases.yaml). The second command answers "can
the pod's identity do this", which is the one that matters — an admin kubeconfig proves nothing here.
The change is two lines in the backend configuration:
lease.kubeconfig is only needed when no backend already has a cluster client. When one does, its client is
reused on purpose: two clients could point at two different clusters.
Verify in this order. Each step fails differently, and skipping to the last one hides which:
- Startup. The log line reads
lease store kind=crd namespace=…. If it instead readscould not read the lease table at startup, the pod's identity lacks the RBAC above — and by design the gateway still starts, degrading to annotation recovery rather than refusing every session. - One connection.
kubectl get byreleases -n <ns>shows one object per live lease, carryingspec.identity,spec.instance, andspec.namewhenidentities[].nameis configured. An emptyspec.namewith names configured means the fingerprint spelling does not match — see the note in the store'sidentityNames. - Restart. The startup log reports
adopted: Nfor N live leases, and a reconnect from the same identity returns the samespec.instance. This is the whole point; before ADR-0013 this step cold-started everyone. A lease that only its annotation knew about gets itsByreLeasewritten at this moment, sokubectl get byreleasesshows one row per adopted lease immediately; if that write fails,byre_leases_unpersistedsays so and the sweep retries it (ADR-0015). - Delete an instance object. Within seconds
kubectl get byreleasesloses that row and the next connection gets a fresh instance, without a restart. This exercises the watch (part 4).
Rollback is removing lease.store and restarting: the table returns to memory and the CRs are then
ignored. Leave them in place — they are the only record of which instance each identity was using at the
moment of rollback, and re-enabling the store picks them up again.
What to watch afterwards:
byre_leases_unpersistedabove zero means the table and the store disagree. It heals on the next successful write (the sweep retries), so a spike is an apiserver blip; a flat non-zero is a permissions or CRD problem, and the error log names it.byre_persist_errors_totalclimbing without recoveries means writes are failing outright.- An instance in
lease failcounts separately from one that is merely unreachable.
Tunables¶
| key | default | guidance |
|---|---|---|
lease.ttl |
360s |
must exceed the client's idle timeout (reference client: 300s) |
lease.grace |
60s |
reconnect window after a disconnect; absorbs ControlPersist expiry |
lease.pool_size |
2 |
warm instances; each one costs one pod-worth of memory when idle. 0 is a real value: no warm capacity, every acquire provisions on demand |
provider.ready_timeout |
120s |
raise for slow images (cold layer pulls) |
provider.run_as_root |
false |
workload instances: by default they run as non-root with all capabilities dropped and RuntimeDefault seccomp; set true only for an image whose entrypoint genuinely needs uid 0 |
ssh.host_key_policy |
accept-new |
strict requires known_hosts; insecure is for throwaway instances only |
provider.api_group/api_version/resource/object_kind |
— | required for provision: claims: the claim API is configuration, never hardcoded |
provider.endpoint_field |
status.sandbox.serviceFQDN |
where a claim-shaped API exposes its SSH address; a bare host gets :22. Only a default — set it to your API's path |
provider.image |
— | provision: workloads: any image that runs sshd and trusts the pool key |
command.acquire/release/list |
— | provision: command: the program that creates, destroys and (optionally) lists instances |
Warm capacity is reported as byre_pool_warm{backend=...} against byre_pool_target{backend=...}. A pool
that never reaches its target means Create is failing (image pull, quota, missing template) — check the
gateway log for pool warm failed and byre_pool_fill_errors_total.
Flags¶
| flag | default | meaning |
|---|---|---|
-config |
config.yaml |
the configuration file |
-listen |
whatever the file says | overrides listen for one run: -listen 127.0.0.1:2223 |
-check-config |
off | validate, print every violation, exit 2 on any |
-shutdown-delay |
2s |
keep accepting this long after SIGTERM before dropping sessions, so the Service stops routing here first. It lives in the binary, not a preStop hook: the prebuilt image is FROM scratch and has no shell to sleep with |
-allow-ephemeral-hostkey |
off | run without host_key (tests only: the fingerprint changes on every restart) |
-version |
off | print the version stamped into the binary |
Logs¶
One line per event, JSON. The messages below are the ones the binary actually emits:
{"level":"INFO","msg":"session open","identity":"a1b2c3d4e5f60718","backend":"k8s-claims","instance":"byre-4k2p9"}
{"level":"INFO","msg":"session closed","identity":"a1b2c3d4e5f60718","instance":"byre-4k2p9"}
{"level":"INFO","msg":"lease released","identity":"a1b2c3d4e5f60718","backend":"k8s-claims","instance":"byre-4k2p9","reason":"expired"}
{"level":"WARN","msg":"stale-binding","identity":"a1b2c3d4e5f60718","backend":"k8s-claims","instance":"byre-4k2p9","reason":"instance no longer exists","cause":"...","action":"lease dropped; the next connection provisions a replacement"}
{"level":"WARN","msg":"cannot reach instance","identity":"a1b2c3d4e5f60718","instance":"byre-4k2p9","error":"dial ..."}
{"level":"INFO","msg":"lease replaced after the instance disappeared","identity":"a1b2c3d4e5f60718","backend":"k8s-claims","old_instance":"byre-4k2p9","new_instance":"byre-7xw2m"}
{"level":"INFO","msg":"lease address refreshed","identity":"a1b2c3d4e5f60718","backend":"k8s-claims","instance":"byre-4k2p9","old":"sandbox-2b47c.ns.svc:22","new":"sandbox-vk77n.ns.svc:22"}
{"level":"WARN","msg":"instance discarded at adoption","backend":"k8s-claims","instance":"byre-warm1","reason":"no identity annotation (stale warm capacity)"}
There is no per-session duration field: a session's length is the distance between its session open and
session closed timestamps. lease released carries reason (expired or invalidated) because "the
client went idle" and "the instance was broken" are different operational events, and stale-binding is
the line that says a lease was dropped before its client came back — the next connection provisions a
replacement instead of being handed an error.
Identities appear as the first 16 characters of the fingerprint — enough to correlate, not enough to reconstruct a key.
Common symptoms¶
| symptom | likely cause | action |
|---|---|---|
| client's files vanish between commands | lease.ttl shorter than the client's idle timeout, or the client opens connections the gateway treats as new identities |
raise ttl; check that the client uses one key everywhere |
| many instances, one client | client rotates keys, or authenticates with several keys | prefer one key per identity: the identity is the fingerprint, and aliases are log labels only — they never route two keys to one lease |
| instance never reclaimed | grace very large, or a channel leaked (session kept open) |
inspect /metrics (M3); kill the lease manually via the backend |
unable to authenticate after a key change |
new fingerprint not in identities |
add it (append), reload |
| startup exits with a long error list | configuration violations | fix every listed item; do not "fix one and retry" |
| instance exists in the cluster but nothing references it | an Acquire returned an unusable instance, or adoption found a duplicate identity annotation |
check byre_instances_discarded; the driver should have released it — file a bug if it did not |
claim (or pod) is READY, but every reconnect dies with Broken pipe and no instance is ever replaced |
the object behind the claim was deleted and rebuilt under a new name, so the lease's cached address no longer resolves; Alive sees only the claim |
upgrade to a build with the address refresh (ADR-0015). Check with kubectl get sandboxclaim <name> -o jsonpath='{.status.sandbox.serviceFQDN}' against the address in the gateway's session open line; they differ when this is happening, and lease address refreshed marks the recovery |
Running more than one replica¶
One replica is the default and needs nothing extra. A second is supported, but only with leader election (ADR-0016): without it both replicas adopt the same object for the same identity and hand it to two clients, and every process's own log looks correct while that happens.
Three preconditions, each of which fails loudly instead of degrading:
ha.enabled: truein the config. The holder of the Lease allocates; every other replica forwards the connection to it before the SSH handshake.- RBAC for
coordination.k8s.io/leases—get,create,update.deploy/rbac.yamlhas it. Without it no replica ever takes the lease, so every connection is refused. - A host key every replica can read. Two replicas with different keys make clients fail strict
known_hostschecking about half the time. AReadWriteOncePVC cannot be mounted twice: put the key in a Secret (deploy/hostkey-secret.example.yaml) and mount it wherehost_keypoints.
overlays/ha/ is that entire configuration as one overlay — two replicas, the Secret mount, a config with
ha.enabled, and the disruption budget that stops a drain taking both:
It is deliberately not a bare --replicas=2: scaling without the Secret gives the second pod a different host
key, and scaling without ha.enabled gives two writers. Each of those starts cleanly and fails quietly later,
which is why the overlay exists instead of a sentence telling you to scale.
Which replica leads, and where the others send connections:
kubectl -n byre-system get lease byre-leader -o jsonpath='{.spec.holderIdentity}'
# byre-5849d4dfb8-vmgqr|10.42.2.146:2222 <- pod name | the address followers dial
curl -s http://<pod-ip>:8099/metrics | grep byre_leader_
byre_leader_elected_total climbing on both pods is the signature of a flapping lease — the thing this
design most needs to make visible. One stable leader and one follower with zero elections is the healthy
shape.
Two behaviours worth knowing:
- An open SSH session stays on the pod that started it. The election coordinates allocation, not the routing of sessions already open: a client that connected to the follower has its whole session on the leader, so restarting the leader ends that session. Clients reconnect and re-attach to the same instance, because the lease survives in the store.
- During a leader change, connections can be refused for up to one
lease_duration(15s by default) while the old holder's readiness is re-evaluated and the new one publishes itself. The window is bounded, and a client retries through it.
Restarting or upgrading safely¶
- The new process adopts live leases first and destroys unannotated (stale pool) objects second, then
refills the pool. Expect
byre_leases_adoptedto be non-zero when clients were connected, andbyre_instances_discardedto account for every object it could not own (no identity annotation, a duplicate identity, or a description that cannot be dialled). - Compare
byre_leases_active + byre_leases_adopted_pendingwith the value ofbyre_leases_activebefore the restart. An adopted lease has no connection yet, so it is idle by definition; comparingactivealone always reads zero and cannot tell a healthy restart from a lost table. - An adopted lease that no client reclaims is destroyed after
ttl + grace(420s with the defaults), exactly like any other idle lease. That is the documented contract: reconnect inside the window. - Only
claimsandworkloadssurvive a restart. Their instances carry the identity as an annotation, so the new process can read it back. Anendpointsbackend keeps ownership in memory only: after a restart every endpoint is up for grabs and the next connection is round-robined as if nothing had happened. Nothing breaks — but a client that held a tree on one host is now on another. - A client that reconnects during this window keeps its instance. A client whose lease had already expired gets a new one — that is the documented contract, not a regression.
- Watch
byre_pool_warm{backend=...}return tobyre_pool_target{backend=...}; a pool that stays at 0 meansCreateis failing — the gateway logspool warm failedevery 15s, counts it inbyre_pool_fill_errors_total, and/readyzstays red. - An instance is bound to an object UID as well as a name. If the object behind a lease was deleted and
recreated, the gateway logs
stale-bindingand does not hand the replacement to the old client; the leftover is reclaimed as unbound capacity. - Every SSH connection is cut when the process exits, but not instantly. On SIGTERM the process
keeps accepting for
-shutdown-delay(default 2s) — the window in which the Service stops routing here — and then closes the listener and every live session. There is no connection hand-off: a rollout ends every live session, including assh -Ltunnel. Clients that reconnect insidettl+graceland on the same instance; long-running commands on the client's side of the connection do not survive it. Pods therefore exit in seconds instead of waiting outterminationGracePeriodSeconds, which is the ceiling, not the expected duration. Roll in a window where that is acceptable, or keep the process alive and swap configuration only where the binary allows it.
More symptoms, with the log lines that identify each one: troubleshooting.md.
Smoke test against a running gateway¶
make and the script are the same thing; the script is what CI would call if it had a gateway.
BYRE_CFG=config.yaml BYRE_KEY=path/to/client_key test/e2e/run.sh
make e2e CONFIG=config.yaml KEY=path/to/client_key # identical
# add --ttl-ok (script) to include the 320s idle-reconnect check
# add --allow-na to tolerate checks that cannot be evaluated (see below)
Without BYRE_CFG and BYRE_KEY (or CONFIG/KEY) the script prints No target given and exits 2 —
that is the whole content of make e2e on its own. A kind-based mode is planned in docs/roadmap.md;
it needs a container runtime to build and load the image, so nothing calls it yet.
It asserts against a gateway that is already running: same instance across reconnects, -L reaching the
instance's own sshd on its port 22, and the adoption and pool counters. Because of that :22, a lab whose
endpoints listen on other ports fails the tunnel check — that is the harness, not byre. It is the same
sequence recorded in docs/acceptance/.
A check that cannot be evaluated is reported as N/A and makes the run exit non-zero: AC5 (adoption) can
only be observed after a restart that adopted live instances, so running the script against a gateway that
has not restarted does not evidence AC5. --allow-na exists for a run that explicitly does not claim
those checks — a green --allow-na run is not evidence for them.
Upgrading¶
byre -check-configwith the new binary against the current file.- Roll the Deployment; the manager adopts live instances on startup (ADR-0002 consequences).
- Watch
byre_leases_active + byre_leases_adopted_pendingreturn to the previous value ofbyre_leases_active; a permanent drop means adoption failed and instances are being recreated under clients that still hold state.
Uninstalling¶
Delete the Deployment and Service, then delete instances carrying byre/managed=true. Static hosts
are untouched by design: the gateway never destroys what it did not create.