Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose envoy cluster options in policy (#1804)
- Loading branch information
Showing
13 changed files
with
277 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
package config | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
|
||
"google.golang.org/protobuf/encoding/protojson" | ||
) | ||
|
||
const ( | ||
policyKey = "policy" | ||
toKey = "to" | ||
healthCheckKey = "health_check" | ||
policyKey = "policy" | ||
toKey = "to" | ||
envoyOptsKey = "_envoy_opts" | ||
) | ||
|
||
var ( | ||
errKeysMustBeStrings = errors.New("cannot convert nested map: all keys must be strings") | ||
) | ||
|
||
var ( | ||
protoPartial = protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: Upstream Load Balancing | ||
description: >- | ||
This article covers Pomerium built-in load balancing capabilities in presence of multiple upstreams. | ||
--- | ||
|
||
# Upstream Load Balancing | ||
|
||
This article covers Pomerium built-in load balancing capabilities in presence of multiple upstreams. | ||
|
||
## Multiple Upstreams | ||
|
||
You may specify multiple servers for your upstream application, and Pomerium would load balance user requests between them. | ||
|
||
```yaml | ||
policy: | ||
- from: https://myapp.localhost.pomerium.io | ||
to: | ||
- http://myapp-srv-1:8080 | ||
- http://myapp-srv-2:8080 | ||
``` | ||
|
||
::: tip | ||
In presence of multiple upstreams, make sure to specify either an active or passive health check, or both, to avoid requests served to unhealthy backend. | ||
::: | ||
|
||
### Active Health Checks | ||
|
||
Active health checks issue periodic requests to each upstream to determine its health. | ||
See [Health Checking](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/health_checking) for a comprehensive overview. | ||
|
||
```yaml | ||
policy: | ||
- from: https://myapp.localhost.pomerium.io | ||
to: | ||
- http://myapp-srv-1:8080 | ||
- http://myapp-srv-2:8080 | ||
health_checks: | ||
- timeout: 10s | ||
interval: 60s | ||
healthy_threshold: 1 | ||
unhealthy_threshold: 2 | ||
http_health_check: | ||
path: "/" | ||
``` | ||
### Passive Health Checks | ||
|
||
Passive health check tries to deduce upstream server health based on recent observed responses. | ||
See [Outlier Detection](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/outlier) for a comprehensive overview. | ||
|
||
## Load Balancing Method | ||
|
||
`lb_policy` should be set to one of the values: | ||
|
||
- [`ROUND_ROBIN`](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#weighted-round-robin) (default) | ||
- [`LEAST_REQUEST`](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#weighted-least-request) and may be further configured using [``](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-msg-config-cluster-v3-cluster-leastrequestlbconfig) | ||
- [`RING_HASH`](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#ring-hash) and may be further configured using [`ring_hash_lb_config`](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#config-cluster-v3-cluster-ringhashlbconfig) option | ||
- [`RANDOM`](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#random) | ||
- [`MAGLEV`](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#maglev) and may be further configured using [`maglev_lb_config`](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-msg-config-cluster-v3-cluster-maglevlbconfig) option | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package controlplane | ||
|
||
import ( | ||
"errors" | ||
"time" | ||
|
||
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" | ||
"github.com/golang/protobuf/ptypes" | ||
) | ||
|
||
var ( | ||
errNoEndpoints = errors.New("cluster must have endpoints") | ||
defaultConnectionTimeout = ptypes.DurationProto(time.Second * 10) | ||
) | ||
|
||
// newDefaultEnvoyClusterConfig creates envoy cluster with certain default values | ||
func newDefaultEnvoyClusterConfig() *envoy_config_cluster_v3.Cluster { | ||
return &envoy_config_cluster_v3.Cluster{ | ||
ConnectTimeout: defaultConnectionTimeout, | ||
RespectDnsTtl: true, | ||
DnsLookupFamily: envoy_config_cluster_v3.Cluster_AUTO, | ||
} | ||
} |
Oops, something went wrong.