Sean's i/o Stream

Musings-as-a-Service

Joining a development team using Bluemix

  • February 02, 2015
  •   category: ibm
  • tags: ibm, bluemix, development

Getting started and joining an app being developed on Bluemix and DevOps Services.

Install your pre-requisites

  • Rational Team Concert (Optional for this if you are using git )
  • Git ( if using Git instead of Jazz SCM )
  • Cloud Foundry Command Line

Get our development environment ready, if you are using JazzSCM this is taking care of for you, if you are using Git you will want to match your configuration global or local to what you have registered on DevOps Services. In this example I am on Windows working in the Git Bash Shell that gets installed by the git installer.

Now to develop in parallel with some isolation on the version control side for testing or a feature spyke you may want to use you own space to isolate where you are deploying to as well. May be you are just getting started and you would like to be able to make some throw away changes and see them in action, or try some wide sweeping changes that will break other developers in progress work if you do it in the shared area. In any case, we will create a new space for this example, create any applications we need, services we are using, and bind them together. In this example we will look at an existing instance of a simple Node.js and Cloudant DB application and use that to create a new space for our independent testing. In a real application, it is helpful to understand the complete application context so you don’t end up trampling over a shared service that may not be explicitly hosted in Bluemix, again for our simple example of one app and one service this is not the case but keep this in mind if you are trying to create a fully isolated environment.

First we get the existing application files from git, in our case this is a single repository, and using a pretty standard git workflow we create a new branch for our work so we can make changes, commit, and push in isolation without necessaryily affecting the whole team.

swilbur@SWILBUR ~/workspaces
$ git config --global --list

Ok one additional word to the wise for those of us that are already members of jazz.net, the login and password provided below is actually a little goofy. The user id is your jazz.net id, while the password is actually your IBM ID password, see support post on forums. If you don’t get a prompt for a username and password and you been using github or another git services with different credentials you may have a credentialhelper turned on and it is providing a username and password for you, check out this stackoverflow for some tips and if you don’t already have it on and get sick of typing the user/pass each time you can activate the credential helper for you operating system here is a tip from github just select your os from the top set of links to get customized instructions for setup.

swilbur@SWILBUR ~/workspaces
$ git clone https://hub.jazz.net/git/swilbur/harbinger
Cloning into 'harbinger'...
Username for 'https://hub.jazz.net': swilbur
Password for 'https://swilbur@hub.jazz.net':
Rremote: Total 223 (delta 0), reused 223 (delta 0)
Receiving objects: 100% (223/223), 200.86 KiB | 0 bytes/s, done.
Resolving deltas: 100% (91/91), done.
Checking connectivity... done.

swilbur@SWILBUR ~/workspaces
$ cd harbinger

swilbur@SWILBUR ~/workspaces/harbinger (master)
$ git config --local --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://hub.jazz.net/git/swilbur/harbinger
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

Now create your own branch for development, personal preference on how your team deals with merging, pull requests, and code reviews. Here for simplicity and sharable isolated streams of work this branch style workflow is useful.

swilbur@SWILBUR ~/workspaces/harbinger (master)
$ git checkout -b swilbur_spyke

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ git status

With our new git branch for testing, we can create the Bluemix space, app, and service we need to get started. Let’s login to the CloudFoundry command line and poke around ( you can also do this through the Bluemix web console, but not all commands and options are available there).

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf api https://api.ng.bluemix.net
Setting api endpoint to https://api.ng.bluemix.net...
OK


API endpoint:   https://api.ng.bluemix.net (API version: 2.14.0)
Not logged in. Use 'cf.exe login' to log in.

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf login -u swilbur@us.ibm.com -o 'dtoczala@us.ibm.com' -s 'IBM Production'
API endpoint: https://api.ng.bluemix.net

Password>
Authenticating...
OK

Targeted org dtoczala@us.ibm.com

Targeted space IBM Production



API endpoint:   https://api.ng.bluemix.net (API version: 2.14.0)
User:           swilbur@us.ibm.com
Org:            dtoczala@us.ibm.com
Space:          IBM Production

Once we are logged in we can checkout what is going on already in th existing spaces, we login to CF and we can inspect the existing organization, spaces, services, and users in our application. The only thing you need to get starting is the appropriate api url, all other commands will prompt you for information about your current connection. Here is a quick list of some helpful commands for looking around, consult the actual CLI doc for a complete list and further explanation. There is basically a get object command and an inspect object command for the major types in CloudFoundry.

See what organizations you have access to:

$ cf orgs

Inspect a specific Organization:

$ cf org <org_name>

Set your current org:

$ cf target -o <org_name>

View all spaces within the current org:

$ cf spaces

Inspect a specific Space:

$ cf space <space_name>

Set your current space:

$ cf target -s <space_name>

Now you can see what is deployed to that space by using the commands for apps and services

$ cf apps
$ cf app <app_name>
$ cf services
$ cf service <service_name>

Once you know where you are going, you can streamline the process by combining it into a single command, like I did when first logging in.

$ cf login -u <username> -o  <org_name> -s <space_name>

Back to some real examples, we are logged in to our cf server

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf apps
Getting apps in org Unleash the Labs / space prototype as swilbur@us.ibm.com...
OK

name              requested state   instances   memory   disk   urls
unleashthecloud   started           1/1         128M     256M   unleashthecloud.mybluemix.net

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf app unleashthecloud
Showing health and status for app unleashthecloud in org Unleash the Labs / space prototype as swilbur@us.ibm.com...
OK

requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: unleashthecloud.mybluemix.net
last uploaded: Fri Jan 30 17:08:48 +0000 2015

     state     since                    cpu    memory          disk
