我创建了一个简单的 Springboot 应用程序,它在我的 localhost 端口号 9091 上运行,它返回“Hello world!!!” 当 http://localhost:9091/helloWorld url 被调用时。
下面是我的Springboot主类和控制器类的代码片段
@SpringBootApplication
public class HelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run(HelloWorldApplication.class, args);
}
}
@RestController
public class HelloWorldController {
@GetMapping(value="/helloWorld")
public String helloWorld() {
return "Hello world!!!!";
}
}
以下是我的 pom.xml 中的依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.3</version>
</dependency>
我还可以使用以下 url http://localhost:9091/swagger-ui/index.html 访问我的 Springboot 项目的 swagger ui
我已使用以下 yaml 文件配置将此 Springboot 应用程序部署到我的 k8s 集群中
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: moviepopcorn/hello_world:0.0.1
ports:
- containerPort: 9091
imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
spec:
type: NodePort
selector:
app: hello-world
ports:
- port: 9091
targetPort: 9091
nodePort: 30001
我还可以使用以下 url <K8S_MASTER_NODE_IP>:<NODE_PORT (30001)> 访问 helloWorld 端点,如下所示
但是当我尝试使用以下 url http://192.168.254.94:30001/swagger-ui/index.html访问我的 Springboot 的 swagger-ui 时,我看到下面的 Whilelabel 错误页面
当我使用集群主节点 ip 访问我的 springboot 应用程序时,您能否帮助我了解导致此 Whitelabel 错误页面问题的原因?