Note: This guide uses the Cloud Foundry CLI version 5. The instructions below are not compatible with any cf version > 5. Click here to get a description of the differences between CLI v5 and CLI v6.
In case you need to access an anynines service directly from your local machine, anynines provides access using the cf tunnel command. You can use the tunnel to send queries to your databases or dump whole databases to your local machine. The cf tunnel command can be used to access the anynines services (MySQL, PostgreSQL, MongoDB, RabbitMQ, Redis) using a direct tunnel connection to your local development machine.
- Switch to the space that contains your desired service:
$> cf switch-space <space-name>
Execute the cf tunnel command followed by the instance name of your desired service:
$> cf tunnel <service-instance-name>(you can list the available services instances within a space using the cf services command)
- Choose the command to execute on the tunnel (client, dump or just tunneling (none option))
- You're now able to access the service's data from your local machine
"none" option usage
- The "none" option opens a tunnel connection to the remote database mapped to your localhost on port 10000
- The credentials will be displayed as follows:
Opening tunnel on port 10000... OK
Service connection info:
username : <username>
password : <password>
name : <database name>
uri : mysql://<username>:<password>@10.12.0.6:3307/<database name>
You can access the service by setting your client's parameters to the displayed information
- e.g: PostgreSQL dump:
$> pg_dump --no-owner --no-acl -p 10000 -h localhost -U <username> -W <database name> > dump_file.sql
- e.g.: MySQL client:
$> mysql -h 127.0.0.1 -P 10000 -D <database name> -u <username> -p<password>
If you retrieve a RuntimeError: Remote tunnel helper is unaware of <instance-name> please re-execute the cf tunnel command. If this is not working either please remove the caldecott tunnel application by executing cf delete caldecott (caldecott is used for generating tunnels into the anynines PaaS system). Re-execute cf tunnel <service-instance-name> after deleting the caldecott app.
- cf tunnel command documentation: http://docs.cloudfoundry.com/docs/using/managing-apps/cf/index.html#tunnel
Please sign in to leave a comment.