0

I'm literally going crazy about this problem, I'll try to provide as many info as I can.

I have a MySQL 8 container running in Docker which is accessible from my machine at the IP that Docker assigns to it, so something like 172.17.0.2, while using localhost gives the error below and this is already a strange issue. I have a Minikube 1.10 cluster running using Docker as driver (so Minikube is basically running as a container) and I want to connect to my MySQL container from a pod inside Minikube and, hopefully, expose MySQL as a service in order to use Kubernetes DNS.

After every solution I tried I always get this error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql:3306' (111)

I think I've read everything possible on the internet, I've tried everything said in these questions:

Minikube expose MySQL running on localhost as service

Connect to local database from inside minikube cluster

Like creating a service and an endpoint by hand and connecting the MySQL container to Minikube network but no luck till now.

Using a busybox I'm able to ping the container using the IP in the Minikube network but not using the service name as explained in the first link I wrote above.

Furthermore, I can confirm that MySQL has bind-address = * and the user is allow to connect remotely as shown here:

mysql> SELECT CURRENT_USER(), @@bind_address;
+----------------+----------------+
| CURRENT_USER() | @@bind_address |
+----------------+----------------+
| dbuser@%       | *              |
+----------------+----------------+

I think I gave all the possible info, if not let me know.
  • Can you run the database as a Kubernetes StatefulSet, instead of trying to cross from one container environment to another? – David Maze Apr 27 '22 at 17:04
  • @DavidMaze I'd prefer to avoid it in order to simulate a real environment where the DB is outside the cluster – Andreascopp Apr 27 '22 at 17:17

0 Answers0