Kubernetes resources and persisted state

The application reads/writes ordinary Kubernetes resources. There is no separate configuration database, local remote-record store or required external key service. Installation and Orbit Deploy ownership are covered in running.

Installed objects

Install deploy/crds.yaml first and wait for its three CRDs for namespaced resources to be Established. All serve/store dns.tak-os.io/v1alpha1:

CRD Kind Runtime scope
dnszones.dns.tak-os.io DNSZone Read only from POD_NAMESPACE, the administration namespace.
dnsrecords.dns.tak-os.io DNSRecords Read only from POD_NAMESPACE, the administration namespace.
peersites.dns.tak-os.io PeerSite Read only from POD_NAMESPACE, the administration namespace.

The base manifest installs a Namespace, ServiceAccount, ClusterRole/Binding, Role/Binding, settings ConfigMap, example DNSZone and DNSRecords, DaemonSet and two Services. The optional Ingress adds the management route. The local TSIG Secret is generated by the app if absent; it is not seeded with an empty placeholder Secret. The example does not install a PVC, NetworkPolicy, PDB, LoadBalancer controller, node-IP advertisement system or external certificate issuer.

DNSZone

apiVersion: dns.tak-os.io/v1alpha1
kind: DNSZone
metadata:
  name: example-com
  namespace: tak-os-dns
spec:
  name: example.com.
  ttl: 60
  soa: false

spec.name is the DNS zone; metadata.name is the Kubernetes resource name. ttl defaults to 60 in application normalization. soa defaults false; true creates an SOA using optional ns and admin. With SOA enabled and no NS list, ns1.<zone> is the default MNAME/NS. An explicit ns list generates apex NS records even with SOA disabled. Empty ns with SOA false creates no apex NS. Nameserver addresses are separate records. Duplicate canonical zone names in the administration namespace reject the assembled configuration. A DNSZone is optional: removing one does not remove standalone DNSRecords or otherwise eligible generated names.

DNSRecords

apiVersion: dns.tak-os.io/v1alpha1
kind: DNSRecords
metadata:
  name: application-extras
  namespace: tak-os-dns
spec:
  records:
    - {name: api.example.com., type: A, ttl: 60, value: 192.0.2.40}
    - {name: old.example.net., type: CNAME, ttl: 60, value: api.example.com.}
    - {name: moved.example.org., type: DNAME, ttl: 60, value: new.example.org.}
    - {name: verification.example.com., type: TXT, ttl: 300, value: '"application-proof"'}

One CR is a logical administrative group. It may contain different names, types and zones and does not depend on DNSZone existence. Names must end in a dot; relative owners and @ are not valid CR owners. Supported types and RDATA are in records. Zero TTL becomes 60 for these standalone entries. Optional zone establishes explicit ownership and requires that zone to exist; omit it for independent records. The source tag is dnsrecords/<object UID>. The CR schema caps a group at 100,000 entries; aggregate/cache limits also apply. Deleting a CR removes only that group's contributions after successful reconciliation.

PeerSite spec and discovered status

apiVersion: dns.tak-os.io/v1alpha1
kind: PeerSite
metadata:
  name: west
  namespace: tak-os-dns
spec:
  id: site-west
  addresses: [192.0.2.20]
  keySecretRef: west-tsig
  disabled: false

id is the expected remote CLUSTER_ID. addresses is an ordered bootstrap list, possibly empty; literal IPs default to TCP 53, and explicit IP:port endpoints are supported. keySecretRef selects a Secret in the administration namespace. If omitted, its name is tak-os-dns-peer- plus the first 16 hexadecimal characters of SHA-256(site ID). Missing credentials leave the site Pending credentials. Referencing the local site TSIG Secret as a remote credential is rejected to prevent accidental local key overwrite or identity aliasing. disabled forces effective endpoints empty without deleting retained DNS data.

Authenticated discovery creates missing PeerSites with deterministic names discovered-<first 24 hex characters of SHA-256(site ID)>, empty bootstrap spec and dns.tak-os.io/discovered-from annotation. The receiver’s own site is not auto-created; existing explicit self objects remain quarantined. There is no fixed PeerSite-count ceiling: concurrent discoveries can add distinct sites without making the aggregate configuration invalid because of its peer count. Catalogue transfers retain the byte bound described in capacity. Discovery writes the status subresource:

Field Meaning
discoveredAddresses Current discovered effective endpoint list.
sources Map from immediate authenticated advertiser ID to its advertised endpoints for this site.
paths Per-advertiser path vectors from described site through the authenticated origin to this receiver; paired with sources.
provenance Sorted advertiser identities represented in sources.
lastDiscovery RFC3339 marker/time for a direct self-advertisement or self quarantine. Repeated unchanged advertisements need not advance it.
self Persistent quarantine: this object identifies the local site. Effective endpoints stay empty.
observedBootstrap Identity and ordered configured seed addresses captured at successful direct discovery. A changed spec identity/seed list explicitly reboots discovery through those new seeds.
sourceVersions Per-advertiser catalogue ordering floors; every existing PeerSite advances its floor, including unchanged routes, blank objects and retained withdrawals, to reject concurrent stale writers.
routeVersions Per-advertiser source-ordering map belonging to this described site's route, preserved on transitive export.
catalogueClaim Fresh random operation marker on an advertiser's own PeerSite. Forces a real status change and optimistic-write barrier even when retrying an identical catalogue.

