I have external Oracle DB and service which is connected to it. I want to deploy this service in my service mesh ang ive it acces to this DB. Definition for this service loks like:
apiVersion: apps/v1
kind: Deployment
metadata:
name: database
namespace: milus-dev
labels:
app: database
spec:
replicas: 1
selector:
matchLabels:
app: database
template:
metadata:
labels:
app: database
version: blue
spec:
containers:
- name: database-blue
image: $IMAGE_VAR
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: "dev"
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 65
timeoutSeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 60
timeoutSeconds: 10
periodSeconds: 5
imagePullSecrets:
- name: gitlab-registry-secret
---
apiVersion: v1
kind: Service
metadata:
name: database
namespace: milus-dev
spec:
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
selector:
app: database
VirtualService:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: database
namespace: milus-dev
spec:
hosts:
- database-dev.lp-k8s-m2.milus.net
gateways:
- ingresgateway
http:
- route:
- destination:
host: database
port:
number: 8080
and ServiceEntry to connect to external DB:
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
name: milus-database
namespace: milus-dev
spec:
hosts:
- milus.tcp.svc
exportTo:
- "."
addresses:
- 14.10.104.100/32
ports:
- number: 1521
name: tcp
protocol: TCP
location: MESH_INTERNAL
resolution: STATIC
endpoints:
- address: 111.37.74.70
ports:
tcp: 1521
and when i try to use in application connection string:
jdbc:oracle:thin:@//14.10.104.100:1521/mt-services
service cannot connect to database. I’m getting
java.sql.SQLRecoverableException: IO Error: Connection reset by peer, connect lapse 3078 ms., Authentication lapse 0 ms.\n\tat oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:794)\n\tat oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)\n\tat oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)\n\tat oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)