Getting Started with Red Hat OpenShift Application Runtimes

Red Hat OpenShift Application Runtimes 1

For Use with Red Hat OpenShift Application Runtimes

Red Hat Customer Content Services

Abstract

This guide provides a getting started experience for Red Hat OpenShift Application Runtimes.

Preface

This guide covers basic information to get started using Red Hat OpenShift Application Runtimes for cloud-native development on OpenShift.

It shows you how to create and deploy example cloud-native applications to OpenShift using developers.redhat.com/launch or Fabric8 Launcher.

These example applications can serve as the foundation for your actual cloud-native microservices because they can be updated and redeployed using the same deployment process detailed in this guide.

Chapter 1. Introduction to Application Development on OpenShift

Red Hat OpenShift Application Runtimes allow you to use different ecosystems, languages, and runtimes at the same time for solving business problems.

1.1. About Red Hat OpenShift

Red Hat OpenShift is a container application platform that brings Docker and Kubernetes to the enterprise.

OpenShift helps manage, secure, and automate the deployment and monitoring of your applications. This enables you to break your business problems into smaller microservices while letting OpenShift provide a simpler way to deploy, monitor, and maintain microservices.

OpenShift Container Platform
A private, on-premise cloud by Red Hat.
OpenShift Online
A public cloud hosted by Red Hat.
Minishift or CDK

A local cloud that you can install and execute on your local machine.

This functionality is provided for example by Red Hat Container Development Kit or Minishift.

1.2. What is Red Hat OpenShift Application Runtimes

Red Hat OpenShift Application Runtimes provides you with cloud-native runtimes and prescribes approaches to developing, building, and deploying applications that use those cloud-native runtimes on OpenShift. These cloud-native development approaches take advantage of the capabilities provided by OpenShift and enable you to use patterns such as Circuit Breaker, Health Check, and Service Discovery.

Application Development on OpenShift is:

  • A collection of runtimes, such as Thorntail and Spring Boot, designed to run on OpenShift.
  • A prescriptive approach to cloud-native development on OpenShift.

The goal of Red Hat OpenShift Application Runtimes is to provide prescriptive architectures, design patterns, tools, and best practices in ready-made example applications that you can execute on OpenShift to enable cloud-native development.

Cloud-native development is an approach to developing, deploying, and running applications that take full advantage of cloud computing.

1.3. Example Applications

Red Hat OpenShift Application Runtimes examples implement Microservice patterns such as:

Example applications use these patterns to show how to create the fundamental building blocks of cloud-native applications and services, such as:

  • Creating HTTP APIs.
  • Integrating your application with a relational database to provide persistent data storage.
  • Implementing the health check and circuit-breaker patterns to ensure that your services can withstand a traffic overload and network issues.
  • Externalizing the configuration of your applications to make them more secure and easier to scale.

Each example application is implemented in one or more runtimes.

1.4. Supported Build Strategies for OpenShift Deployment

OpenShift supports different build strategies including Source-to-Image and Jenkins Pipeline. Red Hat OpenShift Application Runtimes example applications use the Source-to-Image strategy (S2I) for simplicity of use and implementation. Other build strategies, such as the Jenkins Pipeline, are more complex, for example employing multiple servers for building or using webhooks to trigger builds.

Example applications created using the Build and Deploy to OpenShift build process, which is based on the S2I build strategy, can also be executed locally, as well as built locally and manually deployed to OpenShift.

For more information on these options, see the README.adoc file of your example application.

Chapter 2. Application Development on OpenShift with Fabric8 Launcher

To get started developing applications on OpenShift, install Fabric8 Launcher or use the Red Hat-provided service, developers.redhat.com/launch.

2.1. About Fabric8 Launcher

Fabric8 Launcher is a project generator for cloud-native application development on OpenShift. It provides a way of creating functional example applications as well as an easy way to build and deploy these example applications on OpenShift.

Using Fabric8 Launcher, you can create and deploy an example application to OpenShift using the Build and Deploy to OpenShift build process, which is based on the Source-to-Image (S2I) build process. Build and Deploy to OpenShift configures OpenShift to pull the code of your example application from your GitHub repository, build the code, and deploy it to OpenShift. The benefit of this process is that it handles all the configuration, building, and deployment steps needed to get your example application running in OpenShift. It also allows you to quickly deploy code updates and see your changes in OpenShift.

Additional resources

2.2. How the Fabric8 Launcher tool works

The Fabric8 Launcher tool runs on OpenShift and lets you create functional example applications. The Fabric8 Launcher tool walks you through:

  • choosing the example application you want to generate,
  • choosing the runtime you want to use, and
  • choosing how you want to build and execute the example application.

The Fabric8 Launcher tool uses your choices to generate a custom project, called an example application, and either launches it directly to the same OpenShift instance, or provides a downloadable ZIP version of the project.

