Hello bosh users,
since two days I'm facing a connection problem when I try to deploy an application on a local cloudfoundry running on bosh-lite warden in virtualbox. I hope you guys can help me out.
Everything worked fine several times (tried different cf-releases, now I'm on the latest: cf-179), even the application deployment via the cloudfoundry cli works without problems except the connection to the database in a service.
My steps so far:
Successfully created an organisation and space via the cli (followed steps on the bosh-lite github readme).
Deployed the cf-contrib-release with the default manifest created by the template:
$ templates/make_manifest warden
$ bosh -n deploy
Then authenticated the cli:
$ cf create-service-auth-token postgresql core c1oudc0w
(I'm not sure if "core" is correct, but authentication works with this command anyway)
Created a new service:
$ cf create-service postgresql default my-datasource
and bound it to my application (java spring boot app btw):
$ cf bind-service my-application my-datasource
Everything returns OK and there is indeed created a new database on postgres_node/0 machine.
In the application I use the spring-cloudfoundry-connector to automatically receive the datasource.
When I connect to the loggregator stream of this app, I can see the logged datasource received in the app (so the environment variables seem to be set):
But the connection itself is refused everytime inside the application:
Unable to get connection:
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
When I do a manual connection via command line psql, I can login without any problems to the database given in this datasource from inside the host machine.
I found a good guide on how to connect to a warden container here and successfully connected via ssh to the warden instance where the application runs. There I cannot connect to postgres: Connection refused, like in the app itself.
So the service is actually somehow created and bound to the application (i got the right parameters as env-variables and even the datasource with the connector), I can connect to it manually from the host machine (the bosh-lite virtualbox), but inside the warden container connections are refused.
Because of the subnet of the default cf-services-contrib manifest for warden (10.244.1.x instead of 10.244.0.x) I even tried to change some service settings in the postgresql_node config. In the file:
cf-services-contrib-release/jobs/postgresql_node_ng/templates/postgresql_ctl.erb
I tried to allow connections from all hosts with:
echo "host all all 0.0.0.0/0 md5" >> $pg_hba_conf_file
instead of the other echos writing the postgresql connection settings.
But still no luck.
Could you guys give me a hint what I am missing? How does that service binding actually forward requests to and from the service, via the router_z1?
I got the impression that only one little step is missing or silently failing.
Any help or hint much appreciated!
If you need some more information about my setup just let me know.
Cheerz,
leo