Henry
Henry

Reputation: 777

Remotely connect to openshift database

I am trying to remotely connect to my Openshift v3 mysql database. As far as my understanding goes this is not possible without proper configuration as services are not natively reachable from the outside.

I tried port forwarding, which gives me the following error (german reason translates to missing socket access privileges):

oc port-forward mysql-database-1-rqhc8 3306:3306
E1001 09:34:33.103656    2936 portforward.go:202] Unable to create listener: Error listen tcp4 127.0.0.1:3306: bind: Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulässig.
E1001 09:34:33.127445    2936 portforward.go:202] Unable to create listener: Error listen tcp6 [::1]:3306: bind: Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulässig.
W1001 09:34:33.141973    2936 portforward.go:154] Unable to listen on port 3306: All listeners failed to create with the following errors: listen tcp4 127.0.0.1:3306: bind: Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulässig., listen tcp6 [::1]:3306: bind: Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulässig.
error: Unable to listen on any of the requested ports: [{3306 3306}]

Port forwarding to a free port works fine:

oc port-forward mysql-database-1-rqhc8 :3306
I1001 09:35:02.760192    7792 portforward.go:213] Forwarding from 127.0.0.1:51231 -> 3306
I1001 09:35:02.775740    7792 portforward.go:213] Forwarding from [::1]:51231 -> 3306

Still, I cannot connect to the assigned port. Which address would I have to target?

These urls do not work:

jdbc:mysql://<<my-domain.com>>:51231/maindatabase
jdbc:mysql://<<service-cluster-ip-address>>:51231/maindatabase

Upvotes: 1

Views: 980

Answers (1)

Henry
Henry

Reputation: 777

Well, I just found out (accidentally) that oc actually forwards the port to your own local machine.

This is exactly what was said in the documentation, which I just could not believe it would actually do.

So for everyone doing the same stupid mistake, just connect to:

jdbc:mysql://localhost:<<port>>/<<database-name>>

Upvotes: 4

Related Questions