Skip to content

Latest commit

 

History

History

lab02

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Lab 2

API Deployment

Deploying APIs to OpenShift

  • Duration: 15 mins
  • Audience: Developers, Architects, System Administrators, Operators

Overview

The code which implements any of the APIs in your organization is part of it's software infrastructure. This code needs to be well managed since it may need to scale to handle high volume, deployed in multiple locations and updated smoothly. In this lab you will learn how to deploy API backend code on the OpenShift container management platform which provides state of the art tools for managing deployed code.

Why Red Hat?

Red Hat OpenShift is one of the leading container management platforms available in the market. It is based on the highly popular Kubernetes Open Source project which Red Hat is a leading contributor to.

Skipping The Lab

If you are planning to follow to the next lab, there is an already deployed and running Location API Service in this endpoint:

http://location-service-international.apps.GUID.openshiftworkshop.com

Environment

URLs:

Check with your instruction the GUID number of your current workshop environment. Replace the actual number on all the URLs where you find GUID.

Example in case of GUID = 1234:

https://master.GUID.openshiftworkshop.com

becomes =>

https://master.1234.openshiftworkshop.com

Credentials:

Your username is your asigned user number. For example, if you are assigned user number 1, your username is:

user1

The password to login is always the same:

openshift

Lab Instructions

Step 1: Deploying Fuse-based APIs

  1. Open a browser window and navigate to:

    https://master.GUID.openshiftworkshop.com/console

    Remember to replace the GUID with your environment value and your user number.

  2. Accept the self-signed certificate if you haven't.

    selfsigned-cert

  3. Log into OpenShift using your designated user and password. Click on Sign In.

    01-login

  4. You are now in OpenShift's main page. Click on your userX project in the right side of the screen.

    02-user-project

  5. From your main project page, click Browse Catalog.

    03-browse-catalog

  6. Scroll down the page and search for the Red Hat Fuse 7.0 Camel with Spring Boot template. Click on the link.

    04-Fuse70-template

  7. Click the Next > button.

    05-template-information

  8. Fill in the configuration information with your API implementation github repo details:

    06-template-configuration

  9. Click Next >.

  10. In this moment we will not create any bindings. So click Create.

    07-template-binding

  11. Your service will be provisioned in a moment. Click the Continue to the project overview and then click the Close button.

    08-template-results

Step 2: Configure External Resources

Did you notice your deployment is failing? This is because your API requires information on the database host and port to connect. Let's fix this problem.

There are several ways to provision information of the environment to your OpenShift deployment. Most of the times you will use a combination of Config Maps, Environment Variables and, Secrets.

In this lab we will use Environment Variables.

  1. From your overview page, click the location-service link to access the deployment configuration.

    09-deployment-config

  2. In the deployment configuration page, change to the Environment tab. Here click the Add Value link twice to get two (2) new rows.

    10-environment

  3. Fill in with the following information regarding the location of the International Inc Database.

    • Name: MYSQL_SERVICE_HOST
    • Value: mysql.international.svc
    • Name: MYSQL_SERVICE_PORT
    • Value: 3306

    11-environment-variables

  4. Click Save to update the configuration and redeploy the service.

  5. Go back to the Overview page to monitor your updated deployment.

  6. You should now see the blue circle in the location-service pod.

    12-running-pod

Step 3: Test Location API Service

We now have a working Location API Service implementation listening for requests. We will use an online cURL tool to test it.

  1. Open a browser window and navigate to:

    https://onlinecurl.com/
  2. Enter the following URL:

    http://location-service-userX.apps.GUID.openshiftworkshop.com/locations/1

    Remember to replace the GUID with your environment values and your user number. It should look like this:

  3. Click the START YOUR CURL button.

    13-curl-service

  4. The page will load the response information from the service. You will be able to see the RESPONSE HEADERS and the actual RESPONSE_BODY.

    14-curl-response

Congratulations! You successfully deployed your teams Location API Service implementations into OpenShift using Red Hat Fuse 7.0 Spring Boot template.

Steps Beyond

Sometimes, something more complex could be making your deployment fail. You can take a deeper look in to the log by clicking the pod and changing to the Logs tab. From OpenShift you can also connect to the container through the provided Terminal tab.

Summary

In this lab you were able to launch a new software service which implements and API and manage it using the OpenShift platform. Subsequently you were able to call the API to see if it was really deployed and accessible in the right place.

You can now proceed to Lab 3

Notes and Further Reading