Before a direct advertisement, discovered endpoints supplement bootstrap entries; indirect addresses are a sorted union of sources with valid bounded provenance paths. Each persisted path includes this receiver; returning/cyclic paths are dropped and successful catalogue omissions retract that origin’s route. Exports select one shortest deterministic route and its own addresses, not the union. An empty discovered object without a live route is not re-advertised as a seed. A source's complete successful topology update removes its omitted indirect contributions. After the remote site advertises its own addresses, that list replaces bootstrap endpoints and takes precedence over indirect claims, including an explicit empty list. Outages do not erase metadata. Explicit edits to spec.id or ordered spec.addresses are compared with observedBootstrap: changed seeds become effective until a new successful direct advertisement captures them. Unchanged retired seed addresses do not reappear through ordinary polling. Legacy status without observedBootstrap retries configured nonempty seeds once until a successful direct contact establishes the marker; upgrade does not leave an already unreachable site permanently stuck. Persisted source/route versions reject older catalogues before any endpoint changes, including stale omissions; optimistic status updates prevent concurrent writers from silently overwriting newer state. Neither discovery nor its status writes include TSIG secrets or imported DNS records. GitOps owns spec independently of status.

Local-ID matches and signed endpoints identifying the local site are quarantined. Stored bootstrap spec may remain for GitOps ownership, but self/disabled removes every effective endpoint. Quarantine is not automatically cleared by new advertisements. See peer administration.

TSIG Secrets

The local Secret name defaults to tak-os-dns-tsig (LOCAL_TSIG_SECRET override). Remote credentials use each PeerSite's Secret selection above. Each is Opaque:

apiVersion: v1
kind: Secret
metadata:
  name: west-tsig
  namespace: tak-os-dns
type: Opaque
stringData:
  keyName: site-west.
  algorithm: hmac-sha256.
  secret: MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY=

This is a documentation-only key. Generate/export a real private key in the UI. Kubernetes stores these text values in base64 data. The secret text is itself a base64 TSIG value. Keys reload each local cycle. Creation uses GET/POST with AlreadyExists recovery; an existing object wins unchanged. UI writes use resource versions and preserve unrelated Secret data/metadata. GitOps or ESO can own the same lifecycle; the app never updates remote clusters automatically. Details and rotation effects are in security.

Settings, reads and writes

Only data.queryLogging remains in the named settings ConfigMap (CONFIGMAP_NAME, default tak-os-dns). Old config.json content is not migrated or used as DNS configuration. Settings writes preserve unrelated fields and can create a missing ConfigMap. The management API writes CR spec per object, PeerSite status for discovery, local/remote Secrets for credentials, and the logging setting.

The app lists Services and Nodes cluster-wide, Ingresses in networking.k8s.io, and optional tak-os.org/v1 ExternalIPBindings across all namespaces; their UID/resourceVersion tracks ownership. It never writes those generated sources, patches Service externalIPs or changes its DaemonSet. Complete paginated lists reject partial/inconsistent collections.

Service, Ingress and ExternalIPBinding annotations control generated-record opt-out and ingress-class CNAME targets; see Kubernetes annotations. Class mapping uses the annotation and Ingress spec.ingressClassName directly; the DNS ServiceAccount does not need to read IngressClass resources. These annotations and fields remain owned by the manifests/controllers that manage the source objects; DNS never writes them.

The shipped ClusterRole grants get/list Nodes, Services and Ingresses and list ExternalIPBindings (tak-os.org). The Role grants administration-namespace get/create/update ConfigMaps/Secrets, get/list/create/update/delete DNSZones, DNSRecords and PeerSites, and get/update PeerSite status. These are broad management powers: any management API caller effectively acts through this ServiceAccount. Apply the external authentication boundary.

Workload and service exposure

For topology, DNS_SERVICE_NAME (default tak-os-dns) selects the administration namespace DNS Service. Only the intersection of its externalIPs and Node ExternalIPs is advertised, so a newly added but unexposed node is not offered as a usable peer route. This does not automatically maintain the Service IP list.

The DaemonSet schedules a DNS pod on each eligible node under normal Kubernetes scheduling/taint rules; it has no host networking or host ports. The DNS Service selects app: tak-os-dns, exposes UDP/TCP 53 and uses externalTrafficPolicy: Cluster with site-managed externalIPs. Node addresses must already route correctly; the Service does not allocate or advertise them. Nodes without a ready local pod can forward to another ready pod. Management is a separate ClusterIP Service on 8080. The optional Ingress terminates TLS and delegates user authentication.

Persistence boundary

Persisted locally: CR definitions, PeerSite discovery metadata/quarantine, TSIG Secrets and query-logging setting. Memory-only per pod: generated/merged snapshots, imported DNS records, accepted remote watermarks, journals, prepared transfer tokens and runtime metrics/status. A full pod restart re-learns remote DNS records. Metadata persistence does not persist the DNS record cache.

Management validation and recovery

UI/API writes validate individual CR syntax and, when the current assembled configuration is valid, validate the proposed whole aggregate before mutation. Duplicate canonical zones/peer IDs, cross-group alias conflicts or removing a zone still explicitly referenced by records fail with HTTP 400. Repair those references before deleting that zone. A plain unbound DNSRecords group remains independent of DNSZone existence. Existing invalid aggregates permit individual valid repairs so operators can fix separate objects incrementally.

GitOps writes and concurrent edits in different pods can still race across objects. Reconciliation validates the complete candidate and retains last-good state on errors. Object resource versions protect each individual write, not a cluster-wide transaction. The app never silently rewrites GitOps-owned CR metadata to resolve a conflict.