How kudurru works

A visual tour of kudurru v0.2.0: where a DNS query goes, how a client's policy is chosen, how configuration travels from a YAML file or the dashboard to every node, and how the deployment shapes fit together. Every page leads with a picture and then explains it.

The optional DHCPv4 server, included since v0.1.0, runs on Linux with either store: node-local SQLite with standalone or three-node quorum operation, or DHCPScope/DHCPLease objects and one elected replica on the Kubernetes store. Both have dashboard setup.

This tour is for contributors and for operators who want to know what happens inside. For running kudurru, read the guide and the deployment docs. For why it is built this way, read the design record and its decision log (D1 onwards); where the code and the design record disagree, these pages follow the code and say so.

kudurru at a glance: clients, the optional edge, one kudurru node with its pipeline, snapshot, listeners and leader-only work, the store below and the internet on the right

The tour

PageWhat it shows
A query's journeythe ten pipeline stages, every way a query can leave them, and the status each outcome gets
Clients, policies and blockinghow a client is identified, how its policies are merged, how one name is judged, the block page and unblock requests
Block listshow a list is fetched once by the leader, shared with every node, compiled and swapped in
Upstreams and the cachewhich upstream group answers, strategies, server health, the cache and serve-stale
Zones and transfersauthoritative answers, serials, NOTIFY and AXFR/IXFR, secondary and stub zones, stored TSIG keys and RFC 2136 UPDATE
DHCPv4 and leasesthe optional server, dashboard setup, staged restart apply, live management and persistent leases
Configuration and the storethe object model, the two store drivers, the write path, the snapshot, leader election, settings, and enrolled SQLite primaries and followers
Background integrationsthe Integration object, the provider host, Cloudflare publication, UniFi inventory, Tier-B webhooks and the read-only DNSEndpoint source
Deployment shapesone container, Kubernetes, compose HA with dnsdist and keepalived, and what happens when something fails
Access: sign-in, tokens and RBACprincipals, the authentication chain, OIDC sign-in, authorization, the node-to-node plane
Licensing and license keyshow a key is verified offline, what each state changes, and the one promise: DNS never depends on a key
Observabilitythe query log pipeline, metrics, health probes and audit
Stopped-source rollupshow the central database owns rollups per source and recovers a stopped source

Five ideas that explain most of the design

  1. One binary, every node the same. Each replica runs the whole pipeline, the API and the dashboard. A few loops (status, serials, NOTIFY, list downloads) run on exactly one node, the leader.
  2. The store is the only source of truth for configuration. In Kubernetes it is the apiserver (CRDs); in Docker it is state.db. Everything else is derived from it or local to one node.
  3. The query path never touches the store. Each node watches the store and builds an in-memory snapshot. Queries read the snapshot without a lock, and the node keeps answering from it when the store is away.
  4. The pipeline is fixed. The stage order is code, not configuration, so every answer can be explained by the stage that produced it.
  5. Runtime data stays on the node. The query log, the response cache and list bodies are per node; only configuration is replicated.

One process, many loops

kudurru serve starts one runner. Loops in the first group run on every node from the start; loops in the second group run only while the node holds the leader election, and stop (without stopping the process) when it loses it.

flowchart LR
    subgraph every["every node"]
        direction TB
        dns["dns listeners<br/>udp tcp dot doh doq doh3"]
        zc["zonecache<br/>(store watch → snapshot)"]
        lr["list resolver<br/>(compile lists)"]
        xfr["secondary and stub managers,<br/>RPZ feed manager"]
        api["api + dashboard :8080"]
        ops["health :8081, metrics :9153"]
        internal["node-to-node :8082"]
        more["settings reload, objects loader (kube),<br/>query log writer, cache sweep and<br/>persist, block page, admin socket,<br/>external-dns webhook, audit shipper,<br/>query-log shipper, central database,<br/>optional DHCPv4"]
    end
    subgraph leader["leader only"]
        direction TB
        ctrl["controller<br/>(status, serials)"]
        notifier["NOTIFY out<br/>(kube: notifier loop,<br/>sqlite: serving writer)"]
        ol["objects loader<br/>(sqlite)"]
        lf["list fetcher<br/>(downloads)"]
        jan["unblock janitor"]
        dl["allow/deny list sync"]
        ap["audit retention<br/>(state.db, AuditLog batches)"]
        cj["central database janitor<br/>(with database.dsn)"]
        de["DNSEndpoint source<br/>(kube, opt-in)"]
    end
    elect{{"leader election<br/>kube: Lease kudurru-controller<br/>sqlite: the node with write authority"}} --> leader

Some loops start only when their feature is on (the block page, the external-dns webhook, the query log writer, the admin socket). There is no roles: setting: every node runs the full set.

With the SQLite store the election follows durable write authority (internal/store/sqlite, Elector): a standalone node and a static twin each lead themselves, and in an enrolled cluster only the primary leads. An enrolled follower, and a fenced or conflicted node, run no leader-only loop.

The objects loader, which applies objects: and the objectsDir files, is in both groups: every replica runs it on Kubernetes, and it is leader-only on SQLite, so an enrolled follower never applies its local files.

Ports