#0   running   2015-01-30 11:09:24 AM   0.0%   73.8M of 128M   45.4M of 256M

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf services
Getting services in org Unleash the Labs / space prototype as swilbur@us.ibm.com...
OK

name                   service           plan     bound apps
Cloudant NoSQL DB-9z   cloudantNoSQLDB   Shared   unleashthecloud

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf service 'Cloudant NoSQL DB-9z'

Service instance: Cloudant NoSQL DB-9z
Service: cloudantNoSQLDB
Plan: Shared
Description: Cloudant NoSQL DB provides access to a fully managed NoSQL JSON data layer that's always on. This service is compatible with Co
uchDB, and accessible through a simple to use HTTP interface for mobile and web application models
Documentation url:
Dashboard: https://cloudantbroker.stage1.ng.bluemix.net/dashboard/27e5ecfc-2d68-4926-bbfc-885c4314b35b

So that gives us enough information to setup our own space to try test it out, you can go ahead and do the setup in the web ui by browsing and clicking around, I’ll just show the simple example of how to do this via the command line here.

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf create-space swilbur_spyke
Creating space swilbur_spyke in org Unleash the Labs as swilbur@us.ibm.com...
OK
Assigning role SpaceManager to user swilbur@us.ibm.com in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK
Assigning role SpaceDeveloper to user swilbur@us.ibm.com in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

TIP: Use 'cf.exe target -o Unleash the Labs -s swilbur_spyke' to target new space

 swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf target -s swilbur_spyke

API endpoint:   https://api.stage1.ng.bluemix.net (API version: 2.19.0)
User:           swilbur@us.ibm.com
Org:            Unleash the Labs
Space:          swilbur_spyke

Now we have a space to work with, we need to create a Cloudant service and upload our app to create it, most of the commands have a helpful error message if you just try running them when you don’t know the options. In this case I use the information from the working command above to fill in the service type and `plan’ information.

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf create-service
FAILED
Incorrect Usage.

NAME:
   create-service - Create a service instance

ALIAS:
   cs

USAGE:
   cf.exe create-service SERVICE PLAN SERVICE_INSTANCE

EXAMPLE:
   cf.exe create-service cleardb spark clear-db-mine

TIP:
   Use 'cf.exe create-user-provided-service' to make user-provided services available to cf apps


swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf create-service cloudantNoSQLDB Shared spyke_cloudant
Creating service spyke_cloudant in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

Attention: The plan `Shared` of service `cloudantNoSQLDB` is not free.  The instance `spyke_cloudant` will incur a cost.  Contact your admin
istrator if you think this is in error.

$ cf services
Getting services in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

name             service           plan     bound apps
spyke_cloudant   cloudantNoSQLDB   Shared

This is a simple app, so it only has one service and no external dependencies and we are ready to put the application into the space. So one additional change we need to make is to update the application name in the manifest.yml so the default generated route will not collide with an application already deployed with this name. I just made a quick change to update my applicationname from

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ git diff manifest.yml
diff --git a/manifest.yml b/manifest.yml
index 84fdda8..2f3e335 100644
--- a/manifest.yml
+++ b/manifest.yml
@@ -1,7 +1,7 @@
 applications:
 - disk_quota: 256M
-  host: unleashthecloud
-  name: unleashthecloud
+  host: unleashthecloud-spyke
+  name: unleashthecloud-spyke
   command: node app.js
   path: .
   domain: mybluemix.net
warning: LF will be replaced by CRLF in manifest.yml.
The file will have its original line endings in your working directory.

Now we are ready to push the application into the new space and have the application created and started.

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf push
Using manifest file c:\Users\swilbur\workspaces\harbinger\manifest.yml

Creating app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

Creating route unleashthecloud-spyke.mybluemix.net...
OK

Binding unleashthecloud-spyke.mybluemix.net to unleashthecloud-spyke...
OK

Uploading unleashthecloud-spyke...
Uploading app files from: c:\Users\swilbur\workspaces\harbinger
Uploading 93K, 25 files
Done uploading
OK

Starting app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
^Ctrl-C

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf stop unleashthecloud-spyke
Stopping app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

Whoops, I forgot to bind the App to the Cloudant db, so when it trys to run it fails without the database being available. So we need to bind the service to the app to fix this up:

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf bind-service unleashthecloud-spyke spyke_cloudant
Binding service spyke_cloudant to app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK
TIP: Use 'cf.exe restage' to ensure your env variable changes take effect

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf restage unleashthecloud-spyke
Restaging app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...

1 of 1 instances running

App started


OK

App unleashthecloud-spyke was started using this command `node app.js`

Showing health and status for app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: unleashthecloud-spyke.mybluemix.net
last uploaded: Fri Jan 30 20:38:14 +0000 2015

     state     since                    cpu    memory          disk
#0   running   2015-01-30 02:47:04 PM   0.0%   43.9M of 128M   44.7M of 256M

swilbur@SWILBUR ~/workspaces/harbinger (swilbur_spyke)
$ cf app unleashthecloud-spyke
Showing health and status for app unleashthecloud-spyke in org Unleash the Labs / space swilbur_spyke as swilbur@us.ibm.com...
OK

requested state: started
instances: 1/1
usage: 128M x 1 instances
urls: unleashthecloud-spyke.mybluemix.net
last uploaded: Fri Jan 30 20:38:14 +0000 2015

     state     since                    cpu    memory          disk
#0   running   2015-01-30 02:47:04 PM   0.0%   43.9M of 128M   44.7M of 256M

Checkout what just got posted and confirm it looks legit, then you can continue making changes locally and doing your normal cf push to push new changes to the server, and git workflows to share version control. I’ll go deeper into the DevOps Delivery Pipeline service in the future on how to streamline these workflows together once you get sick of typing them everytime!

Reference:
Back to Top