Michael Richmond d04abdf422 BK8s datasource middleware -- PoC for A records (#153)
* Laying down kubernetes middleware foundation

* Duplicated a bunch of code form etcd middleware
* Duplicated code hacked to compile and load as a separate middleware

* Adding verbose build option to Makefile

* Removing stubzone and tls support

tls and stubzone support was carried over from base etcd middleware code.
Removing to simplify the kube middleware implementation. (For now.)

* Adding conf directory for sample conf files

* Removing stubzone support from query handler

* Remove upstream and proxy from k8s corefile.

Not sure that upstream or proxy makes sense for a k8s backed zone.

* Comment out use of singleflight serialization

* Removing parsing support for "upstream" directive from k8s

* Removing upstream directive parsing code

* Removing CNAME and TXT lookup implementation

* Create README.md

Brain-dump of DNS record name assembly and open work items.

* Adding notes about wildcard handling

* Adding basic k8s API client

* Fleshing out methods on k8s connector

* Remove PathPrefix from middleware init

* Removing incorrect plural

* Adding brute-force k8s service lookup functions

* Initializing k8s API connector during startup

* Hacking around to call k8s connector

* Parsing incoming domain name into serviceName and namespace

* Improving and simplifying k8s zone matching and label segmentation

* Removing unused functions carried over from etcd middleware

* Adding basic return of k8s data to DNS client

* updated debugging println statements to flag with "[debug]"
* removed code in kubernetes.go::Records that was a hold-over from etcd middleware.
* Removed some random exploratory hacking.

* Minior README.md updates

* Updating with demo instructions

* Updating README.md with CoreFile and removing completed TODO items

* Updating conf file and README to reflect DNS response cache works

* Disabling DNS response caching

* Adding debug statement on entry to Records()

* Changing port number in exampes to port 53.

* Misc style and clarity changes

* Removing empty function definitions

* Adding comment to track future cleanup

* Refactoring README to follow style of other middleware

* Exposing dataobject field (typo)
2016-06-06 20:49:53 +01:00
2016-04-27 10:48:22 +00:00
2016-04-21 14:26:02 +01:00
2016-04-13 20:14:13 +01:00
2016-03-18 20:57:35 +00:00
2016-04-28 19:07:44 +01:00
2016-05-03 09:00:25 +00:00

CoreDNS

CoreDNS is DNS server that started as a fork of Caddy. It has the same model: it chains middleware.

CoreDNS aims to be a fast and flexible DNS server. The keyword here is flexible, with CoreDNS you are able to do what you want with your DNS data. And if not: write a middleware!

Currently CoreDNS is able to:

  • Serve zone data from a file, both DNSSEC (NSEC only) and DNS is supported (middleware/file).
  • Retrieve zone data from primaries, i.e. act as a secondary server (AXFR only) (middleware/secondary).
  • Sign zone data on-the-fly (middleware/dnssec).
  • Loadbalancing of responses (middleware/loadbalance).
  • Allow for zone transfers, i.e. act as a primary server (middleware/file).
  • Caching (middleware/cache).
  • Health checking (middleware/health).
  • Use etcd as a backend, i.e. a 98.5% replacement for SkyDNS (middleware/etcd).
  • Serve as a proxy to forward queries to some other (recursive) nameserver (middleware/proxy).
  • Rewrite queries (both qtype, qclass and qname) (middleware/rewrite).
  • Provide metrics (by using Prometheus) (middleware/metrics).
  • Provide Logging (middleware/log).
  • Has support for the CH class: version.bind and friends (middleware/chaos).
  • Profiling support (middleware/pprof).

Status

I'm using CoreDNS is my primary, authoritative, nameserver for my domains (miek.nl, atoom.net and a few others). CoreDNS should be stable enough to provide you with a good DNS(SEC) service.

There are still few issues, and work is ongoing on making things fast and reduce the memory usage.

All in all, CoreDNS should be able to provide you with enough functionality to replace parts of BIND9, Knot, NSD or PowerDNS. Most documentation is in the source and some blog articles can be found here. If you do want to use CoreDNS in production, please let us know and how we can help.

https://caddyserver.com/ is also full of examples on how to structure a Corefile (renamed from Caddyfile when I forked it).

Examples

Start a simple proxy:

Corefile contains:

.:1053 {
    proxy . 8.8.8.8:53
}

Just start CoreDNS: ./coredns. And then just query on that port (1053), the query should be forwarded to 8.8.8.8 and the response will be returned.

Serve the (NSEC) DNSSEC signed miek.nl on port 1053, errors and logging to stdout. Allow zone transfers to everybody.

miek.nl:1053 {
    file /var/lib/bind/miek.nl.signed {
        transfer to *
    }
    errors stdout
    log stdout
}

Serve miek.nl on port 1053, but forward everything that does not match miek.nl to a recursive nameserver and rewrite ANY queries to HINFO.

.:1053 {
    rewrite ANY HINFO
    proxy . 8.8.8.8:53

    file /var/lib/bind/miek.nl.signed miek.nl {
        transfer to *
    }
    errors stdout
    log stdout
}

All the above examples are possible with the current CoreDNS.

What remains to be done

  • Website?
  • Logo?
  • Optimizations.
  • Load testing.
  • The issues.

Blog

https://miek.nl/tags/coredns/

Systemd service file

Use this as a systemd service file. It defaults to a coredns wich a homedir of /home/coredns and the binary lives in /opt/bin:

Unit]
Description=CoreDNS DNS server
Documentation=https://miek.nl/tags/coredns
After=network.target

[Service]
PermissionsStartOnly=true
PIDFile=/home/coredns/coredns.pid
LimitNOFILE=8192
User=coredns
WorkingDirectory=/home/coredns
ExecStartPre=/sbin/setcap cap_net_bind_service=+ep /opt/bin/coredns
ExecStart=/opt/bin/coredns -pidfile /home/coredns/coredns.pid -conf=/etc/coredns
/Corefile
Restart=on-failure

[Install]
WantedBy=multi-user.target
Description
CoreDNS is a DNS server that chains plugins
Readme Apache-2.0 150 MiB
Languages
Go 99.9%