Is there anything wrong with how I am trying to configure my Minikube cluster in a way the pods can access the PostgreSQL instance within the same machine?
I've access the /etc/hosts within the Minikube cluster via minikube ssh and returns:
127.0.0.1 localhost
127.0.1.1 minikube
192.168.99.1 host.minikube.internal
192.168.99.110 control-plane.minikube.internal
database-service.yaml
apiVersion: v1
kind: Service
metadata:
name: service-database
spec:
type: ExternalName
externalName: host.minikube.internal
ports:
- port: 5432
targetPort: 5432
pod-deployment.yaml
apiVersion: apps/v1
kind: Deployment
spec:
...
template:
...
spec:
containers:
- name: <container_alias>
image: <container_name>
env:
- name: DB_URL
value: "jdbc:postgresql://service-database/<database_name>"
ports:
- containerPort: 8080
Note: DB_URL environment variable points to the spring.datasource.url in the application.properties in SpringBoot.
Then when I tried to get the logs printed, I am getting this exception:
Caused by: java.net.UnknownHostException: service-database