Working with routes from the IBM Bluemix CLI

Today I played with routes on IBM Bluemix. Routes are how you access the app on IBM Bluemix so basically they are hostnames mapped to apps. By default apps are assigned a hostname under but once you’ve proved a domain belongs to you you may also may custom domain names to your apps. Of course you still need to create a CNAME record in DNS to make it map correctly but you get the point. Working with routes is possible from the GUI but the command line interface (CLI) is more efficient. Below are the commands I use to work with routes. All of the commands assumes you’re already logged in… Actual commands in bold.

Listing the routes (as you can see some routes are not bound to apps): cf routes

Getting routes as lekkim ...

space   host                                                domain            apps
dev     ontime-ibm-connected-2015-verse-demo-contribution     IBM ConnectED 2015 Verse Demo Contribution
dev     otgc-verse                                     IBM ConnectED 2015 Verse Demo Contribution
dev     mikkel-otgcms-test                             Mikkel OTGCMS Test
dev     mikkel-otgcms-test                           Mikkel OTGCMS Test
dev     neodashboard-oauth                             neodashboard-oauth
dev     spring-boot-demo-mikkel                        Spring-Boot-Demo-Mikkel
dev     engageugdemo                                   engageugdemo
dev     engagedemoapp1                            
dev     engagementdemo1                           
dev     engageugdemoapp                           

Map a route called to the engageugdemo app: cf map-route engageugdemo -n myapp

Creating route for org lekkim / space dev as lekkim...

Unmap a route called from the engageugdemo app: cf unmap-route engageugdemo -n myapp

Removing route from app engageugdemo in org lekkim / space dev as lekkim...

Permently delete the route from your account: cf delete-route -n myapp

Deleting route

PaaS, Bluemix and controlling runtime costs with cron

Back at IBM ConnectED 2015 I created a small demo for IBM using the yet-to-be-released extensibility API of IBM Verse to show of third party extension of IBM Verse. Ever since IBM has been using the demo which is great. The app I wrote is running on Bluemix and I turn it on and off whenever they need it. Now with Bluemix being a Platform As A Service (PaaS) offering I pay for the resource I use and since IBM is still to own up and provider partners with a free plan or larger allowance the monthly allowance of free gigabyte hours is cherished. Simply having it run day in and day out is burning up this free allowance. What is a geek to do? Script it of couse…

Since Bluemix is controllable using the cf command line tool I wrote a small script to allow me to start and stop the app on Bluemix using a script (see below). Invoking it is as simple as doing “ start” or “ stop” allowing me to do this remotely.

cf login -a -u {username} -p {password}
cf $1 "IBM ConnectED 2015 Verse Demo Contribution"

Even better is that I’ve added it to an existing on-prem servers crontab so that it starts and stops on business days in the period of time I need it. The cronjob even attaches the log of the start/stop and forwards it to our scheduled job management console so I’m only notified if stuff goes wrong. Love it. Below is a sample crontab entry.

0 12 * 9-11 1-5 ~/ start 2>&1 > ~/versedemo.log && mail -s "Verse Demo App Started"
     -a ~/versedemo.log ***XXX***

The above job simply starts the app Mon-Fri at 12pm (Sept-Nov) and then emails the job logs to our Job Controller service as an attachment.