<p>I'm setting up a new server using kubernetes to run Spring boot microservice. How do i get Spring boot app connected to external oracle database? (Database ip is 170.27.10.10:1521)</p>

<p>Kube Master's IP: 170.16.163.10
Kube Node's IP: 170.16.163.11
Kube Node can connect to server db.</p>

<p>I create deployment by command: </p>

<pre><code>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
</code></pre>

<p>And create service:</p>

<pre><code>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
</code></pre>

<p>And config db in application.properties</p>

<pre><code>spring.datasource.url=jdbc:oracle:thin:@170.27.10.10:1521/vservice
spring.datasource.username=dev_user
spring.datasource.password=dev_pass
</code></pre>

<p>Microservice can not started with error connect to oracle db.</p>

<p>can you try below changes</p>

<pre><code>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
</code></pre>
