Foundations of OpenShift

Learn the foundations of OpenShift through hands-on experience deploying and working with applications, using a no-cost OpenShift cluster through the Developer Sandbox for Red Hat OpenShift.

 

In this lesson, you will learn how to work with the OpenShift web console to install an application from source code stored in a GitHub repository. 

What you need to know

In order to get full benefit from taking this lesson, you need to:

  • Understand the relationship between OpenShift and Kubernetes.
  • Understand the purpose and use of a public Git repository such as GitHub to store application source code.
  • Understand how to access the OpenShift web console via the Developer Sandbox.
  • Understand the basics of the features available to users in the Administrative and Developer perspectives.

What you will learn

In this lesson you will learn:

  • How to use the web console to import source code from GitHub.
  • How to use the web console to get the application up and running from source code.
  • How to remove an application from OpenShift using the web console.

Red Hat OpenShift allows you to use the web console to install an application directly from source code hosted in a GitHub repository. All you need to do is declare the location of the source code, add some configuration information, and start the installation process.

OpenShift does the work of downloading the source code from the GitHub repository and then building a Linux container based on the source code. That Linux container is created as a pod(s) in the underlying OpenShift/Kubernetes cluster. Also, OpenShift does the work of creating a service that allows network access to the pod from within the cluster. OpenShift also creates a route to the application if the application needs to be publicly accessible.

Select the application to install

To select which application you want to install:

  1. Navigate here (Figure 1, Callout 1) and Select Start your sandbox for free (Figure 1, Callout 2). D

    The entry point for access to the Developer Sandbox for Red Hat OpenShift.
    Figure 1: The entry point for access to the Developer Sandbox for Red Hat OpenShift.
    Figure 1: The entry point for access to the Developer Sandbox.
  2. Provide the username and password for your Red Hat account on the login page that appears when you first enter the sandbox (Figure 2). 

    Log into the OpenShift web console with the username and password associated with your Red Hat account.
    Figure 2: Log into the OpenShift web console with the username and password associated with your Red Hat account.
  3. In the OpenShift web console, select +Add from the left-side vertical menu (Figure 3). 

    Select All Services in the +Add web page.
    Figure 3: Select All Services in the +Add web page.
  4. An All service page appears. Under All items, there is a search field. Type Python. This action filters out all text blocks except those that are relevant to Python (Figure 4). 

    The Developer Catalog search feature.
    Figure 4: The Developer Catalog search feature.
  5. Select the text block labeled Python. You'll be presented with a web page that is unique to the Python service you've just selected. You will use this web page to install a Python application from source code. Select Create (Figure 5). 

    Select Create Application.
    Figure 5: Select Create Application.
    Figure 5: Select Create.

Create the application

When you select Create, a web page will appear titled Create  Source-To-Image Application. You'll use this web page to import source code into OpenShift that's stored in a Git repository (repo). You'll use OpenShift's Source-To-Image capabilities to create a Linux container that represents the application running in OpenShift.

Your first step is to declare the location of the application’s source code in GitHub.

  1. Enter https://github.com/openshift-instruqt/blog-django-py in the text box labeled Git Repo URL (Figure 6). 

    Create an Application under Source-to-Image by declaring a URL to the intended application’s source code.
    Figure 6: Create an Application under Source-to-Image by declaring a URL to the intended application’s source code.
  2. Scroll down the page. Your Create to Source-To-Image Application selection has automatically filled-in values for the Application and Name fields of the General section (Figure 7). 

    Source-to-Image provides default naming.
    Figure 7: Source-to-Image provides default naming.
  3. Scroll until you reach Deploy. Select Deployment as the Resource type (Figure 8).

    Resource type should be Deployment.
    Figure 8: Resource type should be Deployment.
  4. Scroll until you reach Advanced options. Select Create a route to the Application. This means that as part of the application creation process, OpenShift will automatically create a URL that allows access to the application from the Internet. 
  5. Select Create. This action will save the source code data and start the build process for the application (Figure 9). 

    OpenShift automatically creates a URL to access the intended application.
    Figure 8: OpenShift automatically creates a URL to access the intended application.
    Figure 9: OpenShift automatically creates a URL to access the intended application.
  6. As the application builds, OpenShift will take you to the Topology sub-menu (Figure 10, Callout 1).
  7. The Topology page will display a graphic that represents the application within the OpenShift cluster. OpenShift will display the application with a light blue circle as the build process progresses (Figure 10, Callout 2).
  8. When the application's build process is complete, the circle’s color will turn dark blue (Figure 10, Callout 3). 

    An application’s status will change from build (light-blue circle) to running (dark-blue circle) in Topology view.
    Figure 9: An application’s status will change from build (light-blue circle) to running (dark-blue circle) in Topology view.
    Figure 10: An application’s status will change from build (light-blue circle) to running (dark-blue circle) in Topology view.
  9. Once the application build process is complete, it is ready for use. In this case, the application is a web application written in Python that is viewable in a web browser. Click the icon in the upper right corner "to application" graphic to start the web application in a browser window (Figure 11). 

    Click the icon in the upper right corner of the application graphic to view it on a web browser.
    Figure 10: Click the icon in the upper right corner of the application graphic to view it on a web browser.
    Figure 11: Click the icon in the upper right corner of the application graphic to view it on a web browser.

At this point, the Python application is up and running. All you did was choose an application template from the OpenShift library and set a URL that declared the location of the application’s source code in GitHub. OpenShift retrieved the source code, created a Linux container based on the source, then got the container up and running in the underlying Kubernetes cluster. Also, OpenShift did the work of exposing the application to the Internet at a URL created by OpenShift to enable access.

Delete the application from OpenShift

You can delete an application running in OpenShift by right-clicking on the circular graphic representing the application in Topology view, then selecting Delete Application.

Right-click on the outer ring of the circular icon representing the application in Topology view, then select Delete Application from the dialog box (Figure 12).

Right-click the outer ring of the application graphic to display the Delete Application dialog box.
Figure 11: Right-click the outer ring of the application graphic to display the Delete Application dialog box.
Figure 12: Right-click the outer ring of the application graphic to display the Delete Application dialog box.

You will be asked to confirm if you want to delete the application. Enter the application’s name to delete it (Figure 13).

Deleting an application requires confirmation.
Figure 12: Deleting an application requires confirmation.
Figure 13: Deleting an application requires confirmation.

Summary

In this lesson, you learned how to use OpenShift to install an application from source code. You selected an application template for the OpenShift library. You declared the URL of the application’s source code in GitHub, then instigated the build process by doing nothing more than clicking a Create button. Finally, you viewed the application by using a URL that OpenShift created.

Next

In the next lesson, you’ll learn how to use the OpenShift web console to install and run an application from a container image that’s hosted in a public repository.

Previous resource
Use the terminal window within the Red Hat OpenShift web console
Next resource
Install an application from a Linux container image repository using the OpenShift web console