Tuesday, May 20, 2014

Quick learn Cloud Foundry command line Tool

In the previous post,I referred the cf tools.This command line interface, or CLI, allows users to do almost everything necessary to deploy apps to Cloud Foundry, bind services to them, look at log files, and so on. If you are a beginner ,I suggest  you download the latest release version 6 and install it and  have a try.
(1) git clone https://github.com/cloudfoundry/cli
(2) git checkout v6.0.0
(3) run bin/build
(4)the binary build will be  be built into the the out/cf

Also you can directly download the release version  package based on your OS  from below url .

Below are some useful commands.
1. cf login

cf login -a https://api.ng.bluemix.net

It will prompt you to enter the email and password to login into the CloudFoundry.Upon successful login, cf v6 saves a config.json file containing your API endpoint, organization, space values, and access token.

2.cf push

cf push APP [-b URL] [-c COMMAND] [-d DOMAIN] [-i NUM_INSTANCES] [-m MEMORY] [-n HOST] [-p PATH] [-s STACK] [--no-hostname] [--no-route] [--no-start]

Here I suggest you to use the manifests.yml to do the automate deployment. Application manifests tell cf push what to do with applications. This includes everything from how many instances to create and how much memory to allocate to what services applications should use.The detail you can reference the below link.You can learn more detail from http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html

3. cf apps

Check on the health of the app you pushed

4.cf logs XXX --recently

List the specified app logs dump

5. cf service
List all the services you have created

6. cf create-service
You can create a managed service instance with the command: cf create-service SERVICE PLAN SERVICE_INSTANCE
cf create-service takes the following required arguments:
  • SERVICE: The service you choose.
  • PLAN: Service plans are a way for providers to offer varying levels of resources or features for the same service.
  • SERVICE_INSTANCE: A name you provide for your service instance. This is an alias for the instance which is meaningful to you. Use any series of alpha-numeric characters, hyphens (-), and underscores (_). You can rename the instance at any time.
Following this step, your managed service instance is provisioned:

$ cf create-service rabbitmq small-plan my_rabbitmq

Notes: SERVICE,PLAN you get from cf marketplace command

7.cf bind-service
You can bind a service to an application with the command cf bind-service APPLICATION SERVICE_INSTANCE. Example:

$ cf bind-service my_app example_service

8.cf files XXX logs/env.log

XXX stands for your app
show the specified app  detail logs.Sometimes it is useful to check the log through the command.

8.cf marketplace

List all the support service and plans in this platform

9. cf files XXX

List deployed app file structure. You can even use like cf files MyNodeSample app/ to list the detail folder content.

There is help inside the CLI using cf help, which prints out the list of commands and a quick summary of each. You can also get additional help for a particular command using cf help <command>

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Online Training from India . or learn thru JavaScript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training