我在不同的端口上配置了几个 spring boot 服务,带有 swagger UI,可以通过 URL 访问
http://SERVICE_A:31031/swagger-ui.html#/
http://SERVICE_B:31032/swagger-ui.html#/
http://SERVICE_C:31033/swagger-ui.html#/
所有 3 项服务中的 Swagger Docket 配置是
@Bean
public Docket api(){
return new Docket (DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.controller"))
.paths(PathSelectors.any())
.build();
}
我将我的应用程序迁移到 kubernetes 平台并使用以下入口配置来公开服务。所有 3 个服务中的所有 API 都可以正常工作,但无法通过入口访问 Swagger UI
http://SERVICE_A/api1/swagger-ui.html#/
http://SERVICE_B/api2/swagger-ui.html#/
http://SERVICE_C/api3/swagger-ui.html#/
我得到 Whitelabel Error Page。请建议。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: <NAME>
annotations:
kubernetes.io/ingress.class: alb
meta.helm.sh/release-name: <HOST_DNS>
meta.helm.sh/release-namespace: <NAMESPACE>
external-dns.alpha.kubernetes.io/hostname: <HOST_DNS>
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/healthcheck-path: <HEALTHCHEK-PATH>
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-timeout-seconds: "30"
alb.ingress.kubernetes.io/healthcheck-interval-seconds: "300"
alb.ingress.kubernetes.io/healthy-threshold-count: "2"
alb.ingress.kubernetes.io/unhealthy-threshold-count: "2"
alb.ingress.kubernetes.io/certificate-arn: <CERT_ARN>
alb.ingress.kubernetes.io/tags: "<TAGS>"
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
alb.ingress.kubernetes.io/load-balancer-attributes:
idle_timeout.timeout_seconds=60
spec:
rules:
- host: <HOST_DNS>
http:
paths:
- path: /api1
pathType: Prefix
serviceName: SERVICE_A
portNumber: 31031
- path: /api2
pathType: Prefix
serviceName: SERVICE_B
portNumber: 31032
- path: /api3
pathType: Prefix
serviceName: SERVICE_C
portNumber: 31033