Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Lorna's Bluemix Cheatsheet

DZone's Guide to

Lorna's Bluemix Cheatsheet

This nice cheatsheet for using IBM Bluemix or Cloudfoundry covers many helpful command line options for working with applications and their cloud hosting.

· Cloud Zone
Free Resource

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

I work for IBM, which means I get to play with Bluemix, their cloud platform. I use this mostly from the command line, 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!

(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 cfC 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 center, 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 command line or just let the tool prompt you for your username, password, organization, 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 organization 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 are plenty of services and it takes time to get a 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 endeavor to update the post to keep everything in one place!

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:
paas ,cloudfoundry ,bluemix ,cloud ,tutorial

Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}