Bertrand_Polus
Mission Specialist
Mission Specialist
  • 598 Views

DO180 How to connect to mysql using a route?

Jump to solution

In DO180, Chapter 6, Guided Exercice "Deploying a Database Server on OpenShift", we are creating a route to mysql service using the command "oc expose service mysql-openshift".

After that, we are using "oc port-forward" command and next, we connect to mysql server using localhost. (And it is working)

But if I try to connect directly to the route created above (with a command like "mysql -uuser1 -pmypa55 --protocol tcp -h ROUTE_URL") form the Workstation, it is not working. If I ping ROUTE_URL, it is working.

Why is it not possible to connect to mysql using the route? Is there something else that needs to be configured to be able to do it? (Like allowing port 3306 in some firewall configuration?)

Labels (2)
1 Solution

Accepted Solutions
arulz
Mission Specialist
Mission Specialist
  • 544 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

Routes support only a limited range of protocols: HTTP, HTTPS and websockets (in addition to TLS with SNI) and I'm not sure is possible to expose in any way mysql through routes

I think that in order to expose mysql out of the cluster you should use a load balancer service (not sure if it's possible in the labs) 

View solution in original post

Reply
Loading...
5 Replies
arulz
Mission Specialist
Mission Specialist
  • 545 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

Routes support only a limited range of protocols: HTTP, HTTPS and websockets (in addition to TLS with SNI) and I'm not sure is possible to expose in any way mysql through routes

I think that in order to expose mysql out of the cluster you should use a load balancer service (not sure if it's possible in the labs) 

View solution in original post

Reply
Loading...
ericbos
Flight Engineer
Flight Engineer
  • 311 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

The mysql database is not accessible through a web browser.

Normally you would have a frontend application talking to the mysql database, like for example the todo application or the Wordpress application.

0 Kudos
Reply
Loading...
Bertrand_Polus
Mission Specialist
Mission Specialist
  • 306 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

I was not trying to access the database from the web browser, but by using mysql client and using the URL of the route. (like what is done when using port forwarding)

But, as arulz replied above, route is likely not supporting the protocol used by mysql client.

0 Kudos
Reply
Loading...
MichaelShire
Mission Specialist
Mission Specialist
  • 299 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

You don't connect to a route for port-forwarding.  The oc cli creates a temporary "proxy" between your machine port and the pod.
oc port-forward <podname> -n <namespace> 3306:<remotePort>

Then on your local mysql client
mysql --host=localhost --user=myname --password mydb --port:3306

0 Kudos
Reply
Loading...
Bertrand_Polus
Mission Specialist
Mission Specialist
  • 295 Views

Re: DO180 How to connect to mysql using a route?

Jump to solution

As written in the original question, I understand that doing an "oc port-forward" and connecting to the localhost is working.

What my question was is "Why is it not possible to connect directly mysql using the URL of a route?" (and this question has already been replied above)

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.