mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
@@ -33,7 +33,7 @@ Then for CoreDNS, check out the `traffic` branch, create a Corefile:
|
||||
|
||||
~~~ Corefile
|
||||
example.org {
|
||||
traffic {
|
||||
traffic grpc://127.0.0.1:18000 {
|
||||
id test-id
|
||||
}
|
||||
debug
|
||||
|
||||
@@ -53,7 +53,7 @@ traffic {
|
||||
|
||||
~~~ corefile
|
||||
example.org {
|
||||
traffic
|
||||
traffic grpc://127.0.0.1:18000
|
||||
debug
|
||||
log
|
||||
}
|
||||
@@ -62,6 +62,14 @@ example.org {
|
||||
This will add load balancing for domains under example.org; the upstream information comes from
|
||||
10.12.13.14; depending on received assignments, replies will be let through as-is or are load balanced.
|
||||
|
||||
## Also See
|
||||
|
||||
The following documents provide some background on Envoy's control plane.
|
||||
|
||||
* https://github.com/envoyproxy/go-control-plane
|
||||
* https://blog.christianposta.com/envoy/guidance-for-building-a-control-plane-to-manage-envoy-proxy-based-infrastructure/
|
||||
* https://github.com/envoyproxy/envoy/blob/442f9fcf21a5f091cec3fe9913ff309e02288659/api/envoy/api/v2/discovery.proto#L63
|
||||
|
||||
## Bugs
|
||||
|
||||
Priority from ClusterLoadAssignments is not used. Locality is also not used. Health status of the
|
||||
@@ -73,10 +81,4 @@ clients that will use this reply, the responding server (CoreDNS) has no idea ho
|
||||
this resolver. So reporting a load of +1 on the CoreDNS side can be anything from 1 to 1000+, making
|
||||
the load reporting highly inaccurate.
|
||||
|
||||
## Also See
|
||||
|
||||
The following documents provide some background on Envoy's control plane.
|
||||
|
||||
* https://github.com/envoyproxy/go-control-plane
|
||||
* https://blog.christianposta.com/envoy/guidance-for-building-a-control-plane-to-manage-envoy-proxy-based-infrastructure/
|
||||
* https://github.com/envoyproxy/envoy/blob/442f9fcf21a5f091cec3fe9913ff309e02288659/api/envoy/api/v2/discovery.proto#L63
|
||||
Multiple **TO** addresses is not implemented.
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package traffic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
"github.com/coredns/coredns/plugin/pkg/parse"
|
||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||
"github.com/coredns/coredns/plugin/traffic/xds"
|
||||
|
||||
"github.com/caddyserver/caddy"
|
||||
@@ -18,7 +22,7 @@ func init() { plugin.Register("traffic", setup) }
|
||||
|
||||
func setup(c *caddy.Controller) error {
|
||||
rand.Seed(int64(time.Now().Nanosecond()))
|
||||
t, err := parse(c)
|
||||
t, err := parseTraffic(c)
|
||||
if err != nil {
|
||||
return plugin.Error("traffic", err)
|
||||
}
|
||||
@@ -48,14 +52,27 @@ func setup(c *caddy.Controller) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func parse(c *caddy.Controller) (*Traffic, error) {
|
||||
func parseTraffic(c *caddy.Controller) (*Traffic, error) {
|
||||
node := "coredns"
|
||||
toHosts := []string{}
|
||||
var err error
|
||||
|
||||
for c.Next() {
|
||||
args := c.RemainingArgs()
|
||||
if len(args) != 0 {
|
||||
if len(args) < 1 {
|
||||
return nil, c.ArgErr()
|
||||
|
||||
}
|
||||
toHosts, err = parse.HostPortOrFile(args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range toHosts {
|
||||
if !strings.HasPrefix(toHosts[i], transport.GRPC+"://") {
|
||||
return nil, fmt.Errorf("not a %s scheme: %s", transport.GRPC, toHosts[i])
|
||||
}
|
||||
// now cut the prefix off again, because the dialer needs to see normal address strings. All this
|
||||
// grpc:// stuff is to enfore uniformaty accross plugins and future proofing for other protocols.
|
||||
toHosts[i] = toHosts[i][len(transport.GRPC+"://"):]
|
||||
}
|
||||
for c.NextBlock() {
|
||||
switch c.Val() {
|
||||
@@ -71,7 +88,8 @@ func parse(c *caddy.Controller) (*Traffic, error) {
|
||||
}
|
||||
}
|
||||
|
||||
x, err := xds.New(":18000", node)
|
||||
// TODO: only the first host is used.
|
||||
x, err := xds.New(toHosts[0], node)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestSetup(t *testing.T) {
|
||||
*/
|
||||
}
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
func TestParseTraffic(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
shouldErr bool
|
||||
@@ -30,7 +30,7 @@ func TestParse(t *testing.T) {
|
||||
}
|
||||
for i, test := range tests {
|
||||
c := caddy.NewTestController("dns", test.input)
|
||||
_, err := parse(c)
|
||||
_, err := parseTraffic(c)
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %v: Expected error but found nil", i)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user