Skip to main content

Using a Route Service with Your App in Cloud Foundry

Hands-On Lab

 

Photo of Travis Thomsen

Travis Thomsen

Course Development Director in Content

Length

02:00:00

Difficulty

Advanced

In this hands-on lab, you are taking on the role of a DevOps Engineer. You have an app called hello-world that is deployed out to Cloud Foundry, and Operations wants additional logging. You are to push out a logger app and configure it as a user-provided service. Once the service is created, you are to bind the route service to hello-world’s route.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Using a Route Service with Your App in Cloud Foundry

Introduction

In this hands-on lab, you are taking on the role of a DevOps Engineer. You have an app called hello-world that is deployed out to Cloud Foundry, and Operations wants additional logging. You are to push out a logger app and configure it as a user-provided service. Once the service is created, you are to bind the route service to hello-world’s route.

Solution

Open a terminal session and log in to the provided instance:

ssh cloud_user@<PUBLIC IP>

Then, become root:

sudo su

You will also need to register for a free Pivotal Cloud Foundry account.

Log In to Pivotal Cloud Foundry

  1. Log in to your Pivotal Cloud Foundry account:

    cf login -a api.run.pivotal.io
  2. When prompted, enter the email address you used for the account as well as your password.

  3. Clean up any lingering resources:

    cf apps
  4. If there are any resources you need to delete, for each app you need to remove, enter:

    cf delete <APP NAME>

Deploy Your Route Service to Cloud Foundry

  1. Change to the hello-world directory:

    cd hello-world
  2. Bootstrap the application:

    cf push
  3. Change to the logging-route-service directory:

    cd logging-route-service
  4. Push the logger application:

    cf push logger -m 512m -k 512m --random-route
  5. Get the route for the app:

    cf apps
  6. Create a user-provided service app for the logger, replacing <APP URL with the logger URL in the output from cf apps:

    cf cups logger -r https://<APP URL>
  7. Bind the logger service instance to the route of hello-world, replacing <HOSTNAME> with the hostname for hello-world (everything up until the .cfapps.io in the cf apps output):

    cf bind-route-service cfapps.io logger --hostname <HOSTNAME>
  8. Execute cf logs against the logger app:

    cf logs logger
  9. In a new browser tab, browse to the hello-world app URL.

  10. Monitor the terminal to see the log data populate.

Conclusion

Congratulations on successfully completing this hands-on lab!