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
eaa7f0d6
Commit
eaa7f0d6
authored
Jan 24, 2020
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix documentation and start parsing localities
Signed-off-by:
Miek Gieben
<
miek@miek.nl
>
parent
93eaaf3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
40 deletions
+68
-40
plugin/traffic/README.md
plugin/traffic/README.md
+49
-36
plugin/traffic/setup.go
plugin/traffic/setup.go
+7
-0
plugin/traffic/traffic.go
plugin/traffic/traffic.go
+12
-4
No files found.
plugin/traffic/README.md
View file @
eaa7f0d6
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
The
*traffic*
plugin is a balancer that allows traffic steering, weighted responses
The
*traffic*
plugin is a balancer that allows traffic steering, weighted responses
and draining of clusters. The cluster information is retrieved from a service
and draining of clusters. The cluster information is retrieved from a service
discovery manager that implements the service discovery protocols from Envoy
discovery manager that implements the service discovery protocols from Envoy
[
implements
](
https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol
)
. It connect to the
[
implements
](
https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol
)
. It connect
s
to the
manager using the Aggregated Discovery Service (ADS) protocol.
manager using the Aggregated Discovery Service (ADS) protocol.
A Cluster in Envoy is defined as: "A group of logically similar endpoints that Envoy connects to."
A Cluster in Envoy is defined as: "A group of logically similar endpoints that Envoy connects to."
...
@@ -48,41 +48,52 @@ traffic TO...
...
@@ -48,41 +48,52 @@ traffic TO...
This enabled the
*traffic*
plugin, with a default node ID of
`coredns`
and no TLS.
This enabled the
*traffic*
plugin, with a default node ID of
`coredns`
and no TLS.
*
**TO...**
are the control plane endpoints to connect to. These must start with
`grpc://`
. The
*
**TO...**
are the control plane endpoints to connect to. These must start with
`grpc://`
. The
port number defaults to 443, if not specified.
port number defaults to 443, if not specified.
The extended syntax is available if you want more control.
The extended syntax is available if you want more control.
~~~
~~~
traffic TO... {
traffic TO... {
node ID
node ID
locality REGION
,ZONE,SUBZONE [REGION,ZONE,SUBZONE
]...
locality REGION
[,ZONE[,SUBZONE]] [REGION[,ZONE[,SUBZONE]]
]...
tls CERT KEY CA
tls CERT KEY CA
tls_servername NAME
tls_servername NAME
ignore_health
ignore_health
}
}
~~~
~~~
*
`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
*
`locality`
has a list of
**REGION,ZONE,SUBZONE**
s. These tell
*traffic*
where its running and what should be
`coredns`
.
considered local traffic. Each
**REGION,ZONE,SUBZONE**
will be used to match clusters again while generating
responses. The list should descend in proximity. A
`*`
describes a wild card match. I.e. when
*
`locality`
has a list of
**REGION,ZONE,SUBZONE**
sets. These tell
*traffic*
where its running
there are 3 regions, US, EU, ASIA, and this CoreDNS is running in EU, you can use:
and what should be considered local traffic. Each
**REGION,ZONE,SUBZONE**
set will be used
`locality EU,*,* US,*,*, ASIA,*,*`
. Only when the cluster's locality isn't UNKNOWN will this
to match clusters against while generating responses. The list should descend in proximity.
matching happen.
**ZONE**
or
**ZONE**
*and*
**SUBZONE**
may be omitted. This signifies a wild card match.
*
`tls`
**CERT**
**KEY**
**CA**
define the TLS properties for gRPC connection. If this is omitted an
I.e. when there are 3 regions, US, EU, ASIA, and this CoreDNS is running in EU, you can use:
insecure connection is attempted. From 0 to 3 arguments can be provided with the meaning as described below
`locality EU US ASIA`
. Each list must be separated using spaces. The elements within a set
should be separated with only a comma.
*
`tls`
- no client authentication is used, and the system CAs are 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**
**CA**
define the TLS properties for gRPC connection. If this is omitted
*
`tls`
**CERT**
**KEY**
- client authentication is used with the specified cert/key pair.
an insecure connection is attempted. From 0 to 3 arguments can be provided with the meaning as
The server certificate is verified with the system CAs.
described below
*
`tls`
**CERT**
**KEY**
**CA**
- client authentication is used with the specified cert/key pair.
The server certificate is verified using the specified CA file.
- `tls` - no client authentication is used, and the system CAs are used to verify the server
certificate
*
`tls_servername`
**NAME**
allows you to set a server name in the TLS configuration. This is needed
because
*traffic*
connects to an IP address, so it can't infer the server name from it.
- `tls` **CA** - no client authentication is used, and the file CA is used to verify the
*
`ignore_health`
can be enabled to ignore endpoint health status, this can aid in debugging.
server certificate
- `tls` **CERT** **KEY** - client authentication is used with the specified cert/key pair. The
server certificate is verified with the system CAs.
- `tls` **CERT** **KEY** **CA** - client authentication is used with the specified cert/key
pair. 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 because
*traffic*
connects to an IP address, so it can't infer the server name from it.
*
`ignore_health`
can be enabled to ignore endpoint health status, this can aid in debugging.
## Naming Clusters
## Naming Clusters
...
@@ -99,27 +110,29 @@ is used in the configuration.
...
@@ -99,27 +110,29 @@ is used in the configuration.
## Matching Algorithm
## Matching Algorithm
How are clients match against the data we receive from xDS endpoint? Ignoring
`locality`
for now,
How are clients match against the data we receive from xDS endpoint? Ignoring
`locality`
for now, it
it will go through the following steps:
will go through the following steps:
1.
Does the cluster exist? If not return NXDOMAIN, otherwise continue.
2.
Run through the endpoints, discard any endpoints that are not HEALTHY. If we are left with no
endpoint return a NODATA response, otherwise continue.
1.
Does the cluster exist? If not return NXDOMAIN, otherwise continue.
3.
If weights are assigned use those to pick an endpoint, otherwise randomly pick one and return a
2.
Run through the endpoints, discard any endpoints that are not HEALTHY. If we are left with no
response to the client.
endpoint return a NODATA response, otherwise continue.
3.
If weights are assigned use those to pick an endpoint, otherwise randomly pick one and return a
response to the client.
If
`locality`
*has*
been specified there is an extra step between 2 and 3.
If
`locality`
*has*
been specified there is an extra step between 2 and 3.
2a. Match the endpoints using the locality that groups several of them, it's the most specific
match
2a. Match the endpoints using the locality that groups several of them, it's the most specific
from left to right in the
`locality`
list; if no
**REGION,ZONE,SUBZONE**
matches then try
match
from left to right in the
`locality`
list; if no
**REGION,ZONE,SUBZONE**
matches then try
**REGION,ZONE**
and then
**REGION**
. If still not match, move on the to next one. If we found
**REGION,ZONE**
and then
**REGION**
. If still not match, move on the to next one. If we found none,
none,
we continue with step 4 above, ignoring any locality.
we continue with step 4 above, ignoring any locality.
## Metrics
## Metrics
If monitoring is enabled (via the
*prometheus*
plugin) then the following metric are exported:
If monitoring is enabled (via the
*prometheus*
plugin) then the following metric are exported:
*
`coredns_traffic_clusters_tracked{}`
the number of tracked clusters.
*
`coredns_traffic_clusters_tracked{}`
the number of tracked clusters.
## Ready
## Ready
...
...
plugin/traffic/setup.go
View file @
eaa7f0d6
...
@@ -124,3 +124,10 @@ func parseTraffic(c *caddy.Controller) (*Traffic, error) {
...
@@ -124,3 +124,10 @@ func parseTraffic(c *caddy.Controller) (*Traffic, error) {
return
t
,
nil
return
t
,
nil
}
}
// parseLoc parses string s into loc's. Each loc must be space separated from the other, inside
// a loc we have region,zone,subzone, where subzone or subzone and zone maybe empty. If specified
// they must be comma separate (not spaces or anything).
func
parseLoc
(
s
string
)
([]
loc
,
error
)
{
return
nil
,
nil
}
plugin/traffic/traffic.go
View file @
eaa7f0d6
...
@@ -17,10 +17,11 @@ import (
...
@@ -17,10 +17,11 @@ import (
// Traffic is a plugin that load balances according to assignments.
// Traffic is a plugin that load balances according to assignments.
type
Traffic
struct
{
type
Traffic
struct
{
c
*
xds
.
Client
c
*
xds
.
Client
id
string
id
string
health
bool
health
bool
origins
[]
string
origins
[]
string
locality
[]
loc
Next
plugin
.
Handler
Next
plugin
.
Handler
}
}
...
@@ -181,3 +182,10 @@ func soa(z string) []dns.RR {
...
@@ -181,3 +182,10 @@ func soa(z string) []dns.RR {
// Name implements the plugin.Handler interface.
// Name implements the plugin.Handler interface.
func
(
t
*
Traffic
)
Name
()
string
{
return
"traffic"
}
func
(
t
*
Traffic
)
Name
()
string
{
return
"traffic"
}
// loc holds the locality for this server. It a list of the set region, zone, subzone.
type
loc
struct
{
region
string
zone
string
subzone
string
}
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