TAK-OS peers synchronize the exporting cluster's complete locally owned data over authenticated TCP DNS. This is a TAK-specific catalogue exchange, not ordinary per-zone AXFR/IXFR. A peer does not need an advance list of remote zones. BIND cannot participate in this protocol.
This document defines the implementation contract. Use peer
administration for setup and recovery,
security for key handling and
configuration for the peer schema. The configuration
schema remains v1; the independent peer wire version is 4.
Ownership and identities
An export contains static and Kubernetes-generated records originating in the exporter's cluster, with their zone metadata and source versions. It never contains imported records. Definitions masked in the merged serving cache, such as a local CNAME masked by remote addresses, remain eligible for local export.
Each peer entry represents one stable cluster identity with alternative ordered IP endpoints. Endpoints are routes to that source, not independent owners. The receiver checks that the response and completed snapshot have the configured peer's cluster ID and rejects its own cluster ID even if reached at another IP. Site discovery is transitive: an authenticated site catalogue propagates site identities and endpoints, and receivers persist new PeerSites. DNS records still require direct authenticated contact with their origin. Missing credentials leave discovered sites pending until an operator or automation provisions their key.
DNS framing and authorization
| Property | Contract |
|---|---|
| Transport | TCP DNS on the configured endpoint, normally port 53. UDP transfers are refused. |
| Question | One IN/TXT question for _tak-os-sync.. |
| Signature | TSIG using hmac-sha256., with a 300-second signing fudge in generated messages. |
| Key authorization | The current local site key authorizes inbound exports; outbound peer credentials are separate. Reciprocal peer configuration is not required. |
| Request envelope | One additional TXT RR before the TSIG; the transfer handler expects exactly those two additional RRs. |
| Successful response | One answer TXT RR containing the response envelope, followed by TSIG. |
TXT character strings concatenate into standard base64-encoded JSON. The writer splits that text into character strings no longer than 200 bytes to stay below the DNS TXT string limit and avoid presentation-format escaping. Payload page bytes have their own base64 layer inside that JSON envelope.
TSIG verification is performed before accepting a request or response. An unsigned response is rejected even if its data otherwise appears valid. Invalid signatures, unsigned requests, unauthorized keys and unsupported transfer transports do not authorize exports. There is no additional source-IP ACL in the peer manager; authorization is by configured TSIG key, with expected cluster identity verified in received data. TSIG provides authentication/integrity, not transport encryption.
All pages of each record or topology fetch use one physical TCP connection. This pins the transfer to one Kubernetes Service backend, whose incremental history may differ from other replicas. Each page is an independently signed query/response pair, not an AXFR-style TSIG MAC continuation. The client creates a fresh DNS connection wrapper for each exchange over the retained socket so the DNS library does not chain one independent query's request MAC into the next.
Request envelope
{"version":4,"revision":"last-content-fingerprint","offset":0}
| Field | Meaning |
|---|---|
version |
Integer 4; another transfer version is rejected. |
kind |
Empty/omitted for DNS records, or topology for the separate site catalogue. Unknown values are rejected. |
revision |
The receiver's accepted source content fingerprint, or omitted/empty when it has no base or requests a forced full transfer. It remains the base fingerprint throughout pagination. |
offset |
Nonnegative byte offset in the unencoded full/delta JSON payload. The first request uses zero. |
target |
Omitted/empty initially. Continuations carry the returned target content fingerprint. |
token |
Omitted/empty initially. Continuations carry the immutable payload token returned by the first page. |
For example, after receiving 24,576 payload bytes:
{"version":4,"revision":"BASE","offset":24576,"target":"TARGET","token":"PAYLOAD_TOKEN"}
An offset-zero request must not contain a target/token cursor. A continuation must identify a retained token, its target revision and, for a delta, its base. The supplied offset must be inside the retained byte stream.
Response envelope
| Field | Meaning |
|---|---|
version |
Integer 4. |
clusterID |
Exporting source cluster identity. |
revision |
Target content fingerprint; independent of source-watermark changes. |
offset |
Offset of this page, matching the request. |
total |
Complete full/delta JSON payload length in bytes, before page base64 encoding. |
mode |
full or delta for records, topology for site metadata. |
base |
Required delta base fingerprint; empty/omitted for a full payload. |
token |
Immutable identity of the exact full/delta byte stream and its encoding metadata. |
data |
Base64 of this page's payload bytes, at most 24 KiB before encoding. |
unchanged |
true instead of a payload when the requested fingerprint already matches. |
versions |
Current collection/configuration watermarks in an unchanged response. |
Fields marked optional by the Go JSON tags can be omitted when empty. An unchanged
response contains no data stream, reports total: 0 and omits the mode/token/data
fields. Its collection watermarks still advance rollback protection. Object-specific
keys containing / are not included in that small response; they are carried in full
snapshots/deltas instead.
For data transfers the receiver requires positive bounded total, a supported mode, a
nonempty token, matching offsets and a valid chunk no larger than 24 KiB. Target
revision, mode, total and token must remain the same across all pages. The transfer
completes only when assembled payload bytes equal total.
Content fingerprints and immutable payload tokens
The content fingerprint is lowercase hexadecimal SHA-256 of the canonical snapshot JSON
with revision empty and versions omitted. It identifies DNS content and ownership,
not the exact transfer encoding. A metadata-only source refresh can preserve that
fingerprint while changing the serialized Versions map or its byte length.
The separate payload token is lowercase hexadecimal SHA-256 of:
UTF8(mode) || 0x00 || UTF8(base) || 0x00 || exact_payload_bytes
For full, base is the empty string; for delta, it is the source fingerprint used
to create the delta. exact_payload_bytes are the complete JSON bytes before page
encoding. Thus mode, delta base and source metadata are all pinned. The receiver
recomputes this token after assembly, before decoding/applying the payload, then
separately validates the reconstructed snapshot fingerprint.
Later source content or watermark publications do not alter an existing token's bytes. Continuation requests read the cached payload directly without cloning the current source, serializing it again, changing transfer mode or rebuilding a delta. An unknown or evicted token fails explicitly; the server never silently substitutes another stream for the remaining pages.
Full and delta payloads
A full payload is the canonical model.Snapshot JSON:
{
"clusterID": "cluster-west",
"revision": "CONTENT_FINGERPRINT",
"versions": {"dnsrecords":"12","services":"15","nodes":"16","ingresses":"17"},
"zones": [{"name":"example.com.","ttl":60,"ns":["ns1.example.com."],"admin":"hostmaster.example.com."}],
"records": [{"zone":"example.com.","name":"app.team.example.com.","type":"A","ttl":60,"value":"192.0.2.40","source":"service/OBJECT_UID"}]
}
Fingerprint placeholders in this example are illustrative. Snapshot zones must not embed records. Records are flattened and retain source ownership, including object UID identifiers. Newly added or removed zones are consequently discovered from the complete payload without a separate per-zone negotiation.
A delta JSON object contains clusterID, base, revision, versions, zones, add
and remove. zones and versions replace the complete target metadata; add and
remove are record sets. Record identity for diffing is its complete JSON
representation, including TTL and source. A change to a record is therefore represented
by removal of the old value and addition of the new one.
The receiver checks the delta's source/base, requires every removal to exist, applies additions to a private reconstruction and then performs complete snapshot normalization and validation. Source identity, resulting fingerprint, optional zone ownership, record types, wire encodability and cache resource limits must all pass before atomic replacement. Incomplete or rejected data never becomes an empty authoritative source.
The exporter chooses a delta only if its base is in its journal and the encoded delta is smaller than the full payload. Otherwise it sends a full snapshot. Exporter restart, journal eviction or a newly selected Service backend can therefore cause a normal full fallback. The full-fallback decision and prepared delta are cached for the current local publication/base pair.
Export cache and limits
| Component | Bound and behaviour |
|---|---|
| Current export | One coherent local snapshot plus its encoded full payload and collection watermarks, refreshed per local publication stamp. |
| Source journal | At most four content revisions and at most twice the transfer-byte limit of encoded snapshot data. |
| Immutable transfer cache | At most eight payload tokens and at most twice the transfer-byte limit of payload bytes, independently of the journal. |
| Transfer-byte limit | 16 MiB by default, enforced on the complete full source and on received transfer payloads. This is an internal peer option, not an environment variable. |
| Page size | At most 24 KiB of payload bytes. |
| Export handler concurrency | Four simultaneous export request/page handlers, also subject to the DNS worker/connection bounds. |
| Outbound refresh worker | Serialized refresh passes; endpoints within a peer are attempted sequentially. |
Journal and token caches evict in insertion order; active sessions are not pinned against cache-capacity eviction. Eviction can fail an in-progress transfer, which retains previous imported state and retries through the endpoint policy. Journal eviction alone does not invalidate a prepared token whose bytes remain retained.
Repeated unchanged polls check the cheap local publication stamp and reuse cached metadata. Imports do not advance that stamp. A local watermark-only publication changes the encoding/token while preserving old immutable sessions. These limits cover encoded history/payload storage, not the entire process heap; source snapshots, reconstructions and serving indexes also consume memory. See capacity planning.
The default DNS connection limit of 1,024 queries accommodates the roughly 683 pages needed for the default 16 MiB limit. Increasing payload limits requires revisiting page counts, listener bounds, deadlines and memory together.
Source ordering and rollback checks
For every previously accepted collection/configuration watermark, a new source must
retain that key and supply the same or a numerically greater value. Changed values are
compared as arbitrary-precision integers. A changed nonnumeric value, missing watermark
or lower numeric value rejects the transfer. Equal opaque values remain acceptable.
The optional logging ConfigMap is not a DNS source collection and its settings
watermark is excluded from ordering checks. Deleting or recreating that ConfigMap
therefore does not block subsequent DNS updates.
Object-specific keys such as service/<UID> are excluded from that comparison: they
legitimately disappear when an object is deleted. The collection watermark establishes
deletion ordering. An unchanged-content response still checks and advances the manager's
accepted watermark state, preventing a later stale endpoint from rolling back data after
a metadata-only observation.
This assumes a Kubernetes backend producing numeric ordered resource versions. Kubernetes resource versions are otherwise opaque; continuous updates from a backend producing changed nonnumeric versions are unsupported here. File-mode snapshots have no such watermarks, so their content fingerprints alone do not establish chronological ordering between differing file replicas. There is no persisted incarnation counter or distributed commit log. Recovery after an API datastore restore is an explicit operator decision covered in troubleshooting.
Scheduling, failover and readiness
A new peer starts at its first configured endpoint. A successful endpoint remains active for subsequent passes. Connection errors, deadlines, transfer failures, identity failures, validation failures or stale versions advance to the next endpoint, wrapping at the end. Each endpoint gets a fresh deadline using the configured peer timeout; all pages share that endpoint's attempt context.
A complete failed pass retains previously served records and records failure. The worker retries on the fixed periodic interval or a coalesced trigger. It does not use exponential backoff or jitter. Peer-cluster traversal order is not specified; only each cluster's endpoint order is configured.
Every configured/discovered peer must complete an initial attempt before readiness, including its bounded endpoint failover pass when credentials/endpoints exist. Missing credentials and disabled sites count as completed attempts without network contact. If credentials become available after a pending attempt, readiness waits for an actual credentialed attempt to finish; the earlier pending state cannot satisfy that condition. Success is not required for that readiness condition. Peer snapshots, accepted watermarks, journals and tokens are held in memory. Restart discards them and forces new learning; an all-pod restart can leave missing imported data until the remote clusters become reachable.
transfers counts accepted successful exchanges, including unchanged polls. failures
counts complete failed passes, rather than individual endpoint errors. The active
endpoint and accepted revision refer to the last successful state; a later failure does
not clear retained data. The management representation is specified in the API
reference.
Notifications, forced re-transfer and removal
A signed TCP DNS NOTIFY for _tak-os-sync. with TXT type queues a refresh. It carries
no authoritative records and no transfer envelope; the recipient obtains and validates
data through the normal fetch path. Notifications and refresh triggers use separate
single-entry coalescing queues drained by the manager. They can trigger a pass over all
configured peers.
The application queues notifications when its local content fingerprint changes. Watermark-only changes remain discoverable through periodic polls. Outbound notifications try ordered endpoints with a fresh timeout for each endpoint. Failure of a notification neither removes records nor disables periodic recovery.
Retransfer(ids...) validates all selected peer IDs before changing any state; an empty
selection means every peer at the internal API level. It invalidates selected in-flight
result generations, clears their transfer bases and queues a full fetch. Serving records
and rollback watermarks remain in place. A manual re-transfer therefore cannot bypass a
source-version rollback rejection.
Peer incarnations increase monotonically within the manager, including removal and recreation of the same site ID. An in-flight record transfer belonging to a removed incarnation cannot republish DNS data or rollback watermarks into its replacement.
Removing a configured peer explicitly purges that source from the cache. Successful snapshots remove records/zones omitted by that source. An unavailable peer, elapsed TTL or failed/partial transfer does neither.
Error and compatibility boundaries
The handler uses REFUSED for unauthorized/unsupported transfer requests, FORMERR for malformed envelope/version/offset input, and SERVFAIL for unavailable exports, capacity pressure or invalid/evicted cursors. The receiver also rejects missing signatures, unexpected identities, inconsistent boundaries, invalid base64/JSON, token mismatches and reconstructed-content failures. It publishes only a fully validated replacement.
Wire v4 is incompatible with v1/v2/v3. It supports independent per-site credentials, optional-zone/DNAME data and transitive topology streams; mismatched versions fail closed. Ordinary AXFR/IXFR is not a fallback. Coordinate peer upgrades as described in upgrades.
Site topology operation
A successful record refresh is followed by an authenticated catalogue fetch when
discovery is enabled. The initial request is
{"version":4,"kind":"topology","offset":0}. It uses the same TXT framing, page size,
concurrency bounds, connection pinning and payload-token algorithm. The response mode is
topology, base is empty, and revision is SHA-256 of the exact topology JSON bytes.
Unchanged-record replies do not skip this operation, so node additions/removals
propagate independently of record fingerprints.
The complete payload is an array of {id,addresses,via,path,versions} site objects. It must
include the authenticated exporter's own site and unique site IDs. There is no fixed
site-count ceiling; the complete encoded catalogue must fit the transfer-byte budget
(16 MiB by default). Each site allows up to 256 literal IP/IP:port endpoints.
Empty address lists are explicit values. The informational via is replaced by
the immediate authenticated origin. path is a bounded vector from described site to
advertiser: [C,B] means B advertises C. IDs must be unique/valid, the first must match
the described site, the last the authenticated advertiser, and length must not exceed
16. Own-site paths are [self]; explicit local seeds use [target,self]. This is loop
prevention metadata, not a cryptographic trust chain. Returning paths containing the
receiver and paths at the receive hop limit are omitted, withdrawing that origin’s
previous contribution when its complete catalogue is reconciled. No TSIG secrets or
remote DNS records are included.
versions is a bounded source-ordering map (at most 16 keys, with values up to 128
characters). Kubernetes own-site advertisements include nodes (complete Node-list
read version), dnsService (the named DNS Service object's version) and peersites
(the PeerSite collection read version). It orders the complete catalogue, including
route omissions; the SHA-256 payload revision alone is an identity, not a clock.
Transitive routes preserve their described site's ordering map rather than substituting
the intermediary's Kubernetes versions. File-mode/explicit seed advertisements may
start without ordering metadata; they cannot replace an established ordered route with
an empty vector.
The receiver persists catalogue ordering floors in PeerSite status. Lower, missing or incomparable established components reject stale topology before it changes endpoints. The originating site's floor and its direct endpoint list are updated together using optimistic resource-version checks. Every existing PeerSite, including unchanged routes, retained withdrawal tombstones and blank objects with no route from this origin, advances its per-origin ordering floor when a newer catalogue is accepted. Even an unchanged endpoint list receives a new optimistic version: otherwise an older in-flight writer could overwrite it or publish its first stale route after the newer catalogue completes. A receiver restart therefore preserves endpoint rollback protection even though its imported DNS records must be learned again. Separate record and topology connections may choose different Service backends; freshness validation remains necessary even with per-operation connection pinning.
Before writing target route status, reconciliation commits a fresh random
catalogueClaim on the origin object using its observed Kubernetes resource version. This forces an actual status change
rather than relying on a potentially optimized no-op PUT. It also fences an equal-version
retry that creates a previously removed target after a newer catalogue's list snapshot.
New blank PeerSites may be created first; their route status is written only after the
origin claim succeeds. Target writes use the individual object versions from that read. A conflict aborts
the remaining projection and surfaces a discovery error; a later authenticated retry
reconciles the partial state. The claim is an operation marker, not a Secret, lease,
leader election mechanism or cross-object transaction.
Topology serialization is pinned in the shared bounded immutable-token cache. A topology
token cannot continue a record transfer, or vice versa. The receiver checks identity,
page boundaries, token and exact-byte digest before invoking the application’s
persistence callback. The topology supplier must include the local site exactly once.
Record publication succeeds independently of metadata. Topology network or persistence
errors appear in discoveryError; they do not undo a valid DNS snapshot or mark its
record transfer failed. Topology fetch has its own PEER_TIMEOUT network deadline. Local
metadata persistence has a separate 30-second internal DiscoveryTimeout budget so API
latency does not consume the network transfer deadline.
The Kubernetes layer reconciles each advertiser's metadata in PeerSite status, retains it through outages, and gives direct site advertisements precedence over indirect claims/bootstrap addresses. Local-ID matches and authenticated endpoints reporting the local ID invoke persistent quarantine with empty effective endpoints. Failed persistence is retried with a bounded local API deadline while in-memory quarantine remains active; reconfiguration cannot silently reactivate it. The persistence error remains visible until a successful retry. Discovered sites without credentials are visible but cannot transfer. Each direction needs its destination site's key; no key is automatically redistributed. File mode can exchange configured sites' records but does not automatically persist discovered PeerSites. See the resource reference.
The dynamic local TSIG provider reads current key material at verification and signing. Rotation drops the old local key once loaded, without listener restart. An outbound fetch captures its credential and rejects publication if the active remote credential changes during that attempt. A source’s Secret rotation does not erase records retained by remote sites.
Persisted PeerSite status.paths[origin] includes the receiver appended to the
validated path, paired with status.sources[origin] addresses. The serving peer
endpoint list may union valid indirect sources before direct contact. Re-export selects
one shortest deterministic complete route together with that route’s addresses,
preserving provenance rather than inventing a seed from merged cache addresses.
Successful catalogue omissions remove both sources and paths for that origin. Empty
discovered objects without live routes are retained but not advertised as local seeds.
This prevents withdrawn addresses circulating forever through a discovery cycle. Direct
self-advertisements retain precedence over indirect routes/bootstrap values, including
explicit empty lists. Editing the recorded bootstrap identity/address list explicitly
starts a new bootstrap attempt; a successful direct advertisement then captures that
new seed state and resumes normal discovered-endpoint precedence.
PeerSite count is not an admission condition for discovery or local configuration. Independent pods can create distinct sites concurrently without crossing a count threshold that invalidates later configuration refreshes. The topology transfer-byte bound remains enforced before accepting a complete received catalogue. An oversized catalogue appears as discoveryError; the separately accepted DNS record transfer still succeeds. The receiver’s own site is not automatically created as a discovered PeerSite. Existing explicitly configured self objects remain subject to quarantine.