2.3. About developers.redhat.com/launch

developers.redhat.com/launch is a stand-alone Red Hat project generator based on Fabric8 Launcher. It provides an easy way to create, build, and deploy example applications to OpenShift Online or other OpenShift instances like OpenShift Container Platform or your Minishift or CDK.

Chapter 3. Available Runtimes

The following runtimes are available for developing your application in OpenShift:

Eclipse Vert.x

A tool-kit for building reactive event driven non blocking applications on JVM.

See Eclipse Vert.x Runtime Guide for information about Eclipse Vert.x application development.

Thorntail

A framework based on the popular JBoss EAP Java application server to enable the creation of small, standalone microservice-based applications. Thorntail is capable of producing the so-called just-enough app-server to support each component of your system.

See Thorntail Runtime Guide for information about Thorntail application development.

Spring Boot

Spring Boot makes it easy to create stand-alone, production-grade Spring based applications that need very little Spring configuration.

See Spring Boot 2.1.x Runtime Guide (current version) for information about Spring Boot application development.

See Spring Boot 1.5.x Runtime Guide for information about Spring Boot 1.5 application development.

Node.js

An asynchronous event-driven JavaScript runtime designed to build scalable network applications.

See Node.js Runtime Guide for information about Node.js application development.

Chapter 4. Creating and deploying an example application using an OpenShift Cluster

You can quickly create, build, and deploy an example application to an OpenShift Cluster using the Fabric8 Launcher tool. The Fabric8 Launcher tool creates a new repository in your GitHub account containing the example application’s code and deploys it to your OpenShift Cluster. It can also create a ZIP of the example application for you to download and run on your localhost.

Procedure

  1. Navigate to the Fabric8 Launcher tool on your OpenShift Cluster using your browser.

    • Optionally, use the following command to open the Web Console of your OpenShift Cluster in your browser in order to navigate to your Fabric8 Launcher tool:

      $ minishift console
  2. Select Launch Your Project.
  3. Follow the instructions to select an example application, runtime, and target environment.
  4. Open the README.adoc file in your example application project for more details about interacting with your example application.

Additional resources

Take a look the different runtime guides to learn more about runtimes as well as their example applications:

Chapter 5. Deploying an example application to OpenShift Online

You can quickly create, build, and deploy an example application to OpenShift Online using developers.redhat.com/launch. developers.redhat.com/launch creates a new repository in your GitHub account containing the application’s code and deploys it to your OpenShift Online account. It can also create a ZIP of the example application for you to download and run on your localhost.

Procedure

  1. Navigate to developers.redhat.com/launch using your browser.
  2. Select Launch your Project.

    • You may be prompted to log in to your Red Hat Developers account. If you are, click Log in or register and complete the authentication steps.
  3. You may be prompted to grant developers.redhat.com/launch access to your GitHub and OpenShift Online accounts. This is a one-time action.

    Important

    developers.redhat.com/launch uses the rh-developers-launch SSO realm to connect your Red Hat Developers account, your GitHub account, and your OpenShift Online account together. When you add these connections, developers.redhat.com/launch is granted access to those accounts and is allowed to use those accounts when creating and deploying example applications.

    When connecting these three accounts together in rh-developers-launch, they may only be used with each other within the rh-developers-launch SSO realm. For example, if your GitHub account is associated with a different Red Hat Developers account within the rh-developers-launch SSO realm, you must deauthorize it from the other Red Hat Developers account or add a different GitHub account.

    At this time, you cannot use the us-east-2 OpenShift Starter cluster with developers.redhat.com/launch. This cluster is used with OpenShift.io and is configured differently.

    1. Click Grant Access.
    2. Click the Add button next to the GitHub field and authorize developers.redhat.com/launch to access your GitHub account.
    3. Click the Add button next to the OpenShift Online cluster you use.
  4. Follow the instructions to select an example application, runtime, and target environment.
  5. Open the README.adoc file in your example applications’s project and follow the instructions for building, deploying, and interacting with your example application.
Important

When you are done interacting with and updating your example application, it is recommended to delete your project because the resources allocated to your OpenShift Online account are limited. For instructions, see the Deleting a Project chapter of the OpenShift Online documentation. You can redeploy the example application later using the instructions in the relevant runtime guide.

You have quotas for your OpenShift Online account. If you exceed your account quota, you will not be able to launch new example applications using developers.redhat.com/launch. The quota for your account varies depending on your subscription.

Chapter 6. Deploying an example to OpenShift Container Platform

Prerequisites

