2016-03-20 17:44:58 +00:00
# etcd
2018-01-04 12:53:07 +00:00
## Name
*etcd* - enables reading zone data from an etcd instance.
## Description
The data in etcd has to be encoded as
2016-03-20 17:44:58 +00:00
a [message ](https://github.com/skynetservices/skydns/blob/2fcff74cdc9f9a7dd64189a447ef27ac354b725f/msg/service.go#L26 )
2017-04-21 11:21:56 +02:00
like [SkyDNS ](https://github.com/skynetservices/skydns ). It should also work just like SkyDNS.
2016-03-20 21:36:55 +00:00
2017-10-10 09:39:35 +02:00
The etcd plugin makes extensive use of the proxy plugin 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-10-10 20:13:22 +01:00
etcd [ZONES...]
2016-03-20 17:44:58 +00:00
~~~
2016-10-10 20:13:22 +01:00
* **ZONES** zones etcd should be authoritative for.
2016-03-20 17:44:58 +00:00
2017-10-10 09:39:35 +02:00
The path will default to `/skydns` the local etcd proxy (http://localhost:2379). If no zones are
specified the block's zone will be used as the zone.
2016-03-20 17:44:58 +00:00
2017-09-14 09:36:06 +01:00
If you want to `round robin` A and AAAA responses look at the `loadbalance` plugin.
2016-03-20 21:36:55 +00:00
2016-03-20 17:44:58 +00:00
~~~
2016-10-10 20:13:22 +01:00
etcd [ZONES...] {
2016-03-25 20:26:42 +00:00
stubzones
2018-01-07 16:32:59 +00:00
fallthrough [ZONES...]
2016-10-10 20:13:22 +01:00
path PATH
endpoint ENDPOINT...
upstream ADDRESS...
2017-07-29 04:03:55 -07:00
tls CERT KEY CACERT
2016-03-20 17:44:58 +00:00
}
~~~
2016-08-22 14:10:25 -07:00
* `stubzones` enables the stub zones feature. The stubzone is *only* done in the etcd tree located
2016-04-16 16:16:52 +01:00
under the *first* zone specified.
2017-09-14 09:36:06 +01:00
* `fallthrough` If zone matches but no record can be generated, pass request to the next plugin.
2018-01-07 16:32:59 +00:00
If ** [ZONES...]** is omitted, then fallthrough happens for all zones for which the plugin
is authoritative. If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa` ), then only
queries for those zones will be subject to fallthrough.
2016-10-10 20:13:22 +01:00
* **PATH** the path inside etcd. Defaults to "/skydns".
* **ENDPOINT** the etcd endpoints. Defaults to "http://localhost:2397".
2016-08-22 14:10:25 -07: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
2017-09-14 09:36:06 +01:00
the proxy plugin. **ADDRESS** can be an IP address, and IP:port or a string pointing to a file
2016-11-24 16:57:20 +01:00
that is structured as /etc/resolv.conf.
2017-01-12 03:14:24 -05:00
* `tls` followed by:
2018-01-04 12:53:07 +00:00
* no arguments, if the server certificate is signed by a system-installed CA and no client cert is needed
* a single argument that is the CA PEM file, if the server cert is not signed by a system CA and no client cert is needed
* two arguments - path to cert PEM file, the path to private key PEM file - if the server certificate is signed by a system-installed CA and a client certificate is needed
* three arguments - path to cert PEM file, path to client private key PEM file, path to CA PEM
file - if the server certificate is not signed by a system-installed CA and client certificate
is needed.
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:
2017-09-15 09:56:05 +01:00
~~~ corefile
. {
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
2016-11-24 16:57:20 +01:00
Or a setup where we use `/etc/resolv.conf` as the basis for the proxy and the upstream
when resolving external pointing CNAMEs.
2017-09-15 09:56:05 +01:00
~~~ corefile
. {
2016-11-24 16:57:20 +01:00
etcd skydns.local {
path /skydns
upstream /etc/resolv.conf
}
cache 160 skydns.local
proxy . /etc/resolv.conf
}
~~~
2017-12-05 12:02:37 -06:00
Multiple endpoints are supported as well.
~~~
etcd skydns.local {
endpoint http://localhost:2379 http://localhost:4001
...
~~~
2016-11-24 16:57:20 +01:00
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
2017-10-24 10:16:03 +01:00
need to add the zone `0.0.10.in-addr.arpa` to the list of zones. Showing a snippet of a Corefile:
2016-06-08 10:29:46 +01:00
~~~
2017-10-24 10:16:03 +01:00
etcd skydns.local 10.0.0.0/24 {
2017-09-15 09:56:05 +01:00
stubzones
...
2016-06-08 10:29:46 +01:00
~~~
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:
2017-10-10 09:39:35 +02:00
~~~ sh
2016-06-08 10:29:46 +01:00
% dig @localhost -x 10.0.0.127 +short
2017-10-10 09:39:35 +02:00
reverse.skydns.local.
2016-06-08 10:29:46 +01:00
~~~
2018-01-04 12:53:07 +00:00
2018-01-10 11:45:12 +00:00
## Bugs
2018-01-04 12:53:07 +00:00
Only the etcdv2 protocol is supported.