Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Latest commit

 

History

History
115 lines (82 loc) · 3.8 KB

deploy-awwvision.md

File metadata and controls

115 lines (82 loc) · 3.8 KB

Exercise: AwwVision

Open in Cloud Shell

Introduction

Now that you've deployed PCF and logged in to Cloud Foundry it's time to explore the platform and Google Cloud.

This exercise deploys a spring application that scrapes /r/aww for photos, stores them in Google Cloud Storage and classifies them with the Google Cloud Vision API.

The services are provisioned by the GCP Service Broker so we will not need to leave Cloud Foundry to create them or setup authentication.

Deploy AwwVision

1. Confirm access to Cloud Foundry

Run cf apps to ensure you're connected and authenticated to Cloud Foundry. If the command fails ensure you've logged in.

2. Create a org and space for development

Cloud Foundry uses orgs and spaces to contain applications and services. Create and target an org and space for your development with the following commands:

cf create-org dev
cf create-space -o dev dev
cf target -o dev -s dev

3. Ensure Maven/JDK8 is Installed

This sample app requires maven and Java 1.8 to build. Users of Google Cloud Shell will have this by default.

Confirm with the following commands:

mvn -version # look for: Apache Maven 3+
java -version # look for: version "1.8"

3. Build and deploy the application

From the root directory of this project (gcp-pcf-quickstart) run the following commands:

cd docs/samples/awwvision
mvn package -DskipTests && cf push -p target/awwvision-spring-0.0.1-SNAPSHOT.jar --no-start

4. Create/Bind Google Services

Create a Google Cloud Storage service and bind it to the application. This provisions a new storage bucket and service account with the role 'storage.objectAdmin'. The bind command will also create a new service account key for your application to authenticate to Google Cloud Storage.

Run the following commands:

cf create-service google-storage standard awwvision-storage
cf bind-service awwvision awwvision-storage -c '{"role":"storage.objectAdmin"}'

To view the credentials, try: cf env awwvision

5. Start and Aww

The app can now be started and hostname retrieved with the following commands:

cf start awwvision
cf apps

Enter the URL into your browser (eg: http://awwvision-...apps...) and click on 'Update with latest images'. This may take up to 30 seconds. Follow the link back to the homepage and view the resulting images:

screenshot showing AwwVaision displaying images with classified names

Click on the text category to view the related images, for example click 'Dog'

Clean up

Find the name of the Google Cloud Storage bucket by running the following command and looking for "bucket_name":

cf env awwvision

Clear the contents of the bucket:

gsutil rm gs://<bucket name>/*

Delete the binding, service, and app:

cf unbind-service awwvision awwvision-storage
cf delete-service awwvision-storage
cf delete awwvision

What's Next?