mirror of
https://github.com/status-im/consul.git
synced 2025-01-20 18:50:04 +00:00
Add TCP keepalive settings to proxy config for mesh gateways
This commit is contained in:
parent
1a883891a7
commit
2242d1ec4a
@ -1534,6 +1534,19 @@ func (s *ResourceGenerator) makeGatewayCluster(snap *proxycfg.ConfigSnapshot, op
|
|||||||
useEDS = false
|
useEDS = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set TCP keepalive settings on the upstream gateway cluster if enabled.
|
||||||
|
if opts.isRemote && cfg.TcpKeepaliveEnable {
|
||||||
|
cluster.UpstreamConnectionOptions = &envoy_cluster_v3.UpstreamConnectionOptions{
|
||||||
|
TcpKeepalive: &envoy_core_v3.TcpKeepalive{},
|
||||||
|
}
|
||||||
|
if cfg.TcpKeepaliveTime != 0 {
|
||||||
|
cluster.UpstreamConnectionOptions.TcpKeepalive.KeepaliveTime = makeUint32Value(cfg.TcpKeepaliveTime)
|
||||||
|
}
|
||||||
|
if cfg.TcpKeepaliveInterval != 0 {
|
||||||
|
cluster.UpstreamConnectionOptions.TcpKeepalive.KeepaliveInterval = makeUint32Value(cfg.TcpKeepaliveInterval)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If none of the service instances are addressed by a hostname we provide the endpoint IP addresses via EDS
|
// If none of the service instances are addressed by a hostname we provide the endpoint IP addresses via EDS
|
||||||
if useEDS {
|
if useEDS {
|
||||||
cluster.ClusterDiscoveryType = &envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_EDS}
|
cluster.ClusterDiscoveryType = &envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_EDS}
|
||||||
|
@ -412,6 +412,16 @@ func TestClustersFromSnapshot(t *testing.T) {
|
|||||||
return proxycfg.TestConfigSnapshotMeshGateway(t, "hash-lb-ignored", nil, nil)
|
return proxycfg.TestConfigSnapshotMeshGateway(t, "hash-lb-ignored", nil, nil)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "mesh-gateway-tcp-keepalives",
|
||||||
|
create: func(t testinf.T) *proxycfg.ConfigSnapshot {
|
||||||
|
return proxycfg.TestConfigSnapshotMeshGateway(t, "default", func(ns *structs.NodeService) {
|
||||||
|
ns.Proxy.Config["envoy_mesh_gateway_tcp_enable_keepalive"] = true
|
||||||
|
ns.Proxy.Config["envoy_mesh_gateway_tcp_keepalive_time"] = 120
|
||||||
|
ns.Proxy.Config["envoy_mesh_gateway_tcp_keepalive_interval"] = 60
|
||||||
|
}, nil)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "ingress-gateway",
|
name: "ingress-gateway",
|
||||||
create: func(t testinf.T) *proxycfg.ConfigSnapshot {
|
create: func(t testinf.T) *proxycfg.ConfigSnapshot {
|
||||||
|
@ -132,6 +132,12 @@ type GatewayConfig struct {
|
|||||||
// ConnectTimeoutMs is the number of milliseconds to timeout making a new
|
// ConnectTimeoutMs is the number of milliseconds to timeout making a new
|
||||||
// connection to this upstream. Defaults to 5000 (5 seconds) if not set.
|
// connection to this upstream. Defaults to 5000 (5 seconds) if not set.
|
||||||
ConnectTimeoutMs int `mapstructure:"connect_timeout_ms"`
|
ConnectTimeoutMs int `mapstructure:"connect_timeout_ms"`
|
||||||
|
|
||||||
|
// TCP keepalive settings for connections between remote mesh gateways.
|
||||||
|
// See: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/address.proto#envoy-v3-api-msg-config-core-v3-tcpkeepalive
|
||||||
|
TcpKeepaliveEnable bool `mapstructure:"envoy_mesh_gateway_tcp_enable_keepalive"`
|
||||||
|
TcpKeepaliveTime int `mapstructure:"envoy_mesh_gateway_tcp_keepalive_time"`
|
||||||
|
TcpKeepaliveInterval int `mapstructure:"envoy_mesh_gateway_tcp_keepalive_interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseGatewayConfig returns the GatewayConfig parsed from an opaque map. If an
|
// ParseGatewayConfig returns the GatewayConfig parsed from an opaque map. If an
|
||||||
|
140
agent/xds/testdata/clusters/mesh-gateway-tcp-keepalives.latest.golden
vendored
Normal file
140
agent/xds/testdata/clusters/mesh-gateway-tcp-keepalives.latest.golden
vendored
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
{
|
||||||
|
"versionInfo": "00000001",
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"name": "bar.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"type": "EDS",
|
||||||
|
"edsClusterConfig": {
|
||||||
|
"edsConfig": {
|
||||||
|
"ads": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"resourceApiVersion": "V3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"connectTimeout": "5s",
|
||||||
|
"outlierDetection": {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"name": "dc2.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"type": "EDS",
|
||||||
|
"edsClusterConfig": {
|
||||||
|
"edsConfig": {
|
||||||
|
"ads": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"resourceApiVersion": "V3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"connectTimeout": "5s",
|
||||||
|
"outlierDetection": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"upstreamConnectionOptions": {
|
||||||
|
"tcpKeepalive": {
|
||||||
|
"keepaliveTime": 120,
|
||||||
|
"keepaliveInterval": 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"name": "dc4.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"type": "LOGICAL_DNS",
|
||||||
|
"connectTimeout": "5s",
|
||||||
|
"loadAssignment": {
|
||||||
|
"clusterName": "dc4.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"endpoints": [
|
||||||
|
{
|
||||||
|
"lbEndpoints": [
|
||||||
|
{
|
||||||
|
"endpoint": {
|
||||||
|
"address": {
|
||||||
|
"socketAddress": {
|
||||||
|
"address": "123.us-west-2.elb.notaws.com",
|
||||||
|
"portValue": 443
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"healthStatus": "HEALTHY",
|
||||||
|
"loadBalancingWeight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dnsRefreshRate": "10s",
|
||||||
|
"dnsLookupFamily": "V4_ONLY",
|
||||||
|
"outlierDetection": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"upstreamConnectionOptions": {
|
||||||
|
"tcpKeepalive": {
|
||||||
|
"keepaliveTime": 120,
|
||||||
|
"keepaliveInterval": 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"name": "dc6.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"type": "LOGICAL_DNS",
|
||||||
|
"connectTimeout": "5s",
|
||||||
|
"loadAssignment": {
|
||||||
|
"clusterName": "dc6.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"endpoints": [
|
||||||
|
{
|
||||||
|
"lbEndpoints": [
|
||||||
|
{
|
||||||
|
"endpoint": {
|
||||||
|
"address": {
|
||||||
|
"socketAddress": {
|
||||||
|
"address": "123.us-east-1.elb.notaws.com",
|
||||||
|
"portValue": 443
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"healthStatus": "UNHEALTHY",
|
||||||
|
"loadBalancingWeight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dnsRefreshRate": "10s",
|
||||||
|
"dnsLookupFamily": "V4_ONLY",
|
||||||
|
"outlierDetection": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"upstreamConnectionOptions": {
|
||||||
|
"tcpKeepalive": {
|
||||||
|
"keepaliveTime": 120,
|
||||||
|
"keepaliveInterval": 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"name": "foo.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||||
|
"type": "EDS",
|
||||||
|
"edsClusterConfig": {
|
||||||
|
"edsConfig": {
|
||||||
|
"ads": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"resourceApiVersion": "V3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"connectTimeout": "5s",
|
||||||
|
"outlierDetection": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"typeUrl": "type.googleapis.com/envoy.config.cluster.v3.Cluster",
|
||||||
|
"nonce": "00000001"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user