Files
fancy-dns/deploy/k8s/console/console.yaml
T
matsandClaude Sonnet 5.5 88479b9a12 Add AddressOverride and DomainRule objects for what lived in a ConfigMap and the config file
The address redirects page rewrote an RPZ ConfigMap through the resolver's own
service account, and the domains page rewrote allow_entries/block_entries in the
config file. Both become cluster objects like the rest.

AddressOverride is one name answered with fixed addresses (the name and
everything under it), exactly what an RPZ "name A address" line did. DomainRule
is a block or allow list of inline names. The resolver reads both with the
existing watch: overrides are rendered into the managed RPZ source the blocklist
manager already has, and rule names join the config's inline entries in the
merged overlay, so the file's config is never written to.

Names are checked to be DNS names or wildcard patterns before they are used,
because they are joined into line-oriented parser input and a newline or a
comment character in one would otherwise add a rule of its own.

The console edits both: the address-overrides and domains endpoints now write
objects. The console keeps its added rules in one DomainRule per action
(inline-block, inline-allow) instead of an object per name, and removes a name
from whichever DomainRule holds it, wildcard or not. An end-to-end test drives
the pages' endpoints and checks the resolver's answers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 10:08:08 +02:00

114 lines
3.7 KiB
YAML

# The console: web UI plus the API behind it, as its own Deployment. It writes
# ClientGroup / BlockList / DNSZone objects and forwards everything else to the
# resolver's admin API. It is not on the DNS path; stopping it changes no answer.
#
# Secrets it needs (create them out of band):
# fancy-dns-console-runtime key FANCYDNS_RUNTIME_KEY : an API key the resolver accepts
# fancy-dns-console-apikey key FANCYDNS_API_KEY : the console's own machine key
apiVersion: v1
kind: ConfigMap
metadata:
name: fancy-dns-console
namespace: dns
data:
console.yaml: |
# The console has no blocklists or listeners of its own.
blocklist: {enabled: false}
api:
enabled: true
listen: ["0.0.0.0:8080"]
base_path: /api
ui: true
auth:
mode: oidc
api_keys: ["${FANCYDNS_API_KEY}"]
oidc_issuer: https://users.k6n.net
oidc_audience: https://dns.k6n.net
oidc_redirect_uri: https://dns.k6n.net/auth/oidc/callback
oidc_client_id: fancy-dns
oidc_write_roles: [admin]
trust_loopback: false
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fancy-dns-console
namespace: dns
---
# The only component allowed to write the objects.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: fancy-dns-console
namespace: dns
rules:
- apiGroups: [fancydns.k6n.net]
resources: [dnszones, clientgroups, blocklists, addressoverrides, domainrules]
verbs: [get, list, create, update, delete]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: fancy-dns-console
namespace: dns
subjects:
- {kind: ServiceAccount, name: fancy-dns-console, namespace: dns}
roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: fancy-dns-console}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fancy-dns-console
namespace: dns
labels: {app.kubernetes.io/name: fancy-dns-console}
spec:
# One replica: OIDC login state and sessions are in memory, as in the
# resolver's console. More than one needs sticky routing.
replicas: 1
selector:
matchLabels: {app.kubernetes.io/name: fancy-dns-console}
template:
metadata:
labels: {app.kubernetes.io/name: fancy-dns-console}
spec:
serviceAccountName: fancy-dns-console
securityContext:
runAsNonRoot: true
runAsUser: 65532
seccompProfile: {type: RuntimeDefault}
containers:
- name: console
image: fancydns/fancy-dns:latest
command: ["/usr/local/bin/fancy-dns-console"]
args:
- -config=/etc/fancy-dns/console.yaml
# A Service in front of the resolver pods. With several replicas, the
# per-pod views (status, cache, upstreams) come from whichever pod answers.
- -runtime-url=http://fancy-dns-admin.dns.svc:8080
env:
- name: FANCYDNS_RUNTIME_KEY
valueFrom: {secretKeyRef: {name: fancy-dns-console-runtime, key: FANCYDNS_RUNTIME_KEY}}
- name: FANCYDNS_API_KEY
valueFrom: {secretKeyRef: {name: fancy-dns-console-apikey, key: FANCYDNS_API_KEY}}
ports: [{name: http, containerPort: 8080}]
readinessProbe:
httpGet: {path: /api/healthz, port: http}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: {drop: [ALL]}
volumeMounts:
- {name: config, mountPath: /etc/fancy-dns, readOnly: true}
volumes:
- name: config
configMap: {name: fancy-dns-console}
---
apiVersion: v1
kind: Service
metadata:
name: fancy-dns-console
namespace: dns
spec:
selector: {app.kubernetes.io/name: fancy-dns-console}
ports: [{name: http, port: 80, targetPort: http}]