mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: support client srv target
This commit is contained in:
parent
133f46246e
commit
bfa21001a1
@ -285,6 +285,13 @@ The following DNS SRV records are looked up in the listed order:
|
|||||||
|
|
||||||
If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over SSL.
|
If `_etcd-server-ssl._tcp.example.com` is found then etcd will attempt the bootstrapping process over SSL.
|
||||||
|
|
||||||
|
To help clients discover the etcd cluster, the following DNS SRV records are looked up in the listed order:
|
||||||
|
|
||||||
|
* _etcd-client._tcp.example.com
|
||||||
|
* _etcd-client-ssl._tcp.example.com
|
||||||
|
|
||||||
|
If `_etcd-client-ssl._tcp.example.com` is found, clients will attempt to communicate with the etcd cluster over SSL.
|
||||||
|
|
||||||
#### Create DNS SRV records
|
#### Create DNS SRV records
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -294,6 +301,13 @@ _etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra1.example.com.
|
|||||||
_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com.
|
_etcd-server._tcp.example.com. 300 IN SRV 0 0 2380 infra2.example.com.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
$ dig +noall +answer SRV _etcd-client._tcp.example.com
|
||||||
|
_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra0.example.com.
|
||||||
|
_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra1.example.com.
|
||||||
|
_etcd-client._tcp.example.com. 300 IN SRV 0 0 2379 infra2.example.com.
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
|
$ dig +noall +answer infra0.example.com infra1.example.com infra2.example.com
|
||||||
infra0.example.com. 300 IN A 10.0.1.10
|
infra0.example.com. 300 IN A 10.0.1.10
|
||||||
@ -382,6 +396,18 @@ DNS SRV records can also be used to configure the list of peers for an etcd serv
|
|||||||
$ etcd --proxy on -discovery-srv example.com
|
$ etcd --proxy on -discovery-srv example.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### etcd client configuration
|
||||||
|
|
||||||
|
DNS SRV records can also be used to help clients discover the etcd cluster.
|
||||||
|
|
||||||
|
The official [etcd/client](../client) supports [DNS Discovery](https://godoc.org/github.com/coreos/etcd/client#Discoverer).
|
||||||
|
|
||||||
|
`etcdctl` also supports DNS Discovery by specifying the `--discovery-srv` option.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ etcdctl --discovery-srv example.com set foo bar
|
||||||
|
```
|
||||||
|
|
||||||
#### Error Cases
|
#### Error Cases
|
||||||
|
|
||||||
You might see an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets.
|
You might see an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets.
|
||||||
|
@ -50,8 +50,8 @@ func (d *srvDiscover) Discover(domain string) ([]string, error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
errHTTPS := updateURLs("etcd-server-ssl", "https")
|
errHTTPS := updateURLs("etcd-client-ssl", "https")
|
||||||
errHTTP := updateURLs("etcd-server", "http")
|
errHTTP := updateURLs("etcd-client", "http")
|
||||||
|
|
||||||
if errHTTPS != nil && errHTTP != nil {
|
if errHTTPS != nil && errHTTP != nil {
|
||||||
return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP)
|
return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP)
|
||||||
|
@ -78,10 +78,10 @@ func TestSRVDiscover(t *testing.T) {
|
|||||||
|
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
lookupSRV = func(service string, proto string, domain string) (string, []*net.SRV, error) {
|
lookupSRV = func(service string, proto string, domain string) (string, []*net.SRV, error) {
|
||||||
if service == "etcd-server-ssl" {
|
if service == "etcd-client-ssl" {
|
||||||
return "", tt.withSSL, nil
|
return "", tt.withSSL, nil
|
||||||
}
|
}
|
||||||
if service == "etcd-server" {
|
if service == "etcd-client" {
|
||||||
return "", tt.withoutSSL, nil
|
return "", tt.withoutSSL, nil
|
||||||
}
|
}
|
||||||
return "", nil, errors.New("Unknown service in mock")
|
return "", nil, errors.New("Unknown service in mock")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user