Split the console from the resolver: fancy-dns-console writes the cluster

fancy-dns-console is a second binary holding the web UI, authentication and
every edit. It writes ClientGroup, BlockList and DNSZone objects through the new
kubeedit package and forwards all other /api routes to a running resolver
with its own key, dropping the browser's credentials, so it can run in the
cluster or on a workstation with a kubeconfig and nothing about the resolver's
placement matters. The resolver never imports kubeedit and the console is not on
the DNS path.

kubeedit validates every spec with the runtime's own converters
(kubesource.CheckGroup/CheckList/CheckZone) before writing, so the console
cannot store an object the resolver would reject. Zone edits keep the
file-based writer's behaviour: duplicate and below-a-delegation records are
refused, a delegation in a new zone also gives the zone its servers, and a
zone with no apex NS is never stored. Each object records the editing user in
an annotation; updates retry on conflict.

The resolver reports groups from ClientGroup objects as source "kubernetes" and
counter-only rows (the "(default)" bucket, or a group removed since) as
"history", and lists DNSZone zones as the editable ones. The console uses that
to leave the YAML's groups alone and to drop history rows, which the UI would
otherwise send back on save. Its GET /api/clients overlays the cluster's
current objects on the resolver's list, because the resolver only sees an edit
after its watch fires and a save made just after another would delete the
first.

An end-to-end test runs both halves against one fake apiserver: a group saved
through the console refuses queries, a zone built record by record answers
authoritatively, and a request with the resolver's own key is rejected by the
console.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
matsandClaude Sonnet 5.5 committed 2026-10-16 08:43:41 +02:00
1 parent 4d38945d94
commit 1a536e7d0e
25 files changed
+1950 -8

No files matched your search

+4 -1
View File
@@ -183,11 +183,14 @@ func TestAdminEndpointKeySets(t *testing.T) {
// so every group card read "matches nothing" and the editor sent a
// shape the server refused. `comment` stays omitempty: a group without
// one must not carry a key the console would have to special-case.
// `source` is omitted for a group from the config file. It is present
// here because the queries above made groups[0] the "(default)"
// traffic bucket, which is reported as source "history".
requireKeys(t, "GET /api/clients groups[0]", keysOfField(t, body, "groups", "0"),
wantKeys("allow_domains", "blocked_count", "client_count",
"deny_domains", "log_queries", "match", "max_concurrent", "matched",
"name", "policy", "query_count", "rate_limit", "skip_blocklist",
"skip_cache", "upstreams"))
"skip_cache", "source", "upstreams"))
requireKeys(t, "GET /api/clients groups[0].match", keysOfField(t, body, "groups", "0", "match"),
wantKeys("any", "cidrs", "ptr_suffixes", "tags"))
})