PortListenerWho calls it
53 udp/tcp (5353 behind an edge)DNSclients, or dnsdist with PROXYv2
67 udp (opt-in)DHCPv4 scopesdirect clients on UDP 68; trusted relays on their authorized source port
Operator-selected TCP peer port (opt-in)DHCPv4 quorummutually authenticated replication and forwarded management between three voters
853 tcp / 443 tcp / 853 udp / 443 udpDoT, DoH, DoQ, DoH3 (off by default)clients
8080REST API /api/v1 and the dashboardbrowsers, the CLI, automation
8081/healthz/*, /lameduck (no auth)probes, kudurru health, kudurru lameduck
8082node-to-node API (always TLS + token)other replicas, edge supervisors
9153/metricsPrometheus
80 (443)block page (when enabled)browsers sent there by a block answer
127.0.0.1:8888external-dns webhook (when enabled)external-dns
unix /run/kudurru/kudurru.sockadmin socketkudurru admin inside the container

Built and not built

The design record plans more than v0.2 ships. These pages describe the code. The main gaps between the two:

Planned in the design recordState in the code
Complete pipeline (local, rewrite, …)10 installed stages, including DNSSEC, configured rewrites and the postprocess wrapper; local remains reserved
follower and raft store driversstore.driver is kube or sqlite. A SQLite node can be enrolled as a primary or a follower: a follower installs the primary's complete image over member mutual TLS, and promotion is a reviewed operator command (configuration and the store). There is no raft store driver, and a follower is never promoted automatically
scatter-gather across nodesthe node list, the stats and the query log are gathered over :8082 (or read from the central database with database.dsn); /nodes/{other}/health reads the named peer's health over :8082
cluster-wide temporary disable of blockingreplicated: Kudurru.status.blocking on the complete SQLite runtime (an enrolled follower forwards the command to its primary), and a kudurru-runtime ConfigMap annotation that every replica reconciles on Kubernetes; static SQLite twins keep node-local state (blocking)
client match by MAC, hostname, DoT/DoH client IDimmutable inventory matching and opt-in encrypted-transport IDs are implemented. Integrations fill the inventory on the complete SQLite runtime, and UniFi fills it on Kubernetes (D384); DHCP lease names and the optional reverse-PTR lookup supply hostnames on both stores. The dnsdist edge derives the same DoT/DoQ server-name and DoH/DoH3 path IDs and sends them in the secret-authenticated TLV 0xE1 (D389)
cluster.role: static read-only twinshost-configured peers, authenticated status and file-managed SQLite twins; independent local leadership; API object and cluster-setting writes answer 503 read_only
secondary zones, NOTIFY in, dynamic UPDATEindependent secondary AXFR/IXFR over TCP/TLS with authenticated NOTIFY fan-out, stub zones, and RFC 2136 UPDATE on both stores (one SQLite transaction; one UPDATE-owned record set per zone on Kubernetes). IXFR out still answers in AXFR form: there is no journal
DHCP server supportDHCPv4 has shipped since v0.1.0 on Linux: SQLite standalone or three-node quorum failover, or the Kubernetes store with DHCPScope/DHCPLease objects and one elected replica behind a relay; dashboard setup, direct/relayed subnets, conflict checks, advanced network/boot options, live management, lease import/export and persistent A/PTR ownership; DHCPv6 is excluded
Kubernetes Events from the controllerevents are logged only

The open list lives in follow-ups.

What depends on the store driver

These features behave differently on the two drivers. "Complete SQLite" means the runtime that serve builds for store.driver: sqlite (newServingRuntime in cmd/kudurru). A 503 in the Kubernetes column is an explicit JSON refusal; the error key is shown where it is specific to the feature.

FeatureComplete SQLiteKubernetes
Transferred RPZ feeds (block lists)per-node feed manager; bound into each complete serving bundleper-node feed manager with the stored TSIG source; each query binds its own policy decision's lists to the node's feed snapshot (D390)
Integration host (integrations)mountedevery replica runs the host with one Lease per Integration: Cloudflare publication and UniFi inventory and groups; webhook instances and UniFi record publication are refused on their object (D384). Commands run on the Lease holder. The read-only DNSEndpoint source is separate and Kubernetes-only
RFC 2136 UPDATE (zones)one transaction with durable primary historyone UPDATE-owned DNSRecordSet per zone, exact resourceVersion CAS
Stored TSIG key management (zones)current commands in one transactionexact-version writes; every node rereads the source every ten seconds
Blocking toggleKudurru.status.blocking in the canonical storekudurru-runtime ConfigMap annotation, reconciled every second
Cluster settings writescanonical Kudurru/default commandssettings ConfigMap; only upstreams can move to UI ownership
TOTP management (access)mounted503 factor_management_unavailable
Session inventory and revocationdurable sessions; own-session list and revokesealed cookies; 503 sessions_unavailable
RoleBinding write APIreviewed create, replace and delete503 unavailable; bindings are CRDs, and their revocation floors persist in the kudurru-grant-floors Secret
Local user create and password reset APImounted503 user_management_unavailable
External account administrationmounted503 external_users_unavailable
Enrollment, join tokens and promotionnonstatic nodes only503 unavailable; replicas share the apiserver instead

Reading the diagrams

Two kinds of pictures appear on these pages:

  • Hand-drawn diagrams (diagrams/*.excalidraw.svg) give the big picture. Each SVG embeds its Excalidraw scene: open it at excalidraw.com (menu → Open) or with the Excalidraw extension for VS Code, edit it, and export it again as SVG with "Embed scene" checked, under the same name.
  • Mermaid diagrams (in the markdown) show flows, sequences and states. GitHub and the docs site render them; edit them as text.

Colors in the hand-drawn diagrams:

ColorMeaning
claykudurru code
blueclients, people and tools
purplednsdist and keepalived (GPL, separate processes)
stonestored data
yellowleader-only work, warnings
green / redan answer / a block
whitesystems outside kudurru

Source: docs/architecture/README.md