Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
ec151309
Commit
ec151309
authored
Jan 16, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement TO
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
def32382
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
16 deletions
+36
-16
plugin/traffic/HACKING.md
plugin/traffic/HACKING.md
+1
-1
plugin/traffic/README.md
plugin/traffic/README.md
+10
-8
plugin/traffic/setup.go
plugin/traffic/setup.go
+23
-5
plugin/traffic/setup_test.go
plugin/traffic/setup_test.go
+2
-2
No files found.
plugin/traffic/HACKING.md
View file @
ec151309
...
...
@@ -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
...
...
plugin/traffic/README.md
View file @
ec151309
...
...
@@ -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.
plugin/traffic/setup.go
View file @
ec151309
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
:=
parse
Traffic
(
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
parse
Traffic
(
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
}
...
...
plugin/traffic/setup_test.go
View file @
ec151309
...
...
@@ -15,7 +15,7 @@ func TestSetup(t *testing.T) {
*/
}
func
TestParse
(
t
*
testing
.
T
)
{
func
TestParse
Traffic
(
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
:=
parse
Traffic
(
c
)
if
test
.
shouldErr
&&
err
==
nil
{
t
.
Errorf
(
"Test %v: Expected error but found nil"
,
i
)
continue
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment