mirror of
https://github.com/coredns/coredns.git
synced 2025-11-27 06:04:03 -05:00
@@ -41,6 +41,8 @@ responding server (CoreDNS) has no idea how many clients use this resolver. So r
|
||||
+1 on the CoreDNS side can results in anything from 1 to 1000+ of queries on the endpoint, making
|
||||
the load reporting from *traffic* highly inaccurate.
|
||||
|
||||
*Traffic* implements version 3 of the xDS API.
|
||||
|
||||
## Syntax
|
||||
|
||||
~~~
|
||||
@@ -155,16 +157,6 @@ lb.example.org {
|
||||
This will load balance any names under `lb.example.org` using the data from the manager running on
|
||||
localhost on port 18000. The node ID will be `test-id` and no TLS will be used.
|
||||
|
||||
## 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 and locality information from ClusterLoadAssignments is not used. Multiple **TO** addresses
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2"
|
||||
corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
|
||||
corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
|
||||
)
|
||||
|
||||
// SocketAddress holds a corepb.SocketAddress.
|
||||
@@ -22,16 +22,16 @@ func (s *SocketAddress) Port() uint16 { return uint16(s.GetPortValue()) }
|
||||
|
||||
type assignment struct {
|
||||
mu sync.RWMutex
|
||||
cla map[string]*xdspb.ClusterLoadAssignment
|
||||
cla map[string]*endpointpb.ClusterLoadAssignment
|
||||
}
|
||||
|
||||
// NewAssignment returns a pointer to an assignment.
|
||||
func NewAssignment() *assignment {
|
||||
return &assignment{cla: make(map[string]*xdspb.ClusterLoadAssignment)}
|
||||
return &assignment{cla: make(map[string]*endpointpb.ClusterLoadAssignment)}
|
||||
}
|
||||
|
||||
// SetClusterLoadAssignment sets the assignment for the cluster to cla.
|
||||
func (a *assignment) SetClusterLoadAssignment(cluster string, cla *xdspb.ClusterLoadAssignment) {
|
||||
func (a *assignment) SetClusterLoadAssignment(cluster string, cla *endpointpb.ClusterLoadAssignment) {
|
||||
// If cla is nil we just found a cluster, check if we already know about it, or if we need to make a new entry.
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
@@ -48,7 +48,7 @@ func (a *assignment) SetClusterLoadAssignment(cluster string, cla *xdspb.Cluster
|
||||
}
|
||||
|
||||
// ClusterLoadAssignment returns the assignment for the cluster or nil if there is none.
|
||||
func (a *assignment) ClusterLoadAssignment(cluster string) *xdspb.ClusterLoadAssignment {
|
||||
func (a *assignment) ClusterLoadAssignment(cluster string) *endpointpb.ClusterLoadAssignment {
|
||||
a.mu.RLock()
|
||||
cla, ok := a.cla[cluster]
|
||||
a.mu.RUnlock()
|
||||
|
||||
@@ -30,9 +30,10 @@ import (
|
||||
"github.com/coredns/coredns/coremain"
|
||||
clog "github.com/coredns/coredns/plugin/pkg/log"
|
||||
|
||||
xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2"
|
||||
corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core"
|
||||
adsgrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v2"
|
||||
clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
|
||||
corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
|
||||
xdspb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"google.golang.org/grpc"
|
||||
@@ -45,7 +46,7 @@ const (
|
||||
edsURL = "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"
|
||||
)
|
||||
|
||||
type adsStream adsgrpc.AggregatedDiscoveryService_StreamAggregatedResourcesClient
|
||||
type adsStream xdspb.AggregatedDiscoveryService_StreamAggregatedResourcesClient
|
||||
|
||||
// Client talks to the grpc manager's endpoint to get load assignments.
|
||||
type Client struct {
|
||||
@@ -72,15 +73,13 @@ func New(addr, node string, opts ...grpc.DialOption) (*Client, error) {
|
||||
c := &Client{cc: cc, to: addr, node: &corepb.Node{Id: node,
|
||||
Metadata: &structpb.Struct{
|
||||
Fields: map[string]*structpb.Value{
|
||||
"HOSTNAME": {
|
||||
Kind: &structpb.Value_StringValue{StringValue: hostname},
|
||||
},
|
||||
"HOSTNAME": {Kind: &structpb.Value_StringValue{StringValue: hostname}},
|
||||
"BUILDVERSION": {Kind: &structpb.Value_StringValue{StringValue: coremain.CoreVersion}},
|
||||
},
|
||||
},
|
||||
BuildVersion: coremain.CoreVersion,
|
||||
},
|
||||
}
|
||||
c.assignments = &assignment{cla: make(map[string]*xdspb.ClusterLoadAssignment)}
|
||||
c.assignments = &assignment{cla: make(map[string]*endpointpb.ClusterLoadAssignment)}
|
||||
c.version, c.nonce = make(map[string]string), make(map[string]string)
|
||||
c.ctx, c.cancel = context.WithCancel(context.Background())
|
||||
|
||||
@@ -100,7 +99,7 @@ func (c *Client) Run() {
|
||||
default:
|
||||
}
|
||||
|
||||
cli := adsgrpc.NewAggregatedDiscoveryServiceClient(c.cc)
|
||||
cli := xdspb.NewAggregatedDiscoveryServiceClient(c.cc)
|
||||
stream, err := cli.StreamAggregatedResources(c.ctx)
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
@@ -183,7 +182,7 @@ func (c *Client) receive(stream adsStream) error {
|
||||
log.Debugf("Failed to unmarshal cluster discovery: %s", err)
|
||||
continue
|
||||
}
|
||||
cluster, ok := any.Message.(*xdspb.Cluster)
|
||||
cluster, ok := any.Message.(*clusterpb.Cluster)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -208,7 +207,7 @@ func (c *Client) receive(stream adsStream) error {
|
||||
log.Debugf("Failed to unmarshal endpoint discovery: %s", err)
|
||||
continue
|
||||
}
|
||||
cla, ok := any.Message.(*xdspb.ClusterLoadAssignment)
|
||||
cla, ok := any.Message.(*endpointpb.ClusterLoadAssignment)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user