Multiple databases with Kubernetes

7/20/2018

We are trying to implement Kubernetes in our system and we have two mysql databases and two services.

One service should be able to connect to both databases and the other uses just one.

So auth-service->key-db and transaction-service->key-db + pdns-db.

I currently the databases running and both exposing port 3306 (default mysql) with hostname key-db and pdns-db. The auth-service is able to connect to the key-db fine. But when I try to start the transaction-service which connects to key-db:3306 and pdns-db:3306 it fails.

We don't want to expose the databases so we didn't gave them a Cluster IP. I'm pretty new to this stuff so I guess I'm missing something.

Thanks in advance.

Theo

-- Theo Bouwman
kubernetes

1 Answer

7/20/2018

You have to put a Service in front of any Pod that you want to connect to from anywhere, even within the cluster. If you declare it a ClusterIP type (the default) it will only be reachable from within the cluster. You have to explicitly set up the service as a NodePort or LoadBalancer type if you want it to be reachable from outside.

-- David Maze
Source: StackOverflow