diff --git a/admiral/pkg/clusters/handler.go b/admiral/pkg/clusters/handler.go index 1d160728d..69c48fdce 100644 --- a/admiral/pkg/clusters/handler.go +++ b/admiral/pkg/clusters/handler.go @@ -32,6 +32,8 @@ const ( DefaultBaseEjectionTime int64 = 300 DefaultConsecutiveGatewayErrors uint32 = 50 DefaultInterval int64 = 60 + DefaultHTTP2MaxRequests int32 = 1000 + DefaultMaxRequestsPerConnection int32 = 100 ) // ServiceEntryHandler responsible for handling Add/Update/Delete events for @@ -85,7 +87,22 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP dr = &v1alpha32.DestinationRule{} ) dr.Host = se.Hosts[0] - dr.TrafficPolicy = &v1alpha32.TrafficPolicy{Tls: &v1alpha32.ClientTLSSettings{Mode: v1alpha32.ClientTLSSettings_ISTIO_MUTUAL}} + dr.TrafficPolicy = &v1alpha32.TrafficPolicy{ + Tls: &v1alpha32.ClientTLSSettings{ + Mode: v1alpha32.ClientTLSSettings_ISTIO_MUTUAL, + }, + ConnectionPool: &v1alpha32.ConnectionPoolSettings{ + Http: &v1alpha32.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequests, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, + LoadBalancer: &v1alpha32.LoadBalancerSettings{ + LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{ + Simple: v1alpha32.LoadBalancerSettings_LEAST_REQUEST, + }, + }, + } if len(locality) == 0 { log.Warnf(LogErrFormat, "Process", "GlobalTrafficPolicy", dr.Host, "", "Skipping gtp processing, locality of the cluster nodes cannot be determined. Is this minikube?") @@ -93,7 +110,7 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP } if gtpTrafficPolicy != nil && processGtp { var loadBalancerSettings = &v1alpha32.LoadBalancerSettings{ - LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{Simple: v1alpha32.LoadBalancerSettings_ROUND_ROBIN}, + LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{Simple: v1alpha32.LoadBalancerSettings_LEAST_REQUEST}, } if len(gtpTrafficPolicy.Target) > 0 { diff --git a/admiral/pkg/clusters/handler_test.go b/admiral/pkg/clusters/handler_test.go index 431e957e4..c8fa424ac 100644 --- a/admiral/pkg/clusters/handler_test.go +++ b/admiral/pkg/clusters/handler_test.go @@ -180,7 +180,23 @@ func TestGetDestinationRule(t *testing.T) { Interval: &duration.Duration{Seconds: 60}, MaxEjectionPercent: 100, } - mTLS := &v1alpha3.TrafficPolicy{Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL}, OutlierDetection: outlierDetection} + mTLS := &v1alpha3.TrafficPolicy{ + Tls: &v1alpha3.ClientTLSSettings{ + Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL, + }, + OutlierDetection: outlierDetection, + ConnectionPool: &v1alpha3.ConnectionPoolSettings{ + Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequests, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, + LoadBalancer: &v1alpha3.LoadBalancerSettings{ + LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{ + Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST, + }, + }, + } se := &v1alpha3.ServiceEntry{Hosts: []string{"qa.myservice.global"}, Endpoints: []*v1alpha3.WorkloadEntry{ {Address: "east.com", Locality: "us-east-2"}, {Address: "west.com", Locality: "us-west-2"}, @@ -195,10 +211,16 @@ func TestGetDestinationRule(t *testing.T) { TrafficPolicy: &v1alpha3.TrafficPolicy{ Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL}, LoadBalancer: &v1alpha3.LoadBalancerSettings{ - LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_ROUND_ROBIN}, + LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST}, LocalityLbSetting: &v1alpha3.LocalityLoadBalancerSetting{}, }, OutlierDetection: outlierDetection, + ConnectionPool: &v1alpha3.ConnectionPoolSettings{ + Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequests, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, }, } @@ -207,7 +229,7 @@ func TestGetDestinationRule(t *testing.T) { TrafficPolicy: &v1alpha3.TrafficPolicy{ Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL}, LoadBalancer: &v1alpha3.LoadBalancerSettings{ - LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_ROUND_ROBIN}, + LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST}, LocalityLbSetting: &v1alpha3.LocalityLoadBalancerSetting{ Distribute: []*v1alpha3.LocalityLoadBalancerSetting_Distribute{ { @@ -218,6 +240,12 @@ func TestGetDestinationRule(t *testing.T) { }, }, OutlierDetection: outlierDetection, + ConnectionPool: &v1alpha3.ConnectionPoolSettings{ + Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequests, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, }, }