Using Spring Cloud Services in PCF Dev

Page last updated:

This topic describes how to deploy and use the Spring Cloud® Services (SCS) suite within PCF Dev.

When configured to use SCS, PCF Dev provides the following services:

The sections below describe how to launch SCS and use the Config Server. The Service Registry and Circuit Breaker Dashboard work by default when PCF Dev is launched with SCS enabled.

Launch Spring Cloud Services

To launch PCF Dev using SCS, run cf dev start using the -s scs flag:

$ cf dev start -s scs
Downloading VM...
Progress: |====================>| 100%
Allocating 8192 MB out of 32768 MB total system memory (14387 MB free).
Importing VM...
Starting VM...
Provisioning VM...
Waiting for services to start...
...

Note: Due to the increased demands of SCS, PCF Dev allocates more memory than usual.

Alternatively, you can deploy SCS after start by running the following command:

$ cf dev deploy-service scs
Deploying scs...
OK

To undeploy SCS, stop PCF Dev:

$ cf dev stop

Use Spring Cloud Services

To create a service instance of the Config Server using the cook sample app, perform the following:

  1. Clone the cook sample app to your workspace.

  2. In a terminal window, navigate to the root repository of the cook sample app.

  3. To compile the cook sample app, run one of the following commands:

    • Mac OS X or Linux: ./gradlew build
    • Windows: gradlew.bat build

    For example, the output on Mac OS X appears as follows:

    $ ./gradlew build
    ...
    :compileTestJava
    :processTestResources UP-TO-DATE
    :testClasses
    :test
    2016-08-23 12:02:07.900  INFO 79148 --- [       Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5c2e9d5e: startup date [Tue Aug 23 12:02:04 EDT 2016]; root of context hierarchy
    2016-08-23 12:02:07.903  INFO 79148 --- [       Thread-5] o.s.w.c.s.GenericWebApplicationContext   : Closing org.springframework.web.context.support.GenericWebApplicationContext@4ef3f6da: startup date [Tue Aug 23 12:02:05 EDT 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5c2e9d5e
    :check
    :build
    
    BUILD SUCCESSFUL
    
  4. Run cf login to log in to PCF Dev and target your local domain using user/pass as the credentials. To avoid SSL validation errors, use the --skip-ssl-validation flag. See SSL Validation Errors.

    $ cf login -a https://api.local.pcfdev.io --skip-ssl-validation
    Email> user
    Password>
    Authenticating...
    OK
    ...
    
  5. Run cf create service to create a service instance of the config server. Use the -c flag to specify a JSON object containing configuration parameters for the service as show in the following example:

    $ cf create-service -c '{ "git": { "uri": "https://github.com/spring-cloud-services-samples/cook-config", "label": "master"  } }' p-config-server standard cook-config-server
    Creating service instance config-server in org pcfdev-org / space pcfdev-space as user...
    OK
    ...
    
  6. Run cf service config-server to confirm that the service was created:

    $ cf service config-server
    
    Service instance: config-server
    Service: p-config-server
    Bound apps:
    Tags:
    Plan: standard
    Description: Config Server for Spring Cloud Applications
    Documentation url: http://docs.pivotal.io/spring-cloud-services/
    Dashboard: https://spring-cloud-broker.local.pcfdev.io/dashboard/p-config-server/155f5ce5-82fb-42ba-adba-d7c569733c5c
    
    Last Operation
    Status: create succeeded
    Message:
    Started: 2016-08-23T16:19:29Z
    Updated: 2016-08-23T16:20:31Z
    

    When finished, the status of the service instance displays create succeeded.

  7. Push the compiled JAR file:

    $ cf push -p ./build/libs/cook-0.0.1-SNAPSHOT.jar
    

  8. Navigate to http://cookie.local.pcfdev.io/restaurant to view the cook app.

Note: PCF Dev uses an unverified certificate. When a PCF Dev SCS service makes use of an unverified certificate, the pushed apps must have the environment variable CF_TARGET set to the api URL of the PCF Dev instance: https://api.local.pcfdev.io. PCF Dev does this by default for all pushed apps.

Manage Spring Cloud Services

To manage an SCS instance within PCF Dev, navigate to Apps Manager and log in using the admin credentials, admin/admin. Instances of the SCS services are displayed in the instances space of the p-spring-cloud-services org. See the Use Apps Manager topic for more information.

SCS Apps Manager