How to connect a database to a backend in minicube?

10/8/2018

I want to start a minikube cluster with a data base and a java backend.

I have a persistent volume and the service for the mariadb database with the following persistent, claim and delpoyment

and the java backend with the deployment and service

in addition my java backend uses dropwizard and I specify the database address and all the credentials in a config.yml

logging:
  level: INFO
  loggers:
    DropwizardBackend.org: DEBUG
dataBase:
  driverClass: org.mariadb.jdbc.Driver
  user: <userName>
  password: <password>
  url: jdbc:mariadb://<database address>:<port>/<database Name>

Since my java backend needs to connect to the database to run at the moment I get a error message since the specified data base can not be found. I was wondering what the address of the database is? Do I have to specify it like the external IP of the java-deployment? How ever I prefer if only the backend is able to access the database.

-- A.Dumas
docker
kubernetes
minikube

1 Answer

10/8/2018

From your yaml it seems you have named the mariaDB service "maria" so the dns name for it should be just maria (if you are in the same namespace) or maria.<namespace> (from all other namespaces) or maria.<namespace>.svc.cluster.local as a FQDN.

-- Andreas Wederbrand
Source: StackOverflow