CoreDNS
CoreDNS is the simplest DNS server to run with the agent: its auto plugin
loads every zone file the agent writes and picks up new, changed and deleted
zones by itself, so the agent never has to reload it.
To run it, see Docker Compose, Kubernetes or a Linux host.
The starter Corefile
When the agent runs with the coredns profile (VALGRID_SERVER=coredns, or
VALGRID_COREFILE set) and no Corefile exists yet, it writes this one, by
default as Corefile in the zone directory. With -init it writes the file
and exits, which is how the examples prepare it before CoreDNS starts:
. {
# Serve every zone file valgrid-agent writes, and pick up new, changed
# and deleted zones without a restart.
auto {
directory /var/lib/valgrid
reload 10s
}
# Apply edits to this file without a restart.
reload
errors
# Liveness on :8080/health and readiness on :8181/ready.
health :8080
ready :8181
}
The agent never changes or replaces an existing Corefile, so your edits are kept.
This CoreDNS is authoritative only: it answers for your Valgrid zones and refuses other names. Clients reach it through their usual resolvers; see Point clients at the DNS servers.
Use your own Corefile
To add plugins, such as cache, prometheus or log, write your own Corefile
and give it to CoreDNS instead of the starter one. Keep the auto block
pointing at the zone directory:
. {
auto {
directory /var/lib/valgrid
reload 10s
}
reload
errors
log
cache 30
prometheus :9153
health :8080
ready :8181
}
With Docker Compose, mount the file into the CoreDNS container and drop the
agent-init service, which is then not needed:
coredns:
image: coredns/coredns:1.15.0
command: ["-conf", "/etc/coredns/Corefile"]
volumes:
- ./Corefile:/etc/coredns/Corefile:ro
- zones:/var/lib/valgrid:ro
On Kubernetes, store it in a ConfigMap, mount it at /etc/coredns, set the
CoreDNS container's args to ["-conf", "/etc/coredns/Corefile"] and remove
the agent-init init container.
CoreDNS must see the zone directory at the same path as the agent,
/var/lib/valgrid in the agent image.