- Duration: 15 mins
- Audience: Developers, Architects, System Administrators, Operators
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.
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.
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
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
-
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.
-
Accept the self-signed certificate if you haven't.
-
Log into OpenShift using your designated user and password. Click on Sign In.
-
You are now in OpenShift's main page. Click on your userX project in the right side of the screen.
-
From your main project page, click Browse Catalog.
-
Scroll down the page and search for the Red Hat Fuse 7.0 Camel with Spring Boot template. Click on the link.
-
Click the Next > button.
-
Fill in the configuration information with your API implementation github repo details:
- Application Name: location-service
- Git Repository URL: https://github.com/hguerrero/3scale-api-workshop
- Git Repository context: /projects/location-service
- Git Reference: master
-
Click Next >.
-
In this moment we will not create any bindings. So click Create.
-
Your service will be provisioned in a moment. Click the Continue to the project overview and then click the Close button.
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.
-
From your overview page, click the location-service link to access the deployment configuration.
-
In the deployment configuration page, change to the Environment tab. Here click the Add Value link twice to get two (2) new rows.
-
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
-
Click Save to update the configuration and redeploy the service.
-
Go back to the Overview page to monitor your updated deployment.
-
You should now see the blue circle in the location-service pod.
We now have a working Location API Service implementation listening for requests. We will use an online cURL tool to test it.
-
Open a browser window and navigate to:
https://onlinecurl.com/
-
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:
-
Click the START YOUR CURL button.
-
The page will load the response information from the service. You will be able to see the RESPONSE HEADERS and the actual RESPONSE_BODY.
Congratulations! You successfully deployed your teams Location API Service implementations into OpenShift using Red Hat Fuse 7.0 Spring Boot template.
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.
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