@@ -514,7 +514,14 @@ func processEndpoints(clusterName string, clusterDetails *model.EndpointCluster,
514
514
515
515
addresses := []* corev3.Address {}
516
516
517
+ withinClusterEndpoint := false
518
+
517
519
for i , ep := range clusterDetails .Endpoints {
520
+
521
+ if ep .URLType == "http" && strings .HasSuffix (ep .Host , "svc.cluster.local" ) {
522
+ withinClusterEndpoint = true
523
+ }
524
+
518
525
// validating the basepath to be same for all upstreams of an api
519
526
if strings .TrimSuffix (ep .Basepath , "/" ) != basePath {
520
527
return nil , nil , errors .New ("endpoint basepath mismatched for " + ep .RawURL + ". expected : " + basePath + " but found : " + ep .Basepath )
@@ -612,6 +619,26 @@ func processEndpoints(clusterName string, clusterDetails *model.EndpointCluster,
612
619
TypedDnsResolverConfig : dnsResolverConf ,
613
620
}
614
621
622
+ // If the endpoint is within the cluster, set the max requests per connection to 1
623
+ // This ensure cilium proxy will not reuse the connection
624
+ if withinClusterEndpoint && os .Getenv ("ROUTER_DISABLE_IN_CLUSTER_CONNECTION_POOLING" ) == "true" {
625
+ config := & upstreams.HttpProtocolOptions {
626
+ CommonHttpProtocolOptions : & corev3.HttpProtocolOptions {
627
+ MaxRequestsPerConnection : wrapperspb .UInt32 (1 ),
628
+ },
629
+ }
630
+
631
+ marshalledConfig , err := anypb .New (config )
632
+ if err != nil {
633
+ return nil , nil , errors .New ("internal Error while marshalling the HTTP Protocol Options" )
634
+ }
635
+
636
+ // Add to cluster's TypedExtensionProtocolOptions instead of deprecated fields
637
+ cluster .TypedExtensionProtocolOptions = map [string ]* any.Any {
638
+ "envoy.extensions.upstreams.http.v3.HttpProtocolOptions" : marshalledConfig ,
639
+ }
640
+ }
641
+
615
642
if len (clusterDetails .Endpoints ) > 1 {
616
643
cluster .HealthChecks = createHealthCheck ()
617
644
}
0 commit comments