Monday, November 23, 2015

CloudFoundry – Getting started


This article helps you getting started on cloudfoundry. This does not explain on the cloudfoundry concepts.

Step 1: Create an account in pivotal cloudfoundry. 
                You can create a 2 months free subscription account from pivotal cloudfoundry services web site https://run.pivotal.io. An organization as the name specifies – can be your company name, project group or so.
The space is nothing but the environment you wish to create, you may want to have a development, qa and production spaces. In short applications are hosted in spaces (environemnts) and spaces belongs to an organization.



Step 2: Create a simple spring application, you can also create in Grails, Ruby etc., You can use maven, gradle as the build tool.
                You can use spring boot to create a simple application. Please refer http://ndeiveehan.blogspot.com/2015/11/spring-boot-getting-started.html to create a new spring application.

You can also create in other languages as Cloudfoundry offers other buildpacks.
Once created, you can generate the war or jar using the maven command.

Step 3: Login to cloudfoundry and create required organization and spaces.
From you PC, login to cloudfoundry using the CLI tools.
cf login -a https://api.run.pivotal.io

Enter your credentials to login.



Step 4: Deploy your application.
You can push the apps in the following ways:
- Use the Cloudfoundry CLI tool.
- Use cloufdoundry eclipse plugin.
- Use a build plugin to integrate deployment as part of your build tool.
 but this article shows you how to push application using the CLI tool.

Now issue the following cf command.
cf push springbootfirst -p target/springbootfirst-0.0.1-SNAPSHOT.jar
               
 This command uploads the spring jar file to the cloudfoundry site and starts the server. 

Step 5: You can now access the web application in the following web url:




Now there is a lot more you can do using CF tool such as:
-          Configuring your own domain instead of cfapps.io.
  • Scale up an application.
  • Deleting an app, renaming it, start or stop an application.
  • View logs for an application
  • Enable ssh for an application.
  • View services from the market place.
  •  Create, update organizations, spaces, buildpacks etc.,
  •  Perform user administration on organizations / projects.



See you in the next article on cloudfoundry. 

No comments:

Post a Comment