无法连接到远程 Kubernetes 服务 - SERVICE_UNAVAILABLE

问题描述 投票:0回答:1

我正在尝试进行以下测试设置:Spring 云网关将消息在内部转发到内部微服务。我尝试了这个网关项目:

https://github.com/rcbandit111/gateway

内部微服务:

https://github.com/rcbandit111/mockup

路由设置到网关:

    server:
      port: 8888
      servlet:
        context-path: /api
    spring:
      application:
        name: gateway
      cloud:
        gateway:
          routes:
            - id: mockup
              uri: lb://mockup
              predicates:
                - Path=/api/mockup/admin/**
              filters:
                - RemoveRequestHeader=Cookie
                - name: CircuitBreaker
                  args:
                    name: mockup
                - RewritePath=/api/mockup/admin/(?<path>.*), /mockup/admin/$\{path}

          httpclient:
            wiretap: true
          httpserver:
            wiretap: true

    logging:
      level:
        reactor:
          netty: DEBUG
        org:
          springframework:
            cloud:
              gateway: TRACE

呼叫的 Postman 配置:

`curl --location --request POST 'localhost:8888/api/mockup/admin/greeting'

来自网关的日志文件:

root@node1:~# kubectl logs gateway-57b7c558bc-ncthg

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.4)

2024-04-23T16:35:05.883Z  INFO 1 --- [gateway] [           main] org.gateway.Application                  : The following 1 profile is active: "kubernetes"
2024-04-23T16:35:32.887Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$TokenRelayConfiguration matched
2024-04-23T16:35:33.190Z TRACE 1 --- [gateway] [           main] Configuration$OnVerboseDisabledCondition : Condition GatewayAutoConfiguration.OnVerboseDisabledCondition on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$GatewayActuatorConfiguration#gatewayLegacyControllerEndpoint did not match due to NoneNestedConditions 1 matched 0 did not; NestedCondition on GatewayAutoConfiguration.OnVerboseDisabledCondition.VerboseDisabled @ConditionalOnProperty (spring.cloud.gateway.actuator.verbose.enabled) matched
2024-04-23T16:35:33.886Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration#routingFilter matched
2024-04-23T16:35:33.888Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration#nettyWriteResponseFilter matched
2024-04-23T16:35:33.985Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration#reactorNettyWebSocketClient matched
2024-04-23T16:35:33.987Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration#reactorNettyRequestUpgradeStrategy matched
2024-04-23T16:35:35.591Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#adaptCachedBodyGlobalFilter matched
2024-04-23T16:35:35.594Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#removeCachedBodyFilter matched
2024-04-23T16:35:35.684Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#routeToRequestUrlFilter matched
2024-04-23T16:35:35.686Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#forwardRoutingFilter matched
2024-04-23T16:35:35.689Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#forwardPathFilter matched
2024-04-23T16:35:35.783Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#webSocketService matched
2024-04-23T16:35:35.784Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledGlobalFilter        : Condition OnEnabledGlobalFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#websocketRoutingFilter matched
2024-04-23T16:35:35.785Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#weightCalculatorWebFilter matched
2024-04-23T16:35:35.786Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#afterRoutePredicateFactory matched
2024-04-23T16:35:35.787Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#beforeRoutePredicateFactory matched
2024-04-23T16:35:35.788Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#betweenRoutePredicateFactory matched
2024-04-23T16:35:35.788Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#cookieRoutePredicateFactory matched
2024-04-23T16:35:35.791Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#headerRoutePredicateFactory matched
2024-04-23T16:35:35.883Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#hostRoutePredicateFactory matched
2024-04-23T16:35:35.885Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#methodRoutePredicateFactory matched
2024-04-23T16:35:35.886Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#pathRoutePredicateFactory matched
2024-04-23T16:35:35.887Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#queryRoutePredicateFactory matched
2024-04-23T16:35:35.889Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#readBodyPredicateFactory matched
2024-04-23T16:35:35.890Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#remoteAddrRoutePredicateFactory matched
2024-04-23T16:35:35.890Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#xForwardedRemoteAddrRoutePredicateFactory matched
2024-04-23T16:35:35.984Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#weightRoutePredicateFactory matched
2024-04-23T16:35:35.984Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.c.OnEnabledPredicate           : Condition OnEnabledPredicate on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#cloudFoundryRouteServiceRoutePredicateFactory matched
2024-04-23T16:35:35.985Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#addRequestHeaderGatewayFilterFactory matched
2024-04-23T16:35:35.986Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#addRequestHeadersIfNotPresentGatewayFilterFactory matched
2024-04-23T16:35:36.183Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#mapRequestHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.188Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#addRequestParameterGatewayFilterFactory matched
2024-04-23T16:35:36.191Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#addResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.193Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#modifyRequestBodyGatewayFilterFactory matched
2024-04-23T16:35:36.283Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#dedupeResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.284Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#modifyResponseBodyGatewayFilterFactory matched
2024-04-23T16:35:36.284Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#cacheRequestBodyGatewayFilterFactory matched
2024-04-23T16:35:36.285Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#prefixPathGatewayFilterFactory matched
2024-04-23T16:35:36.286Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#preserveHostHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.288Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#redirectToGatewayFilterFactory matched
2024-04-23T16:35:36.289Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#removeJsonAttributesResponseBodyGatewayFilterFactory matched
2024-04-23T16:35:36.290Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#removeRequestHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.383Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#removeRequestParameterGatewayFilterFactory matched
2024-04-23T16:35:36.387Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#removeResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.885Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#rewritePathGatewayFilterFactory matched
2024-04-23T16:35:36.887Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#retryGatewayFilterFactory matched
2024-04-23T16:35:36.888Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#setPathGatewayFilterFactory matched
2024-04-23T16:35:36.889Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#secureHeadersGatewayFilterFactory matched
2024-04-23T16:35:36.889Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#setRequestHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.890Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#setRequestHostHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.984Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#setResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.987Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#rewriteResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.988Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#rewriteLocationResponseHeaderGatewayFilterFactory matched
2024-04-23T16:35:36.989Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#setStatusGatewayFilterFactory matched
2024-04-23T16:35:37.083Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#saveSessionGatewayFilterFactory matched
2024-04-23T16:35:37.085Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#stripPrefixGatewayFilterFactory matched
2024-04-23T16:35:37.086Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#requestHeaderToRequestUriGatewayFilterFactory matched
2024-04-23T16:35:37.088Z TRACE 1 --- [gateway] [           main] o.s.c.g.c.conditional.OnEnabledFilter    : Condition OnEnabledFilter on org.springframework.cloud.gateway.config.GatewayAutoConfiguration#requestSizeGatewayFilterFactory matched
.........
2024-04-23T16:38:00.984Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {_genkey_0=Cookie} to RemoveRequestHeader
2024-04-23T16:38:00.986Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {name=mockup} to CircuitBreaker
2024-04-23T16:38:01.084Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {_genkey_0=/api/mockup/admin/(?<path>.*), _genkey_1=/mockup/admin/$\{path}} to RewritePath
2024-04-23T16:38:01.087Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition matched: mockup
2024-04-23T16:38:01.183Z DEBUG 1 --- [gateway] [           main] o.s.c.g.filter.GatewayMetricsFilter      : New routes count: 1
2024-04-23T16:38:10.891Z  INFO 1 --- [gateway] [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8888
2024-04-23T16:38:11.684Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying {_genkey_0=/api/mockup/admin/**} to Path
2024-04-23T16:38:11.784Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {_genkey_0=Cookie} to RemoveRequestHeader
2024-04-23T16:38:11.790Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {name=mockup} to CircuitBreaker
2024-04-23T16:38:11.793Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition mockup applying filter {_genkey_0=/api/mockup/admin/(?<path>.*), _genkey_1=/mockup/admin/$\{path}} to RewritePath
2024-04-23T16:38:11.884Z DEBUG 1 --- [gateway] [           main] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition matched: mockup
2024-04-23T16:38:11.886Z DEBUG 1 --- [gateway] [           main] o.s.c.g.filter.GatewayMetricsFilter      : New routes count: 1
2024-04-23T16:38:11.984Z  INFO 1 --- [gateway] [           main] org.gateway.Application                  : Started Application in 238.21 seconds (process running for 264.79)
2024-04-23T16:38:24.883Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.f.WeightCalculatorWebFilter      : Weights attr: {}
2024-04-23T16:38:24.994Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.h.p.PathRoutePredicateFactory    : Pattern "/api/mockup/admin/**" matches against value "/api/mockup/admin/greeting"
2024-04-23T16:38:25.082Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : Route matched: mockup
2024-04-23T16:38:25.184Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : Mapping [Exchange: POST http://11.1.1.1.:30055/api/mockup/admin/greeting] to Route{id='mockup', uri=lb://mockup, order=0, predicate=Paths: [/api/mockup/admin/**], match trailing slash: true, gatewayFilters=[[[RemoveRequestHeader name = 'Cookie'], order = 1], [[SpringCloudCircuitBreakerResilience4JFilterFactory name = 'mockup', fallback = [null]], order = 2], [[RewritePath /api/mockup/admin/(?<path>.*) = '/mockup/admin/${path}'], order = 3]], metadata={}}
2024-04-23T16:38:25.185Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : [7cc8013d-1] Mapped to org.springframework.cloud.gateway.handler.FilteringWebHandler@6368358
2024-04-23T16:38:25.186Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.handler.FilteringWebHandler      : Sorted gatewayFilterFactories: [[GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RemoveCachedBodyFilter@2b464384}, order = -2147483648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@701c482e}, order = -2147482648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@43cf5bff}, order = -1], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardPathFilter@4ede8888}, order = 0], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.GatewayMetricsFilter@65a2755e}, order = 0], [[RemoveRequestHeader name = 'Cookie'], order = 1], [[SpringCloudCircuitBreakerResilience4JFilterFactory name = 'mockup', fallback = [null]], order = 2], [[RewritePath /api/mockup/admin/(?<path>.*) = '/mockup/admin/${path}'], order = 3], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@681b42d3}, order = 10000], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.config.GatewayNoLoadBalancerClientAutoConfiguration$NoLoadBalancerClientFilter@2b3242a5}, order = 10150], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@571db8b4}, order = 2147483646], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@5f781173}, order = 2147483647], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@77f7352a}, order = 2147483647]]
2024-04-23T16:38:25.987Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.filter.RouteToRequestUrlFilter   : RouteToRequestUrlFilter start
2024-04-23T16:38:28.491Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.filter.GatewayMetricsFilter      : spring.cloud.gateway.requests tags: [tag(httpMethod=POST),tag(httpStatusCode=503),tag(outcome=SERVER_ERROR),tag(routeId=mockup),tag(routeUri=lb://mockup),tag(status=SERVICE_UNAVAILABLE)]
2024-04-23T16:39:26.926Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.f.WeightCalculatorWebFilter      : Weights attr: {}
2024-04-23T16:39:26.984Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.h.p.PathRoutePredicateFactory    : Pattern "/api/mockup/admin/**" matches against value "/api/mockup/admin/greeting"
2024-04-23T16:39:26.985Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : Route matched: mockup
2024-04-23T16:39:26.985Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : Mapping [Exchange: POST http://1.1.1.1.1:30055/api/mockup/admin/greeting] to Route{id='mockup', uri=lb://mockup, order=0, predicate=Paths: [/api/mockup/admin/**], match trailing slash: true, gatewayFilters=[[[RemoveRequestHeader name = 'Cookie'], order = 1], [[SpringCloudCircuitBreakerResilience4JFilterFactory name = 'mockup', fallback = [null]], order = 2], [[RewritePath /api/mockup/admin/(?<path>.*) = '/mockup/admin/${path}'], order = 3]], metadata={}}
2024-04-23T16:39:26.985Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.h.RoutePredicateHandlerMapping   : [7cc8013d-2] Mapped to org.springframework.cloud.gateway.handler.FilteringWebHandler@6368358
2024-04-23T16:39:26.986Z DEBUG 1 --- [gateway] [     parallel-1] o.s.c.g.handler.FilteringWebHandler      : Sorted gatewayFilterFactories: [[GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RemoveCachedBodyFilter@2b464384}, order = -2147483648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@701c482e}, order = -2147482648], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@43cf5bff}, order = -1], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardPathFilter@4ede8888}, order = 0], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.GatewayMetricsFilter@65a2755e}, order = 0], [[RemoveRequestHeader name = 'Cookie'], order = 1], [[SpringCloudCircuitBreakerResilience4JFilterFactory name = 'mockup', fallback = [null]], order = 2], [[RewritePath /api/mockup/admin/(?<path>.*) = '/mockup/admin/${path}'], order = 3], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@681b42d3}, order = 10000], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.config.GatewayNoLoadBalancerClientAutoConfiguration$NoLoadBalancerClientFilter@2b3242a5}, order = 10150], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@571db8b4}, order = 2147483646], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@5f781173}, order = 2147483647], [GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@77f7352a}, order = 2147483647]]
2024-04-23T16:39:26.988Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.filter.RouteToRequestUrlFilter   : RouteToRequestUrlFilter start
2024-04-23T16:39:27.091Z TRACE 1 --- [gateway] [     parallel-1] o.s.c.g.filter.GatewayMetricsFilter      : spring.cloud.gateway.requests tags: [tag(httpMethod=POST),tag(httpStatusCode=503),tag(outcome=SERVER_ERROR),tag(routeId=mockup),tag(routeUri=lb://mockup),tag(status=SERVICE_UNAVAILABLE)]

微服务日志:

root@node1:~# kubectl logs mockup-6c5cfb4677-gjtxq
Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.4)

2024-04-23T16:24:27.754Z  INFO 1 --- [mockup-test] [           main] com.mockup.mockup.MockupApplication      : The following 1 profile is active: "kubernetes"
2024-04-23T16:25:11.355Z  INFO 1 --- [mockup-test] [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=9caa440b-0f6a-3d84-8563-fc56c1328493
2024-04-23T16:25:23.048Z  WARN 1 --- [mockup-test] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$DeferringLoadBalancerInterceptorConfig' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$DeferringLoadBalancerInterceptorConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [lbRestClientPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
2024-04-23T16:25:23.247Z  WARN 1 --- [mockup-test] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'deferringLoadBalancerInterceptor' of type [org.springframework.cloud.client.loadbalancer.DeferringLoadBalancerInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-04-23T16:25:35.151Z  INFO 1 --- [mockup-test] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8761 (http)
2024-04-23T16:25:35.650Z  INFO 1 --- [mockup-test] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-04-23T16:25:35.651Z  INFO 1 --- [mockup-test] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.19]
2024-04-23T16:25:39.254Z  INFO 1 --- [mockup-test] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-04-23T16:25:39.347Z  INFO 1 --- [mockup-test] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 69803 ms
Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts
2024-04-23T16:26:26.363Z  INFO 1 --- [mockup-test] [           main] o.s.c.k.client.KubernetesClientUtils     : Created API client in the cluster.
2024-04-23T16:26:38.752Z  WARN 1 --- [mockup-test] [           main] .s.s.UserDetailsServiceAutoConfiguration :

Using generated security password: 8507cd38-99c5-44e8-b74b-c2dcfe32a35b

This generated password is for development use only. Your security configuration must be updated before running your application in production.

2024-04-23T16:26:42.851Z  INFO 1 --- [mockup-test] [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2024-04-23T16:26:44.250Z  INFO 1 --- [mockup-test] [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with 
......
2024-04-23T16:27:13.549Z  INFO 1 --- [mockup-test] [           main] s.c.k.c.d.KubernetesDiscoveryClientUtils : Cache fully loaded (total 6 services), discovery client is now available
2024-04-23T16:27:28.151Z  INFO 1 --- [mockup-test] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8761 (http) with context path ''
2024-04-23T16:27:29.050Z  INFO 1 --- [mockup-test] [           main] com.mockup.mockup.MockupApplication      : Started MockupApplication in 230.599 seconds (process running for 253.897)
Starting EventListener when ApplicationReadyEvent !!!
Kubernetes services size 2
Discovered service mockup
Discovered service gateway
root@node1:~#

由于某种原因,未找到模型微服务。你知道可能是什么问题吗?

kubernetes spring-cloud spring-cloud-gateway
1个回答
0
投票

解决方案:

spring:
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.