Procedure

  1. Clone the Github repository with your example application, or download and extract the example application ZIP archive.
  2. Get the command containing your authentication token for using the oc CLI client with your OpenShift Container Platform Web Console:

    1. Login to your OpenShift Container Platform Web console.
    2. Click on the question mark icon in the top right-hand corner of the Web console, next to your user name.
    3. Select Command Line Tools in the drop-down menu.
    4. Find the text box that contains the oc login …​ command with the hidden token, and click the button next to it to copy its content to your clipboard.
  3. Paste the command you copied in the previous step into a terminal to authenticate your oc CLI client with your OpenShift Container Platform account by using your authentication token.

    $ oc login OCP_URL --token=MYTOKEN
  4. Create a new project.

    $ oc new-project MY_PROJECT_NAME
  5. Navigate to the root directory of your application.
  6. Deploy your example to OpenShift Container Platform.

    1. If your example uses Maven:

      $ mvn clean fabric8:deploy -Popenshift
    2. If your example uses npm.

      $ npm install && npm run openshift
  7. Open the README.adoc file in your example application’s project and follow the instructions for interacting with your example application.

Additional resources

Take a look at the different runtime guides to learn more about the runtimes and their example applications:

Appendix A. Updating your example application and deploying the changes

To push changes to an example application running in OpenShift Online or your Minishift or CDK, you can push a new commit to the GitHub repository and start a new build.

Prerequisites

  • Have an example application deployed to OpenShift Online, or Minishift or CDK using the Deploy in OpenShift Online option.

Procedure

  1. Clone your project from GitHub:

    $ git clone git@github.com:USERNAME/PROJECT-NAME.git
  2. Open your project in your desired IDE or editor, such as Red Hat CodeReady Studio.
  3. Make an update to the project.
  4. Save your changes.
  5. Commit and push your changes back to GitHub:

    $ git add .
    $ git commit -m "Made an update"
    $ git push
  6. Navigate back to the OpenShift Online or Minishift or CDK Web console and ensure the project of your example application is selected.
  7. Click on the three dots on the right side of your application’s deployment and choose Start Build.

    Your deployment is complete when you see Build #2 is complete under Builds and a #2 next to the application name under Deployment. This number will increase for each additional build and deployment.

  8. Confirm your changes when your deployment is complete.

Appendix B. Using Red Hat CodeReady Studio with an example application project

Red Hat CodeReady Studio is an integrated development environment, or IDE, that provides tooling for writing software. You can use it to make changes to your example application’s code.

Prerequisites

B.1. Importing your example application code to Red Hat CodeReady Studio

Importing your example application’s code creates a project in Red Hat CodeReady Studio and enables you to start making changes.

Prerequisites

Procedure

  1. In Red Hat CodeReady Studio, Click FileImport.
  2. Choose GitProjects from Git and click Next.
  3. Choose Existing local repository and click Next.
  4. Click Add.
  5. Click Browse.
  6. Navigate to the project folder of your example application and click Open.
  7. Click the check box next to your example application project and click Finish.
  8. Make sure your example application project is selected and click Next.
  9. Select Import as general project and click Next.
  10. Click Finish.
  11. Start editing your project after your import is complete.

B.2. Committing and pushing changes to the GitHub repository of your example application

Red Hat CodeReady Studio provides tooling for committing and pushing code through Git directly in the IDE. Alternatively, you can use Red Hat CodeReady Studio to make changes and push those changes with the Git CLI.

Prerequisites

  1. All files with changes that you intend to commit are saved.

Procedure

  1. In Red Hat CodeReady Studio, right click on the root of the project Project Explorer or Package Explorer view.
  2. Choose TeamCommit…​.
  3. Drag all the changes you want to commit from the Unstaged Changes section to the Staged Changes section.
  4. Enter your commit message and click Commit and Push.
  5. Click Close in the Push Results window when prompted.
  6. Observe your changes are now available in your GitHub repository.

Appendix C. Glossary

C.1. Product and project names

developers.redhat.com/launch
developers.redhat.com/launch is a standalone getting started experience offered by Red Hat for jumpstarting cloud-native application development on OpenShift. It provides a way of creating functional example applications as well as an easy way to build and deploy these example applications on OpenShift.
Fabric8 Launcher
The Fabric8 Launcher is the upstream project on which developers.redhat.com/launch is based.
Minishift or CDK
An OpenShift cluster running on your machine using Minishift.

C.2. Terms specific to Fabric8 Launcher

Example

An application specification, for example a web service with a REST API.

Examples generally do not specify which language or platform they should run on; the description only contains the intended functionality.

Example application

A language-specific implementation of a particular example on a particular runtime. Example applications are listed in an examples catalog.

For example, an example application is a web service with a REST API implemented using the Thorntail runtime.

Examples Catalog
A Git repository that contains information about example applications.
Runtime
A platform that executes an example application. For example, Thorntail or Eclipse Vert.x.

Legal Notice

Copyright © 2019 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.