Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Frank Schröder edited this pageOct 25, 2017 ·7 revisions

Manual overrides

Since an automatically generated routing table can only be changed with aservice deployment additional routing commands can be stored manually in theconsul KV store which get appended to the automatically generated routingtable. This allows fine-tuning and fixing of problems without a deployment.

The routing commands are also stored in the KV store.

Config Language

The routing table is configured with commands in the language specified below.

Comments

Blank lines and lines starting with# or// are ignored.

route add

Add a route for a servicesvc for thesrc (e.g./path or:port) to adst (e.g.URL orhost:port).

route add <svc> <src> <dst>[ weight <w>][ tags "<t1>,<t2>,..."][ opts "k1=v1 k2=v2 ..."]

Options

OptionDescription
strip=/pathForward/path/to/file as/to/file
proto=tcpUpstream service is TCP,dst must be:port
proto=httpsUpstream service is HTTPS
tlsskipverify=trueDisable TLS cert validation for HTTPS upstream
host=nameSet theHost header toname. Ifname == 'dst' then theHost header will be set to the registered upstream host name

Example

# route traffic for product-svc to 1.2.3.4:8000 and :9000route add product-svc /product http://1.2.3.4:8000route add product-svc /product http://1.2.3.4:9000

route del

Remove one or more routes which match the given criteria.

route del <svc>[ <src>[ <dst>]]route del <svc> tags "<t1>,<t2>,..."route del tags "<t1>,<t2>,..."

Example

# remove all routes for 'product-svc'route del product-svc# remove all routes for 'product-svc' and /pathroute del product-svc /path# remove single routeroute del product-svc /path http://1.2.3.4:8000# remove all routes for 'product-svc' matching a tagroute del product-svc tags "green"# remove all routes matching a tagroute del tags "yesterday"

route weight

Directs a certain amount of traffic to instances matching certain criteria.

The weightw is expressed as follows:

  • w is a float > 0 describing a percentage, e.g. 0.5 == 50%
  • w <= 0: means no fixed weighting. Traffic is evenly distributed
  • w > 0: route will receive n% of traffic. If sum(w) > 1 then w is normalized.
  • sum(w) >= 1: only matching services will receive traffic

Note that the total sum of traffic sent to all matching routes isw%.

The order of commands matters but routes are always ordered from most to leastspecific by prefix length.

route weight <svc> <src> weight <w> tags "<t1>,<t2>,..."route weight <src> weight <w> tags "<t1>,<t2>,..."route weight <svc> <src> weight <w>route weight service host/path weight w tags "tag1,tag2"

Example

# Route 5% of the traffic to product-svc:/path with tags "green"route weight product-svc /path weight .05 tags "green"# Route 5% of the traffic to '/path' to the Go implementation.# Route the rest (95%) to the other implementationroute weight /path weight .05 tags "lang=go"# Route 5% of the traffice to '/path' on the product-svc-goroute weight product-svc-go /path weight .05

Routing rules

The routing table contains first all routes with a host sorted by prefixlength in descending order and then all routes without a host again sorted byprefix length in descending order.

For each incoming request the routing table is searched top to bottom for amatching route. A route matches if eitherhost/path or - if there was nomatch - just/path matches.

The matching route determines the target URL depending on the configuredstrategy.rnd andrr are available withrnd being the default.

Example

The auto-generated routing table is

route add service-a www.mp.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.kjca.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.dba.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-b www.mp.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.kjca.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.dba.dev/auth/ http://host-b:11080/ tags "a,b"

The manual configuration under/fabio/config is

route del service-b www.dba.dev/auth/route add service-c www.somedomain.com/ http://host-z:12345/

The complete routing table then is

route add service-a www.mp.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.kjca.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.dba.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-b www.mp.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.kjca.dev/auth/ http://host-b:11080/ tags "a,b"route add service-c www.somedomain.com/ http://host-z:12345/ tags "a,b"
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp