Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 4.5 KB

replication.md

File metadata and controls

97 lines (73 loc) · 4.5 KB

Replication Model

The replicator bridges two trust boundaries: the upstream tenant control plane, where users author DNS resources, and the downstream authoritative cluster, where the DNS backend runs. It mirrors desired state down, realized status up, and never gives tenants access to the authoritative cluster.

This document describes how that bridge works. For where each side runs, see Deployment Topology.

Upstream and Downstream

  • Upstream — a tenant / project control plane (or, in single mode, the local cluster) holding the user-facing DNSZone and DNSRecordSet.
  • Downstream — the shared authoritative cluster where the DNS backend and the downstream agent run.

For every upstream resource, the replicator maintains a shadow object downstream. The downstream agent programs the backend from the shadow and writes realized status onto it; the replicator mirrors that status back upstream. A change on either side wakes the replicator via cross-cluster watches.

Replication Flow — desired state down, realized status up

Shadow Objects and Namespace Mapping

Kubernetes does not support cross-cluster ownership references, so the replicator uses a mapped-namespace strategy to place and track shadows:

  • Each upstream namespace maps to a downstream namespace named from the upstream namespace's UID (ns-<uid>), keeping tenant namespaces collision-free without leaking their names.
  • The shadow keeps the same object name as its upstream source.
  • Provenance annotations (meta.datumapis.com/upstream-*) record the source cluster, group, kind, name, and namespace on every shadow.
  • An anchor object downstream stands in for the missing cross-cluster owner reference, so garbage collection cleans up shadows when the upstream resource is deleted.

Deletion flows downstream-first: the replicator removes the shadow (and its backend state) before releasing the upstream finalizer, so a deleted zone stops resolving before it disappears from the tenant's view.

Status Synthesis

The replicator computes the two conditions users watch, combining upstream validity with downstream reality:

Condition Set to True when
Accepted The resource is valid, its dependencies exist, and (for zones) the operator knows the authoritative nameservers
Programmed The backend has realized the desired state — for a zone, its default SOA and NS record sets exist; for a record set, the backend has applied it

The replicator mirrors record-set status straight from the downstream shadow, including per-owner results, so a user sees exactly what the backend realized. Zone status also reports the authoritative nameservers and a record count.

Zone Ownership Accounting

Because many tenant control planes feed one authoritative cluster, two tenants could request the same domain. The replicator guards against that collision with an ownership ledger in the authoritative cluster, keyed by domain name. The first zone to claim a domain wins. The replicator holds a later claimant's zone with Accepted=False (reason DNSZoneInUse) and emits a warning event, rather than overwriting the incumbent. The replicator releases ownership when the owning zone is deleted.

Default SOA and NS Records

A zone is not authoritative until it has SOA and NS records. Once the operator knows the zone's nameservers (from its DNSZoneClass nameserver policy), the replicator ensures two operator-managed record sets exist for the apex (@):

  • an NS set that lists the authoritative nameservers, and
  • an SOA set whose primary nameserver is the first of those, with a hostmaster address derived from the domain and default refresh, retry, and expire values.

The replicator creates these sets only when they are missing, so it never overwrites user-authored apex records. The operator synthesizes a date-based SOA serial (YYYYMMDD01) when a record omits one.

Discovery of Zone Records

DNSZoneDiscovery is a one-shot, read-only companion resource. The replicator resolves the referenced zone's live records over DNS and writes them into the resource's status. Use it to snapshot existing DNS during onboarding or verification; it performs no mirroring and no backend writes.

Related