Lorna’s Bluemix Cheatsheet

I work for IBM which means I get to play with Bluemix, their cloud platform. I use this mostly from the commandline as the tools are great and I find it the easiest way to work – but I keep having to look up the commands I need so here’s my cheatsheet covering the stuff I use the most. It’s here for me to refer to easily but if it’s helpful to you too, then great!

EDIT November 2017 There’s now a bluemix or bx CLI tool that covers more of IBM Cloud, so there’s a post about that too.

(Note that everything here should work for more or less any Cloud Foundry installation)

Getting Set Up

To get started, you’ll need to install the cf Cloud Foundry CLI tool. Verify it works using cf -v – if this runs and shows you a version number, you’re all set.

Regions

Bluemix regions can be confusing at first, essentially you need to say which Bluemix you want to talk to; the public cloud has regions but it also comes as a dedicated offering or can be in your own data centre so it’s important to specify which of those the tools should communicate with.

To this end, we set the API endpoint in the tool.

cf api https://api.ng.bluemix.net

This connects you to the US South region, your other options are:

  • UK: https://api.eu-gb.bluemix.net
  • Sydney: https://api.au-syd.bluemix.net

If you want to change regions, then you will need to cf logout, change the API and then login again.

Logging In and Targeting a Space

The command for logging in is: cf login. You can pass the parameters on the commandline or just let the tool prompt you for your username, password, organisation and which “space” to use (the space is optional, you can create and switch spaces after you are logged in).

To check where the tool is currently pointing to (it’s a system-wide setting so you may need to change it when you switch between projects) or to change the organisation or space you use:

cf target // shows your current target
cf orgs // lists the orgs in this region that you are part of
cf spaces // lists spaces in the current org
cf target -o [organisation] -s [space]

Setting up Services and Apps

This terminology can be confusing, but essentially a service is something you rely on, and an app is something you deploy. So for my most recent project, I created services for a Cloudant database and the RabbitMQ message broker I needed, then deployed my app.

To discover services, use the cf marketplace command but be prepared to wait a while because there’s plenty of services and it takes time to get the response! If you know which service you want and are looking for which plan you want, use cf marketplace -s [service] which will load much more quickly as it does much less work!

Once you know what you need cf create-service is the command you want: use cf help create-service for more details on that.

The apps are interesting, in that usually you create them by deploying (for this, use a manifest file, docs are here). You can however do plenty of very useful things with them!

cf apps // list the apps in this space
cf env [app] // show the environment config for this app
cf logs [app] // tail the logs for an app (use --recent to get the last few lines)
cf push // pushes the app following the instructions in manifest.yml
cf stop [app] // stops the app from running

Using these tools, I found the move to cloud to be quite painless and at times easier than wrestling server logins! Which commands did I miss? Add a comment and I’ll endeavour to update the post to keep everything in one place!

One thought on “Lorna’s Bluemix Cheatsheet

  1. Pingback: Login and Switch Spaces With Bluemix CLI | LornaJane

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.