2016-03-20 17:44:58 +00:00
|
|
|
# etcd
|
|
|
|
|
|
|
|
|
|
`etcd` enabled reading zone data from an etcd instance. The data in etcd has to be encoded as
|
|
|
|
|
a [message](https://github.com/skynetservices/skydns/blob/2fcff74cdc9f9a7dd64189a447ef27ac354b725f/msg/service.go#L26)
|
2016-04-16 16:16:52 +01:00
|
|
|
like [SkyDNS](https//github.com/skynetservices/skydns). It should also work just like SkyDNS.
|
2016-03-20 21:36:55 +00:00
|
|
|
|
2016-04-16 16:16:52 +01:00
|
|
|
The etcd middleware makes extensive use of the proxy middleware to forward and query other servers
|
|
|
|
|
in the network.
|
2016-03-24 08:22:24 +00:00
|
|
|
|
2016-03-20 17:44:58 +00:00
|
|
|
## Syntax
|
|
|
|
|
|
|
|
|
|
~~~
|
2016-03-22 11:32:12 +00:00
|
|
|
etcd [zones...]
|
2016-03-20 17:44:58 +00:00
|
|
|
~~~
|
|
|
|
|
|
2016-03-25 20:26:42 +00:00
|
|
|
* `zones` zones etcd should be authoritative for.
|
2016-03-20 17:44:58 +00:00
|
|
|
|
2016-04-19 12:52:05 +00:00
|
|
|
The path will default to `/skydns` the local etcd proxy (http://localhost:2379).
|
2016-03-22 11:32:12 +00:00
|
|
|
If no zones are specified the block's zone will be used as the zone.
|
2016-03-20 17:44:58 +00:00
|
|
|
|
2016-03-24 17:55:46 +00:00
|
|
|
If you want to `round robin` A and AAAA responses look at the `loadbalance` middleware.
|
2016-03-20 21:36:55 +00:00
|
|
|
|
2016-03-20 17:44:58 +00:00
|
|
|
~~~
|
2016-03-25 20:26:42 +00:00
|
|
|
etcd [zones...] {
|
|
|
|
|
stubzones
|
2016-03-20 17:44:58 +00:00
|
|
|
path /skydns
|
2016-03-22 11:04:56 +00:00
|
|
|
endpoint endpoint...
|
2016-03-25 20:26:42 +00:00
|
|
|
upstream address...
|
|
|
|
|
tls cert key cacert
|
Allow debug queries to etcd middleware (#150)
With this you can retreive the raw data that the etcd middleware
used to create the reply. The debug data is put in TXT records
that are stuffed in the CH classs. This is only enabled if you
specify `debug` in the etcd stanza.
You can retrieve it by prefixing your query with 'o-o.debug.'
For instance:
; <<>> DiG 9.10.3-P4-Ubuntu <<>> @localhost -p 1053 SRV o-o.debug.production.*.skydns.local
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47798
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;o-o.debug.production.*.skydns.local. IN SRV
;; ANSWER SECTION:
production.*.skydns.local. 154 IN SRV 10 50 8080 service1.example.com.
production.*.skydns.local. 154 IN SRV 10 50 8080 service2.example.com.
;; ADDITIONAL SECTION:
skydns.local.skydns.east.production.rails.1. 154 CH TXT "service1.example.com:8080(10,0,,false)[0,]"
skydns.local.skydns.west.production.rails.2. 154 CH TXT "service2.example.com:8080(10,0,,false)[0,]"
2016-05-22 21:16:26 +01:00
|
|
|
debug
|
2016-03-20 17:44:58 +00:00
|
|
|
}
|
|
|
|
|
~~~
|
|
|
|
|
|
2016-04-16 16:16:52 +01:00
|
|
|
* `stubzones` enable the stub zones feature. The stubzone is *only* done in the etcd tree located
|
|
|
|
|
under the *first* zone specified.
|
2016-03-25 20:26:42 +00:00
|
|
|
* `path` the path inside etcd, defaults to "/skydns".
|
|
|
|
|
* `endpoint` the etcd endpoints, default to "http://localhost:2397".
|
2016-04-16 16:16:52 +01:00
|
|
|
* `upstream` upstream resolvers to be used resolve external names found in etcd, think CNAMEs
|
|
|
|
|
pointing to external names. If you want CoreDNS to act as a proxy for clients you'll need to add
|
|
|
|
|
the proxy middleware.
|
2016-03-26 16:32:36 +00:00
|
|
|
* `tls` followed the cert, key and the CA's cert filenames.
|
2016-06-07 20:57:45 +01:00
|
|
|
* `debug` allow debug queries. Prefix the name with `o-o.debug.` to retrieve extra information in the
|
2016-08-08 19:54:17 -07:00
|
|
|
additional section of the reply in the form of text records.
|
2016-06-07 20:57:45 +01:00
|
|
|
|
2016-03-20 17:44:58 +00:00
|
|
|
## Examples
|
2016-04-16 16:16:52 +01:00
|
|
|
|
|
|
|
|
This is the default SkyDNS setup, with everying specified in full:
|
|
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
.:53 {
|
2016-04-19 12:52:05 +00:00
|
|
|
etcd skydns.local {
|
2016-04-16 16:16:52 +01:00
|
|
|
stubzones
|
|
|
|
|
path /skydns
|
2016-04-19 12:52:05 +00:00
|
|
|
endpoint http://localhost:2379
|
2016-04-16 16:16:52 +01:00
|
|
|
upstream 8.8.8.8:53 8.8.4.4:53
|
|
|
|
|
}
|
2016-04-19 12:52:05 +00:00
|
|
|
prometheus
|
|
|
|
|
cache 160 skydns.local
|
2016-04-16 16:16:52 +01:00
|
|
|
loadbalance
|
|
|
|
|
proxy . 8.8.8.8:53 8.8.4.4:53
|
|
|
|
|
}
|
|
|
|
|
~~~
|
2016-06-08 10:29:46 +01:00
|
|
|
|
|
|
|
|
### Reverse zones
|
|
|
|
|
|
|
|
|
|
Reverse zones are supported. You need to make CoreDNS aware of the fact that you are also
|
|
|
|
|
authoritative for the reverse. For instance if you want to add the reverse for 10.0.0.0/24, you'll
|
|
|
|
|
need to add the zone `10.in-addr.arpa` to the list of zones (the fun starts with reverse IPv6 zones
|
|
|
|
|
in the ip6.arpa domain). Showing a snippet of a Corefile:
|
|
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
etcd skydns.local 10.in-addr.arpa {
|
|
|
|
|
stubzones
|
|
|
|
|
...
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
Next you'll need to populate the zone with reverse records, here we add a reverse for
|
|
|
|
|
10.0.0.127 pointing to reverse.skydns.local.
|
|
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
% curl -XPUT http://127.0.0.1:4001/v2/keys/skydns/arpa/in-addr/10/0/0/127 \
|
|
|
|
|
-d value='{"host":"reverse.skydns.local."}'
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
Querying with dig:
|
|
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
% dig @localhost -x 10.0.0.127 +short
|
|
|
|
|
reverse.atoom.net.
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
|
|
Or with *debug* queries enabled:
|
|
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
% dig @localhost -p 1053 o-o.debug.127.0.0.10.in-addr.arpa. PTR
|
|
|
|
|
|
|
|
|
|
;; OPT PSEUDOSECTION:
|
|
|
|
|
; EDNS: version: 0, flags:; udp: 4096
|
|
|
|
|
;; QUESTION SECTION:
|
|
|
|
|
;o-o.debug.127.0.0.10.in-addr.arpa. IN PTR
|
|
|
|
|
|
|
|
|
|
;; ANSWER SECTION:
|
|
|
|
|
127.0.0.10.in-addr.arpa. 300 IN PTR reverse.atoom.net.
|
|
|
|
|
|
|
|
|
|
;; ADDITIONAL SECTION:
|
|
|
|
|
127.0.0.10.in-addr.arpa. 300 CH TXT "reverse.atoom.net.:0(10,0,,false)[0,]"
|
|
|
|
|
~~~
|
2016-08-08 19:54:17 -07:00
|
|
|
|
|
|
|
|
## Debug queries
|
|
|
|
|
|
|
|
|
|
When debug queries are enabled CoreDNS will return errors and etcd records encountered during the resolution
|
|
|
|
|
process in the response. The general form looks like this:
|
|
|
|
|
|
|
|
|
|
skydns.test.skydns.dom.a. 300 CH TXT "127.0.0.1:0(10,0,,false)[0,]"
|
|
|
|
|
|
|
|
|
|
This shows the complete key as the owername, the rdata of the TXT record has:
|
|
|
|
|
`host:port(priority,weight,txt content,mail)[targetstrip,group]`.
|
|
|
|
|
|
|
|
|
|
Any errors seen doing parsing will show up like this:
|
|
|
|
|
|
|
|
|
|
. 0 CH TXT "/skydns/local/skydns/r/a: invalid character '.' after object key:value pair"
|
|
|
|
|
|
|
|
|
|
which shows `a.r.skydns.local.` has a json encoding problem.
|
|
|
|
|
|
|
|
|
|
Errors when communicating with an upstream will be returned as:
|
|
|
|
|
|
|
|
|
|
. 0 CH TXT "example.org. IN A: unreachable backend"
|
|
|
|
|
|
|
|
|
|
Signalling that an A record for example.org. was sought, but it failed
|
|
|
|
|
with that error.
|