I deployed Wildfly application and MySQL persistent on Openshift web console and tried to connect MySQL persistent with jdbc driver of Eclipse outside. However I can not find the public IP address at all on web console.
How can I find public IP address of MySQL persistent or how to configure the specific IP address into MySQL persistent? I attach an image of both services on Openshift.
[
UPDATED
On Eclipse IDE, I opened the log part of MySQL pod. And I found the IP addresses of MySQL service:
"readinessProbe" : {
"exec" : {"command" : [
"/bin/sh",
"-i",
"-c",
"MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"
]},
"initialDelaySeconds" : 5,
"timeoutSeconds" : 1,
"periodSeconds" : 10,
"successThreshold" : 1,
"failureThreshold" : 3
},
....
"phase" : "Running",
"conditions" : [
{
"type" : "Initialized",
"status" : "True",
"lastTransitionTime" : "2017-04-02T06:35:00Z"
},
{
"type" : "Ready",
"status" : "True",
"lastTransitionTime" : "2017-04-03T16:47:27Z"
},
{
"type" : "PodScheduled",
"status" : "True",
"lastTransitionTime" : "2017-04-02T06:35:00Z"
}
],
"hostIP" : "172.31.14.159",
"podIP" : "10.1.72.72",
"startTime" : "2017-04-02T06:35:00Z",
"containerStatuses" : [{
"name" : "mysql",
"state" : {"running" : {"startedAt" : "2017-04-03T16:47:07Z"}},
"lastState" : {"terminated" : {
"exitCode" : 255,
"reason" : "Error",
"startedAt" : "2017-04-02T06:36:28Z",
....
I tried to connect MySQL pod with the hostIP, 172.31.14.159 or podIP, 10.1.72.72. But connection failed. And then I found the following MySQL generation commands in the log contents:
"exec" : {"command" : [
"/bin/sh",
"-i",
"-c",
"MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"
]},
So, I tried to connect the mysql database service with the ip 127.0.0.1. And the connection was SUCCESSFUL.
Now I am confused what this 127.0.0.1 address is, my local PC or MySQL pod of Openshift container. How can I generate MySQL persistent with the HostIP, not with 127.0.0.1? I am afraid I missed the some procedure.
Your mysql pod havn't a public ip address, but you can use port forwarding.
With Eclipse:
How-To: https://blog.openshift.com/getting-started-eclipse-jboss-tools-openshift-online-3/
Download: http://marketplace.eclipse.org/content/jboss-tools-luna
With Openshift CLI:
$ oc port-forward <pod> [<local_port>:]<remote_port> [...[<local_port_n>:]<remote_port_n>]
such as
$ oc port-forward <pod> 3306:5000
Now you can connect the URL jdbc:mysql://127.0.0.1:5000/database. The mysql pod listen to on your local port 5000.
https://docs.openshift.com/container-platform/3.3/dev_guide/port_forwarding.html