gpt4 book ai didi

oracle - 如何从Kubernetes连接到外部Oracle数据库?

转载 作者:行者123 更新时间:2023-12-02 12:15:17 26 4
gpt4 key购买 nike

我正在使用kubernetes设置新服务器以运行Spring Boot微服务。我如何将Spring Boot App连接到外部Oracle数据库? (数据库ip为170.27.10.10:1521)

Kube Master的IP:170.16.163.10
Kube Node的IP:170.16.163.11
Kube Node可以连接到服务器数据库。

我通过命令创建部署:

kubectl run db-deployment --image 170.16.163.30:5000/mcrdb:0.0.4 --replicas=2 --port=8083
kubectl expose deployment db-deployment --type=LoadBalancer --port=8083 --target-port=8083

并创建服务:
kind: "Service"
apiVersion: "v1"
metadata:
name: "dbdev"
spec:
ports:
-
name: "oracle-db"
protocol: "TCP"
port: 1521
targetPort: 1521
nodePort: 0


kind: Endpoints
apiVersion: v1
metadata:
name: dbdev
subsets:
- addresses:
- ip: 170.27.10.10
ports:
- port: 1521

并在application.properties中配置db
spring.datasource.url=jdbc:oracle:thin:@170.27.10.10:1521/vservice
spring.datasource.username=dev_user
spring.datasource.password=dev_pass

微服务无法启动并错误连接到oracle db。

最佳答案

您可以尝试以下更改吗

kind: Service
apiVersion: v1
metadata:
name: dbdev
spec:
ports:
-
name: oracle-db
protocol: TCP
port: 1521
targetPort: 1521


kind: Endpoints
apiVersion: v1
metadata:
name: dbdev
subsets:
- addresses:
- ip: 170.27.10.10
ports:
- port: 1521

application.properties
------------------------
spring.datasource.url=jdbc:oracle:thin:@dbdev:1521/vservice
spring.datasource.username=dev_user
spring.datasource.password=dev_pass

关于oracle - 如何从Kubernetes连接到外部Oracle数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57471943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com