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
246782b7
Commit
246782b7
authored
Jan 16, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
45f11f32
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
21 deletions
+25
-21
plugin/traffic/README.md
plugin/traffic/README.md
+8
-7
plugin/traffic/traffic.go
plugin/traffic/traffic.go
+9
-7
plugin/traffic/xds/assignment.go
plugin/traffic/xds/assignment.go
+5
-5
plugin/traffic/xds/client.go
plugin/traffic/xds/client.go
+3
-2
No files found.
plugin/traffic/README.md
View file @
246782b7
...
@@ -23,7 +23,7 @@ endpoints need to be drained from it.
...
@@ -23,7 +23,7 @@ endpoints need to be drained from it.
every 10 seconds. The plugin hands out responses that adhere to these assignments. Each DNS response
every 10 seconds. The plugin hands out responses that adhere to these assignments. Each DNS response
contains a single IP address that's considered the best one.
*Traffic*
will load balance A and AAAA
contains a single IP address that's considered the best one.
*Traffic*
will load balance A and AAAA
queries. The TTL on these answer is set to 5s. It will only return successful responses either with
queries. The TTL on these answer is set to 5s. It will only return successful responses either with
an answer or otherwise a NODATA response.
NXDOMAIN responses will
*never*
be sent
.
an answer or otherwise a NODATA response.
Queries for non-existent clusters get a NXDOMAIN
.
The
*traffic*
plugin has no notion of draining, drop overload and anything that advanced,
*
it just
The
*traffic*
plugin has no notion of draining, drop overload and anything that advanced,
*
it just
acts upon assignments
*. This is means that if a endpoint goes down and *
traffic
*
has not seen a new
acts upon assignments
*. This is means that if a endpoint goes down and *
traffic
*
has not seen a new
...
@@ -35,8 +35,9 @@ assignment yet, it will still include this endpoint address in responses.
...
@@ -35,8 +35,9 @@ assignment yet, it will still include this endpoint address in responses.
traffic TO...
traffic TO...
~~~
~~~
*
**TO...**
are the Envoy control plane endpoint to connect to. The syntax mimics the
*forward*
This enabled the
*traffic*
plugin, with a default node id of
`coredns`
and no TLS.
plugin and must start with
`grpc://`
.
*
**TO...**
are the Envoy control plane endpoint to connect to. This must start with
`grpc://`
.
The extended syntax is available is you want more control.
The extended syntax is available is you want more control.
...
@@ -46,7 +47,7 @@ traffic TO... {
...
@@ -46,7 +47,7 @@ traffic TO... {
node ID
node ID
tls CERT KEY CA
tls CERT KEY CA
tls_servername NAME
tls_servername NAME
}
}
~~~
~~~
*
node
**ID**
is how
*traffic*
identifies itself to the control plane. This defaults to
`coredns`
.
*
node
**ID**
is how
*traffic*
identifies itself to the control plane. This defaults to
`coredns`
.
...
@@ -57,7 +58,7 @@ traffic TO... {
...
@@ -57,7 +58,7 @@ traffic TO... {
*
`tls`
**CA**
- no client authentication is used, and the file CA is used to verify the server certificate
*
`tls`
**CA**
- no client authentication is used, and the file CA is used to verify the server certificate
*
`tls`
**CERT**
**KEY**
- client authentication is used with the specified cert/key pair.
*
`tls`
**CERT**
**KEY**
- client authentication is used with the specified cert/key pair.
The server certificate is verified with the system CAs.
The server certificate is verified with the system CAs.
*
`tls`
**CERT**
**KEY**
**CA**
- client authentication is used with the specified cert/key pair.
*
`tls`
**CERT**
**KEY**
**CA**
- client authentication is used with the specified cert/key pair.
The server certificate is verified using the specified CA file.
The server certificate is verified using the specified CA file.
*
`tls_servername`
**NAME**
allows you to set a server name in the TLS configuration. This is needed
*
`tls_servername`
**NAME**
allows you to set a server name in the TLS configuration. This is needed
...
@@ -120,9 +121,9 @@ Multiple **TO** addresses is not implemented.
...
@@ -120,9 +121,9 @@ Multiple **TO** addresses is not implemented.
## TODO
## TODO
*
reconnecting the stream
*
acking responses
*
acking responses
*
correctly tracking versions and pruning old clusters.
*
correctly tracking versions and pruning old clusters.
*
metrics?
*
metrics?
*
how to exactly deal with health status from the endpoints.
*
testing
*
testing
*
credentials (other than TLS)
*
credentials (other than TLS)
- how/what?
plugin/traffic/traffic.go
View file @
246782b7
...
@@ -39,18 +39,20 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
...
@@ -39,18 +39,20 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
return
plugin
.
NextOrFailure
(
t
.
Name
(),
t
.
Next
,
ctx
,
w
,
r
)
return
plugin
.
NextOrFailure
(
t
.
Name
(),
t
.
Next
,
ctx
,
w
,
r
)
}
}
addr
:=
t
.
c
.
Select
(
cluster
)
if
addr
!=
nil
{
log
.
Debugf
(
"Found endpoint %q for %q"
,
addr
,
cluster
)
}
else
{
log
.
Debugf
(
"No healthy endpoints found for %q"
,
cluster
)
}
m
:=
new
(
dns
.
Msg
)
m
:=
new
(
dns
.
Msg
)
m
.
SetReply
(
r
)
m
.
SetReply
(
r
)
m
.
Authoritative
=
true
m
.
Authoritative
=
true
addr
,
ok
:=
t
.
c
.
Select
(
cluster
)
if
!
ok
{
m
.
Ns
=
soa
(
state
.
Zone
)
m
.
Rcode
=
dns
.
RcodeNameError
w
.
WriteMsg
(
m
)
return
0
,
nil
}
if
addr
==
nil
{
if
addr
==
nil
{
log
.
Debugf
(
"No (healthy) endpoints found for %q"
,
cluster
)
m
.
Ns
=
soa
(
state
.
Zone
)
m
.
Ns
=
soa
(
state
.
Zone
)
w
.
WriteMsg
(
m
)
w
.
WriteMsg
(
m
)
return
0
,
nil
return
0
,
nil
...
...
plugin/traffic/xds/assignment.go
View file @
246782b7
...
@@ -54,10 +54,10 @@ func (a *assignment) clusters() []string {
...
@@ -54,10 +54,10 @@ func (a *assignment) clusters() []string {
// Select selects a backend from cla, using weighted random selection. It only selects
// Select selects a backend from cla, using weighted random selection. It only selects
// backends that are reporting healthy.
// backends that are reporting healthy.
func
(
a
*
assignment
)
Select
(
cluster
string
)
net
.
IP
{
func
(
a
*
assignment
)
Select
(
cluster
string
)
(
net
.
IP
,
bool
)
{
cla
:=
a
.
clusterLoadAssignment
(
cluster
)
cla
:=
a
.
clusterLoadAssignment
(
cluster
)
if
cla
==
nil
{
if
cla
==
nil
{
return
nil
return
nil
,
false
}
}
total
:=
0
total
:=
0
...
@@ -81,7 +81,7 @@ func (a *assignment) Select(cluster string) net.IP {
...
@@ -81,7 +81,7 @@ func (a *assignment) Select(cluster string) net.IP {
// continue
// continue
// }
// }
if
r
==
i
{
if
r
==
i
{
return
net
.
ParseIP
(
lb
.
GetEndpoint
()
.
GetAddress
()
.
GetSocketAddress
()
.
GetAddress
())
return
net
.
ParseIP
(
lb
.
GetEndpoint
()
.
GetAddress
()
.
GetSocketAddress
()
.
GetAddress
())
,
true
}
}
i
++
i
++
}
}
...
@@ -98,9 +98,9 @@ func (a *assignment) Select(cluster string) net.IP {
...
@@ -98,9 +98,9 @@ func (a *assignment) Select(cluster string) net.IP {
// }
// }
r
-=
int
(
lb
.
GetLoadBalancingWeight
()
.
GetValue
())
r
-=
int
(
lb
.
GetLoadBalancingWeight
()
.
GetValue
())
if
r
<=
0
{
if
r
<=
0
{
return
net
.
ParseIP
(
lb
.
GetEndpoint
()
.
GetAddress
()
.
GetSocketAddress
()
.
GetAddress
())
return
net
.
ParseIP
(
lb
.
GetEndpoint
()
.
GetAddress
()
.
GetSocketAddress
()
.
GetAddress
())
,
true
}
}
}
}
}
}
return
nil
return
nil
,
false
}
}
plugin/traffic/xds/client.go
View file @
246782b7
...
@@ -216,5 +216,6 @@ func (c *Client) Receive(stream adsStream) error {
...
@@ -216,5 +216,6 @@ func (c *Client) Receive(stream adsStream) error {
}
}
}
}
// Select returns an address that is deemed to be the correct one for this cluster.
// Select returns an address that is deemed to be the correct one for this cluster. The returned
func
(
c
*
Client
)
Select
(
cluster
string
)
net
.
IP
{
return
c
.
assignments
.
Select
(
cluster
)
}
// boolean indicates if the cluster exists.
func
(
c
*
Client
)
Select
(
cluster
string
)
(
net
.
IP
,
bool
)
{
return
c
.
assignments
.
Select
(
cluster
)
}
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