mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
plugin/kubernetes: Add upstream @self and loop count (#1484)
* add upstream @self and loop count * 1st round of feedback * allow argless upstream * update test * readmes * feedback
This commit is contained in:
committed by
Miek Gieben
parent
ee8084a08f
commit
71ee323651
@@ -32,7 +32,7 @@ etcd [ZONES...] {
|
||||
fallthrough [ZONES...]
|
||||
path PATH
|
||||
endpoint ENDPOINT...
|
||||
upstream ADDRESS...
|
||||
upstream [ADDRESS...]
|
||||
tls CERT KEY CACERT
|
||||
}
|
||||
~~~
|
||||
@@ -47,8 +47,9 @@ etcd [ZONES...] {
|
||||
* **ENDPOINT** the etcd endpoints. Defaults to "http://localhost:2379".
|
||||
* `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 plugin. **ADDRESS** can be an IP address, and IP:port or a string pointing to a file
|
||||
that is structured as /etc/resolv.conf.
|
||||
the proxy plugin. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself.
|
||||
**ADDRESS** can be an IP address, and IP:port or a string pointing to a file that is structured
|
||||
as /etc/resolv.conf.
|
||||
* `tls` followed by:
|
||||
|
||||
* no arguments, if the server certificate is signed by a system-installed CA and no client cert is needed
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/coredns/coredns/plugin/proxy"
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
"github.com/coredns/coredns/plugin/pkg/upstream"
|
||||
etcdc "github.com/coreos/etcd/client"
|
||||
"github.com/miekg/dns"
|
||||
"golang.org/x/net/context"
|
||||
@@ -24,7 +25,7 @@ type Etcd struct {
|
||||
Fall fall.F
|
||||
Zones []string
|
||||
PathPrefix string
|
||||
Proxy proxy.Proxy // Proxy for looking up names during the resolution process
|
||||
Upstream upstream.Upstream // Proxy for looking up names during the resolution process
|
||||
Client etcdc.KeysAPI
|
||||
Ctx context.Context
|
||||
Stubmap *map[string]proxy.Proxy // list of proxies for stub resolving.
|
||||
@@ -50,7 +51,7 @@ func (e *Etcd) Reverse(state request.Request, exact bool, opt plugin.Options) (s
|
||||
|
||||
// Lookup implements the ServiceBackend interface.
|
||||
func (e *Etcd) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) {
|
||||
return e.Proxy.Lookup(state, name, typ)
|
||||
return e.Upstream.Lookup(state, name, typ)
|
||||
}
|
||||
|
||||
// IsNameError implements the ServiceBackend interface.
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// ServeDNS implements the plugin.Handler interface.
|
||||
func (e *Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||
opt := plugin.Options{}
|
||||
state := request.Request{W: w, Req: r}
|
||||
state := request.Request{W: w, Req: r, Context: ctx}
|
||||
|
||||
name := state.Name()
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/coredns/coredns/plugin/etcd/msg"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnstest"
|
||||
"github.com/coredns/coredns/plugin/pkg/tls"
|
||||
"github.com/coredns/coredns/plugin/pkg/upstream"
|
||||
"github.com/coredns/coredns/plugin/proxy"
|
||||
"github.com/coredns/coredns/plugin/test"
|
||||
|
||||
@@ -227,8 +228,9 @@ func newEtcdPlugin() *Etcd {
|
||||
tlsc, _ := tls.NewTLSConfigFromArgs()
|
||||
client, _ := newEtcdClient(endpoints, tlsc)
|
||||
|
||||
p := proxy.NewLookup([]string{"8.8.8.8:53"})
|
||||
return &Etcd{
|
||||
Proxy: proxy.NewLookup([]string{"8.8.8.8:53"}),
|
||||
Upstream: upstream.Upstream{Forward: &p},
|
||||
PathPrefix: "skydns",
|
||||
Ctx: context.Background(),
|
||||
Zones: []string{"skydns.test.", "skydns_extra.test.", "in-addr.arpa."},
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/pkg/dnsutil"
|
||||
mwtls "github.com/coredns/coredns/plugin/pkg/tls"
|
||||
"github.com/coredns/coredns/plugin/pkg/upstream"
|
||||
"github.com/coredns/coredns/plugin/proxy"
|
||||
|
||||
etcdc "github.com/coreos/etcd/client"
|
||||
@@ -90,13 +90,13 @@ func etcdParse(c *caddy.Controller) (*Etcd, bool, error) {
|
||||
case "upstream":
|
||||
args := c.RemainingArgs()
|
||||
if len(args) == 0 {
|
||||
return &Etcd{}, false, c.ArgErr()
|
||||
return nil, false, c.ArgErr()
|
||||
}
|
||||
ups, err := dnsutil.ParseHostPortOrFile(args...)
|
||||
u, err := upstream.NewUpstream(args)
|
||||
if err != nil {
|
||||
return &Etcd{}, false, err
|
||||
return nil, false, err
|
||||
}
|
||||
etc.Proxy = proxy.NewLookup(ups)
|
||||
etc.Upstream = u
|
||||
case "tls": // cert key cacertfile
|
||||
args := c.RemainingArgs()
|
||||
tlsConfig, err = mwtls.NewTLSConfigFromArgs(args...)
|
||||
|
||||
Reference in New Issue
Block a user