|
|
@ -104,7 +104,7 @@ func (s *Server) routesFromSnapshotTerminatingGateway(_ connectionInfo, cfgSnap
|
|
|
|
if resolver.LoadBalancer != nil {
|
|
|
|
if resolver.LoadBalancer != nil {
|
|
|
|
lb = resolver.LoadBalancer
|
|
|
|
lb = resolver.LoadBalancer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb)
|
|
|
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, true)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
|
|
|
logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -114,7 +114,7 @@ func (s *Server) routesFromSnapshotTerminatingGateway(_ connectionInfo, cfgSnap
|
|
|
|
// If there is a service-resolver for this service then also setup routes for each subset
|
|
|
|
// If there is a service-resolver for this service then also setup routes for each subset
|
|
|
|
for name := range resolver.Subsets {
|
|
|
|
for name := range resolver.Subsets {
|
|
|
|
clusterName = connect.ServiceSNI(svc.Name, name, svc.NamespaceOrDefault(), cfgSnap.Datacenter, cfgSnap.Roots.TrustDomain)
|
|
|
|
clusterName = connect.ServiceSNI(svc.Name, name, svc.NamespaceOrDefault(), cfgSnap.Datacenter, cfgSnap.Roots.TrustDomain)
|
|
|
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb)
|
|
|
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, true)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
|
|
|
logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -126,13 +126,20 @@ func (s *Server) routesFromSnapshotTerminatingGateway(_ connectionInfo, cfgSnap
|
|
|
|
return resources, nil
|
|
|
|
return resources, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func makeNamedDefaultRouteWithLB(clusterName string, lb *structs.LoadBalancer) (*envoy_route_v3.RouteConfiguration, error) {
|
|
|
|
func makeNamedDefaultRouteWithLB(clusterName string, lb *structs.LoadBalancer, autoHostRewrite bool) (*envoy_route_v3.RouteConfiguration, error) {
|
|
|
|
action := makeRouteActionFromName(clusterName)
|
|
|
|
action := makeRouteActionFromName(clusterName)
|
|
|
|
|
|
|
|
|
|
|
|
if err := injectLBToRouteAction(lb, action.Route); err != nil {
|
|
|
|
if err := injectLBToRouteAction(lb, action.Route); err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to apply load balancer configuration to route action: %v", err)
|
|
|
|
return nil, fmt.Errorf("failed to apply load balancer configuration to route action: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Configure Envoy to rewrite Host header
|
|
|
|
|
|
|
|
if autoHostRewrite {
|
|
|
|
|
|
|
|
action.Route.HostRewriteSpecifier = &envoy_route_v3.RouteAction_AutoHostRewrite{
|
|
|
|
|
|
|
|
AutoHostRewrite: makeBoolValue(true),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return &envoy_route_v3.RouteConfiguration{
|
|
|
|
return &envoy_route_v3.RouteConfiguration{
|
|
|
|
Name: clusterName,
|
|
|
|
Name: clusterName,
|
|
|
|
VirtualHosts: []*envoy_route_v3.VirtualHost{
|
|
|
|
VirtualHosts: []*envoy_route_v3.VirtualHost{
|
|
|
|