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

  • Try Cloud Foundry 13 - Logs Loggregator is the next generation system for aggregating and streaming logs and metrics from all of the user apps and system components in an Elastic Runtime deployment. Loggregator uses Google's protocol buffers along with gRPC to deliver logs.
  • Try Cloud Foundry 12 - Config Server Config Server for Pivotal Cloud Foundry (PCF) is an externalized application configuration service, which gives you a central place to manage an application’s external properties across all environments.
  • Try Cloud Foundry 11 - Autoscaler Autoscaler
  • Try CloudFoundry Try CloudFoundry
  • Try Cloud Foundry 10 - Service Discovery Service Registry for Pivotal Cloud Foundry (PCF) provides your applications with an implementation of the Service Discovery pattern, one of the key tenets of a microservice-based architecture. Trying to hand-configure each client of a service or adopt some form of access convention can be difficult and prove to be brittle in production. Instead, your applications can use the Service Registry to dynamically discover and call registered services.
  • Try Cloud Foundry 9 - Message Broker A message broker is an architectural pattern for message validation, transformation and routing. It mediates communication amongst applications, minimizing the mutual awareness that applications should have of each other in order to be able to exchange messages, effectively implementing decoupling.

Comments

comments powered by Disqus
Back to Top