How briankohler/dnsapi works
Based on our analysis of the file tree and README, this project is a containerized, full-stack DNS management service. Its core purpose is to expose a REST API (written in Go) to manage TinyDNS zone files, which are subsequently served via the TinyDNS service fronted by an Unbound caching resolver. Consul is used as the persistent data store (and, optionally, as a FUSE-backed filesystem for the zonefile), and there is optional integration with S3 for versioning and backup.
• DNS API Service: Represented by the “dnsapi” container which contains the Go source (organized in subdirectories such as “dnsapi”, “consulhelper”, “helper”, “log”, and “logmiddleware”). This component accepts REST calls (on port 9080) and implements business logic for record manipulation.
• TinyDNS Service: Represented by the “tinydns” container (with its own Dockerfile, configuration, and start script). It is responsible for serving the DNS zone files generated/updated by the API.
• Unbound DNS Resolver: Represented by the “unbound” container. It is used as a caching DNS resolver and listens on port 53.
• Persistent Data Store (Consul): Shown as an external or auxiliary component (backed by the “consuldata” directory), which is used by the API to persist DNS data. Optionally, this is also involved in providing a FUSE-backed filesystem to the TinyDNS service when the experimental USE_CONSULFS flag is set.
• Optional Components:
• DNS Dummper: There is a “dnsapidumper” service that appears designed to dump or backup zone file information.
• S3 Backup: Indicate that when provided AWS credentials and the S3_BUCKET environment variable, the tiny datafile can be backed-up/versioned with Git and S3.
Relationships and Interactions
• REST Client (or even a cURL command, as shown in the README) interacts with the DNS API service.
• The DNS API service processes requests (e.g., creating, updating, or deleting A, NS, CNAME, SOA records) and interacts with Consul for persistent storage.
• When records are changed, the API updates the TinyDNS zonefile (and possibly uses the “dnsapidumper” to reflect those changes).
• The TinyDNS service, in its container, reads and serves the updated zonefile.
• Unbound operates on top of every change as a caching front-end, effectively serving DNS requests based on the latest zonefile.
• Optional: When configured, S3 integration backs up versioned zonefiles, and the experimental FUSE-based mounting (with USE_CONSULFS) changes how the zonefile is accessed by TinyDNS.
Architectural Patterns and Design Principles
• Modular Separation: The Go application is neatly segmented into packages managing different responsibilities (record handling, logging, and Consul integration).
• Containerization: All services (API, TinyDNS, Unbound) are containerized (Dockerfiles are provided) and orchestrated with a docker-compose.yml file.
• Service Interaction: The use of environment variables (like USE_CONSULFS and S3_BUCKET) and external configuration files points to a design that emphasizes flexible deployment.
Technologies, Frameworks, and Libraries
• Go language for building the API.
• Docker for containerization (each service has its own Dockerfile).
• Docker Compose for service orchestration.
• Consul for persistence and as an experimental FUSE filesystem backend.
• Unbound DNS caching resolver.
• TinyDNS for generating/serving zone files.
• (Optionally) AWS S3 for file versioning and backup combined with Git-versioning.
Final Reminder to the Principal Software Engineer
• Every major component (API, TinyDNS, Unbound, Consul/S3) is clearly labeled.