Tiven Wang
Wang Tiven February 23, 2017
425 favorite favorites
bookmark bookmark
share share

Try CloudFoundry Series

Background

How Can I Try Out Cloud Foundry?

Signup

Get a free Pivotal Web Services account

Try

Install CF CLI

Install the CF CLI

Deploy the Sample App

Now that you have the cf CLI installed and a Pivotal Web Services (PWS) account, you are really close to deploying the sample app.

This sample app is built with Spring Boot to get you up and running as quickly as possible.

Download the app with git:

git clone https://github.com/cloudfoundry-samples/cf-sample-app-spring.git

If you don’t have Git installed, you can download a zip file of the app at https://github.com/cloudfoundry-samples/cf-sample-app-spring/archive/master.zip

Navigate to the app directory:

cd cf-sample-app-spring

Sign in to PWS:

cf login -a https://api.run.pivotal.io

Push the app to PWS:

cf push

Open the sample app in your browser:

Image: gettingstartedwithpcf

View the Logs

View a snapshot of recent logs:

cf logs cf-spring --recent

Or, stream live logs:

cf logs cf-spring

PCF provides access to an aggregated view of logs related to your application. This includes HTTP access logs, as well as output from app operations such as scaling, restarting, and restaging.

Every log line contains four fields:

  • Timestamp
  • Log type
  • Channel
  • Message

Image: sample-app-logs

Press Control C to stop streaming.

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:

cf marketplace -s elephantsql

Create a service instance with the free plan:

cf create-service elephantsql turtle cf-spring-db

Bind the newly created service to the app:

cf bind-service cf-spring cf-spring-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

Verify the new service is bound to the app:

cf services

Scale the App

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.

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

Image: scaling

Increase the number of app instances from one to two:

cf scale cf-spring -i 2

Check the status of the app and verify there are two instances running:

cf app cf-spring

Scaling your app vertically changes the disk space limit or memory limit for each app instance.

Increase the memory limit for each app instance:

cf scale cf-spring -m 1G

Increase the disk limit for each app instance:

cf scale cf-spring -k 512M

Next Steps

Topics to explore

References

Similar Posts

Comments

Back to Top