Deployment guide
This guide sets up DNS servers in your network that serve the zones you manage
in Valgrid. Each DNS server is an unmodified DNS server, such as CoreDNS or
BIND, with a valgrid-agent next to it. The agent reads one
namespace's DNS configuration from Valgrid and writes it as zone files for the
DNS server.
DNS servers keep answering from the zone files they last received while Valgrid is unreachable, so Valgrid is not in the path of your DNS queries.
Before you start
You need:
- An API token that you create, with
namespace:writeandzone:writeto create zones andagent:writeto register agents. See Authenticate. - A host or Kubernetes cluster in your network to run the DNS servers on, with outbound HTTPS access to the Valgrid API.
Prepare a namespace
A DNS server serves one namespace. Create a namespace, a zone and its records
as described in the API user guide, or with
vg:
export VALGRID_API_URL='https://api.valgrid.io'
export VALGRID_API_KEY='<API token>'
vg cr ns --name production
vg cr zone --name corp.internal --namespace-id <namespace_id>
vg cr rrset <zone_id> --name ns1 --type A --record 192.0.2.53
vg cr rrset <zone_id> --name www --type A --record 192.0.2.10
vg cr rrset <zone_id> --name localhost --type A --record 127.0.0.1
The localhost record is a harmless test record: localhost.corp.internal
always answers 127.0.0.1, which makes it easy to check a DNS server without
depending on your real records.
Give the zone's primary name server a record. By default it is ns1 inside the
zone; BIND refuses to load a zone whose in-zone name server has no A or
AAAA record.
Register an agent
Register one agent for each DNS server, so you can revoke a single server's
access without touching the others. Use a token with the agent:write
permission:
vg reg agent --name dns-1 --namespace-id <namespace_id> \
--credential-file agent-token
The agent's credential, vga_<agent_id>.<secret>, is shown only once.
--credential-file writes it straight into agent-token, readable only by
you, instead of printing it. Without it, vg prints the credential on
the last line; save it in your secret manager right away. To register agents
with the API instead, see Agents.
The credential can only read its namespace's DNS configuration. To revoke it,
delete the agent with vg del agent <agent_id>. See
vg for listing and renaming agents.
Run a DNS server with the agent
Run the agent next to an unmodified DNS server. The agent writes zone files
into a directory and the DNS server loads them; in containers the two share
that directory as a volume. The agent image is
ghcr.io/valgrid-dns/valgrid-agent; use the tag of a specific release, such as
ghcr.io/valgrid-dns/valgrid-agent:<version>, so that upgrades happen only when
you choose.
Pick a DNS server:
- CoreDNS: the simplest choice. It picks up changed zone files by itself.
- BIND: the agent reloads BIND over its control channel after each change.
Then pick where to run it:
- Docker Compose, with CoreDNS or BIND.
- Kubernetes, with CoreDNS.
- A Linux host without containers, with the agent as a
systemdservice.
Verify
Once the agent is running:
- Its logs show the configuration version it applied.
GET /v1/agents/<agent_id>shows a recentlast_checked_at.- The DNS server answers for the test record:
dig @<dns-server-address> localhost.corp.internal A +short
It prints 127.0.0.1.
Change a record through the API; the DNS server serves the new value within the agent's poll interval, 30 seconds by default.
Point clients at the DNS servers
The DNS servers answer only for your Valgrid zones; they do not resolve other
names. Keep your clients on their usual resolvers, and configure those
resolvers to send queries for your internal zones, such as corp.internal, to
the DNS servers. Point clients at the DNS servers has examples
for BIND, Unbound, dnsmasq, CoreDNS, Windows DNS Server and systemd-resolved.
Run at least two DNS servers so that one can be upgraded or restarted while the other answers.
Security checklist
- Keep API tokens and agent credentials in a secret manager, never in version control or container images.
- Give each DNS server its own agent credential, mounted as a file rather than an environment variable, and delete the agent when the server is retired.
- Expose the DNS servers only to the networks that need them.