l2sm-dns is a DNS service component for the l2sm project. It provides a standard layout for Go-based CLI applications and services, enabling you to manage DNS entries via a gRPC server that integrates with CoreDNS and deploys seamlessly on Kubernetes.
The repository is organized as follows:
- cmd/
- server/: Contains the gRPC server implementation (
server.goandmain.go) that listens on port8081and integrates with CoreDNS.
- server/: Contains the gRPC server implementation (
- api/
- v1/dns/: Holds the API definitions (e.g.,
dns.proto) and generated gRPC code (dns.pb.go,dns_grpc.pb.go).
- v1/dns/: Holds the API definitions (e.g.,
- pkg/
- coredns-manager/: Implements the CoreDNSManager used to update the CoreDNS ConfigMap dynamically.
- config/
- rbac/: Kubernetes RBAC manifests for service accounts, roles, and role bindings.
- dev/: Patches for local development (e.g., deleting or patching CoreDNS deployments).
- server/: Kubernetes manifests (deployment, service, configmap) to run the DNS service in a cluster.
- default/: Default kustomize configurations.
- test/
- Contains end-to-end and integration tests, along with a sample DNS client (
client.go) and configuration (config.yaml).
- Contains end-to-end and integration tests, along with a sample DNS client (
- deployments/
- Kubernetes YAML manifests for deploying the service.
- examples/
- quickstart/: A Kind cluster configuration to quickly set up a local Kubernetes environment.
- Makefile
- Provides common tasks for building, testing, and running the project.
- Dockerfile
- For containerizing the DNS gRPC server.
- Go (1.x or later)
- Docker (for building container images)
- Kubernetes cluster (or Kind for local testing)
- kubectl (to interact with your cluster)
- Make (for build automation)
git clone https://github.com/Networks-it-uc3m/l2sm-dns.git
cd l2sm-dnsIf you fork or move the repository, update the module path in go.mod:
go mod edit -module github.com/<your-org>/l2sm-dns
go mod tidyBuild the project using the Makefile:
make buildRun tests:
make testTo run the DNS gRPC server locally, execute:
make run-serverThe server listens on port 8081 and uses a Kubernetes configuration (in-cluster or via your local kubeconfig) to interact with the CoreDNS ConfigMap.
A sample DNS client is available in the test/ directory. To send an AddEntry request, run:
go run test/client.go --test-add-entry --config ./test/config.yaml --pod your-pod --ip 10.0.1.2 --network your-network --scope globalThis command will connect to the gRPC server, send the DNS entry details, and print the response.
The repository includes Kubernetes manifests and kustomize configurations for a production-like deployment.
- RBAC Setup
Apply RBAC resources:kubectl apply -k config/rbac/
- Deploy the Server
Deploy the DNS server and its related resources:kubectl apply -k config/server/
- Quickstart with Kind (Optional)
For a local cluster setup using Kind, run:kind create cluster --config examples/quickstart/kind-cluster.yaml kubectl apply -k config/server/
The server uses the CoreDNSManager (see pkg/coredns-manager/corednsmanager.go) to update the CoreDNS Corefile dynamically. This allows you to add or remove DNS entries on the fly by modifying the CoreDNS ConfigMap (e.g., l2smdns-coredns-config).
- build: Compiles the project.
- test: Runs unit and integration tests.
- run-server: Launches the gRPC DNS server.
- docker-build: Builds the Docker image.
- docker-run: Runs the Docker container locally.
l2sm-dns is a key component of the broader l2sm ecosystem. For further details, integration guidelines, and additional modules, please refer to the main l2sm repository.
Contributions are welcome! For guidelines on contributing, please check out the contribution instructions in the l2sm repository.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.