I recently read about blog post by Takeshi Morikawa on Chisel ( https://github.com/morikat/chisel ). Chisel was originally developed by Jaime Pillora (https://github.com/jpillora). This software brings TCP tunnel over HTTP. Morikawa-san’s idea is to use this software to access back-end services on Cloud Foundry base PaaS, such as Cloudn or IBM Bluemix . Some of Cloud Foundry users may remember that there was “tunneling feature (vmc tunnel)” in Cloud Foundry V1. This allowed to connect to back-end services such as mysql, postgresql from client command line. Unfortunately, this feature was gone in Cloud Foundry V2.
Morikawa-san found out a way of similar functionality to us. “Connect to Service(PostgreSQL & MySQL) on Cloudn PaaS v2(CloudFoundry)” (written in Japanese) . This is excerpt of Morikawa-san’s blog on how to use Chisel for Cloud Foundry base PaaS. This example used “mysql” service available on Bluemix, but should be able to provide access to any services. I have to modify some of the sample code to be able to run Chisel, especially Go dependency did not work well on Bluemix, so I have worked around via old .godir method. Here is a procedure to deploy chisel application.
$ cf create-service mysql 100 amnt-mysql # Create mysql service $ git clone https://github.com/morikat/chisel # Clone Chisel application source code $ cd chisel $ mv Godeps /tmp $ echo "github.com/morikat/chisel" > .godir $ cf push --no-start amnt-chisel # no-start to bind service later $ cf bind-service amnt-chisel amnt-mysql $ cd start amnt-chisel
To make is easy to verify the chisel application, I have also deployed phpMyAdmin application so that I can create table from the GUI as a reference.
$ git clone https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin $ cd cf-ex-phpmyadmin $ mv manifest.yml manifest.yml-original $ cf push --no-start -m 256M -b https://github.com/cloudfoundry/php-buildpack.git amnt-phpmyadmin $ cf push --no-start -m 256M amnt-phpmyadmin $ cf bind-service amnt-phpmyadmin amnt-mysql $ cf start amnt-phpmyadmin
I have created SAMPLE table shown in the attached screenshot. Please refer to the result of “SELECT * FROM SAMPLE” in the bottom of the screenshot. It has FRISTNAME, LASTNAME and EMAIL.
Connect to mysql service via “Chisel” application
A shell script called “caldecott.sh” is provided to access to the service as a sample. I needed to supply application GUID (because I’m running go version of Cloud Foundry CLI). I have modified caldecott.sh to supply my application GUID in “APP_GUID” environmental variable in the caldecott.sh. Now, I run the command.
Connect to mysql service via “Chisel” application. The application name is provided as an argument to “caldecott.sh” script.
$ ./bin/caldecott.sh amnt-chisel 2015/04/07 17:34:36 client: Connecting to ws://amnt-chisel.mybluemix.net:80 mysql >
Now, I see “mysql” prompt here. I queried the table which I created at phpMyAdmin application.
mysql> select * from SAMPLE;
| ID | FIRSTNAME | LASTNAME | EMAIL |
| 12345 | Takehiko | Amano | email@example.com |
1 row in set (0.44 sec)
I was able to query the mysql services on Bluemix from my local client now !