Working with Pivotal Cloud Foundry Web Services with a free Account

To Start working on Pivotal Cloud Foundry PAAS Platform first create a free account on pivotal.io and get a trial account.

After registration login with the following URL to the public PAAS environment and create an ORG for your account.

Pivotal WS account

https://login.run.pivotal.io/login

Next download the cf command line tool from the following URL

https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github

Unzip the installer and double click on the installer named cf_installer.exe

After installing the cf CLI execute the command cf -v to see if the cf command works fine or not.

CF instalation

D:\CloudFoundryDev\cf-sample-app-spring>cf -v
cf version 6.38.0+7ddf0aadd.2018-08-07

To test an application you need to either programm your own application or you can download or clone an application from github

To clone an application from github you ll need git tool ,so install git on your desktop or laptop

Clone the code repository to your local folder

D:\CloudFoundryDev>git clone https://github.com/cloudfoundry-samples/cf-sample-app-spring.git

D:\CloudFoundryDev>cd cf-sample-app-spring

D:\CloudFoundryDev\cf-sample-app-spring>cf login -a https://api.run.pivotal.io

Provide the username and password for your pivotal trial account.

cf-login-public paas

After login execute the command

D:\CloudFoundryDev\cf-sample-app-spring>cf push

This will push the application to the cloud foundry PASS platform

I ll give a small explanation of what happens when you execute the command cf push

push sequence

1.User execute cf push on CLI

2.Cf CLI tells the cloud controller to create a record for the application.

3.Cloud controller stores application metadata

4.Before uploading all the application source files, the cf CLI issues a resource match request to the cloud controller to determine if any of the application files already exist in the resource cache.

5.The cloud controller stores the application package in the blobstore.

6.The cf cli issues an app start command.

7.The cloud controller issues a staging request to diego, which then schedules a diego cell(“cell”) to run the staging task (“task”)

8.The cell streams the output of the staging process so the developer can troubleshoot application staging problems.

9.The task packages the resulting compiled and staged application into a tarball called a “droplet” and the cell stores the droplet in the blobstore.

10.The diego bulletin board system reports to the cloud controller that staging is complete.

11.Diego schedules the application as a long running process on one or more diego cells.

12.The diego cells report the status of the application to the cloud controller.

running app

sample-spring-app

To View the sample app Logs run the following command

D:\CloudFoundryDev\cf logs cf-spring –recent

Or, stream live logs: D:\CloudFoundryDev\cf logs cf-spring

Now let’s connect a Database

PCF enables administrators to provide a variety of services on the platform that can easily be consumed by applications.

List the available ElephantSQL plans:

D:\CloudFoundryDev\cf marketplace -s elephantsql

Create a service instance with the free plan:

You can create a service instance from CF CLI or from the Web Services Console too.

add-service-1

add-service-2

D:\CloudFoundryDev\cf create-service elephantsql turtle cf-spring-db

app-restart

Bind the newly created service to the app:

cf bind-service cf-spring cf-spring-db

bind-db

Once a service is bound to an app, environment variables are stored that allow the app to connect to the service after a push, restage, or restart command.

Restart the app:

cf restart cf-spring

cf services

app-restart-1

Scale the Application on Pivotal PAAS.

Increasing the available disk space or memory can improve overall app performance. Similarly, running additional instances of an app can allow an app to handle increases in user load and concurrent requests.

These adjustments are called scaling.

You can do scaling either from  the Web Application Manager or using the CF CLI.

scale-1

Scaling your app horizontally adds or removes app instances. Adding more instances allows your application to handle increased traffic and demand.

scale-2

Scaling your app horizontally adds or removes app instances. Adding more instances allows your application to handle increased traffic and demand.

Increase the number of app instances from one to two:

cf scale cf-spring -i 2

cf-scale-1

Increase the memory limit for each app instance:

cf scale cf-spring -m 1G

cf-scale-2

Increase the disk limit for each app instance:

cf scale cf-spring -k 512M

cf-scale-3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s