I'm setting up a MySQL service on an Openshift container, but I can't access it from the rest of the services.
According to the documentation (https://docs.openshift.com/online/dev_guide/environment_variables.html#automatically-added-environment-variables), when a service is created, the X_SERVICE_HOST
and X__SERVICE_PORT
environment vbles are populated to the rest of the services, but I can't seem to be able to access them from my Java service (using the ${MYSQL_SERVICE_HOST}
placeholder on a .properties
file).
Previously I had been able to connect to a MySQL db using the Cluster IP
value on the service definition, but it doesn't work either, I have tried to import the mysql secret on my Java service, which is supposed to import the env variables such as username, pwd, etc. but it doesn't import the hostname and port.
As stated in this thread (https://github.com/openshift/origin/issues/10401) I have tried to create a MySQL service named MYSQL
, but it fails due to the upper casing.
How should I propagate the env vbles to other services?
Thank you.
Edit: The issue was finally solved, the MySQL URL connection format was wrong, and it contained an extra /
somewhere, after I fixed that the vbles propagated correctly.