Overview
This template provides a production‑ready CoreDNS instance as a Monk runnable. You can:- Run it directly to get a managed CoreDNS container with sensible defaults
- Inherit it in your own runnable to seamlessly add a flexible, extensible DNS server to your infrastructure
What this template manages
- CoreDNS container (
coredns/corednsimage, configurable tag) - DNS service on port 53 (UDP)
- Custom CoreDNS configuration (Corefile)
- Plugin-based DNS functionality
- Persistent volume for zone files and configuration
Quick start (run directly)
- Load templates
- Run CoreDNS with a custom zone domain
- Customize configuration (recommended via inheritance)
variables. For production use, it’s recommended to inherit this runnable and customize the configuration.
- Preferred: inherit and override variables as shown below.
- Alternative: fork/clone and edit the
variablesincoredns/coredns.yaml, thenmonk load MANIFESTand run.
Configuration
Key variables you can customize in this template:${monk-volume-path}/coredns on the host. Place your zone database files (e.g., example.local.db) in this directory.
The default Corefile configuration includes:
- A catch-all zone (
.) that forwards queries to upstream DNS servers - A custom zone configured via
zone-domainvariable that serves from a zone file - Logging and error reporting enabled
- 5-second reload interval for zone file changes
Use by inheritance (recommended for infrastructure)
Inherit the CoreDNS runnable in your networking infrastructure:Ports and connectivity
- Service:
dnson UDP port53 - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the DNS server host.
Plugins
CoreDNS supports a wide range of plugins. The default configuration uses:- forward: Forwarding queries to upstream DNS servers (8.8.8.8, 9.9.9.9)
- file: Serving zone data from files
- log: Query logging
- errors: Error logging
- kubernetes: Service discovery for Kubernetes
- cache: Caching DNS responses
- prometheus: Exporting metrics to Prometheus
- rewrite: Rewriting queries
- etcd: Backend storage in etcd
- loadbalance: Load balancing with random selection
Persistence and configuration
- Zone files path:
${monk-volume-path}/coredns:/config - Corefile location:
/etc/coredns/Corefile(in container) - You can place additional zone files in the config path and reference them in your Corefile
Zone file format
Zone files follow standard DNS zone file format (RFC 1035). Example:Related templates
- See other templates in this repository for complementary services
- Combine with monitoring tools (
prometheus-grafana/) for observability - Integrate with your application stack as needed
Troubleshooting
- Ensure port 53 is available and not blocked by another DNS service
- Verify your Corefile configuration is valid (use
coredns -conf /etc/coredns/Corefile -validateinside the container) - Ensure zone files exist in the config directory and have correct permissions
- Check that
zone-domainvariable is set when running the template - Check logs:
- Test DNS resolution:
- Verify zone file syntax:
- If queries are not being answered, ensure the zone file matches the
zone-domainvariable (e.g., ifzone-domain=example.local, the zone file should be namedexample.local.db)