This guide covers basic information to get started using Application Development on OpenShift 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.
Introduction to Application Development on OpenShift
Application Development on OpenShift allow you to use different ecosystems, languages, and runtimes at the same time for solving business problems.
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.
What is Application Development on OpenShift
Application Development on OpenShift 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 Application Development on OpenShift 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.
Example Applications
Application Development on OpenShift examples implement Microservice patterns such as:
-
Health Check
-
REST or HTTP endpoint
-
Circuit Breaker
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.
Supported Build Strategies for OpenShift Deployment
OpenShift supports different build strategies including Source-to-Image and Jenkins Pipeline. Application Development on OpenShift 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.
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.
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.
-
For information about installing Fabric8 Launcher in your OpenShift instance, see Install and Configure the Fabric8 Launcher Tool.
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.
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.
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, stand-alone 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.
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.
-
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
-
-
Select Launch Your Project.
-
Follow the instructions to select an example application, runtime, and target environment.
-
Open the
README.adoc
file in your example application project for more details about interacting with your example application.
Take a look the different runtime guides to learn more about runtimes as well as their example applications:
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.
-
Check which OpenShift Online cluster you belong to using https://manage.openshift.com.
-
Navigate to developers.redhat.com/launch using your browser.
-
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.
-
-
You may be prompted to grant developers.redhat.com/launch access to your GitHub and OpenShift Online accounts. This is a one-time action.
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 therh-developers-launch
SSO realm. For example, if your GitHub account is associated with a different Red Hat Developers account within therh-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.-
Click Grant Access.
-
Click the Add button next to the GitHub field and authorize developers.redhat.com/launch to access your GitHub account.
-
Click the Add button next to the OpenShift Online cluster you use.
-
-
Follow the instructions to select an example application, runtime, and target environment.
-
Open the
README.adoc
file in your example applications’s project and follow the instructions for building, deploying, and interacting with your example application.
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. |
Creating a new application using the Fabric8 Launcher Tool
Set up a new application project and deploy it to an OpenShift cluster using the Fabric8 Launcher tool. The following procedure describes the main actions you need to perform when setting up your project using Fabric8 Launcher:
-
Configure a frontend for your application.
-
Configure a backend for your application.
-
Connect to a GitHub account to host the repository with your project files.
-
Configure an OpenShift Cluster to host your deployed application.
-
Access to an OpenShift cluster
-
Fabric8 Launcher installed on your OpenShift cluster.
-
A GitHub account
-
Click Start on the Launcher landing page to access the main Launcher screen.
-
Select Create a New Application.
-
Specify a name for your application project. If you do not provide a name, Fabric8 Launcher assigns a random name to your project.
-
Configure a frontend for your application.
-
Click Configure a Frontend.
-
Select a framework that you want to use for your application frontend. You can choose between community and product releases of the listed frameworks. If you do not want Fabric8 Launcher to configure a frontend for your app, select None.
-
Click Save when you are done.
-
-
Configure a backend for your application
-
Click Configure a Backend.
-
Select a runtime that you want to use for your application backend. You can choose between community and product releases of the listed runtimes. If you do not want Fabric8 Launcher to configure a backend for your app select None.
-
OPTIONAL: Select additional capabilities for your application. You might need to specify additional options depending on the capability you choose. Health Checks are added to your app by default.
-
Click Save when you are done.
-
-
Connect a GitHub account to your Fabric8 Launcher.
-
Click Authorize in the Destination Repository section of the screen.
-
When you are redirected to the login prompt on GitHub, log in using your account credentials. When logged in, you are redirected to the authorization screen.
-
Click Authorize fabric8-launcher. When authorization completes, you are redirected back to the Launcher web interface.
-
Click Save to confirm your destination repository settings and return to the project setup screen in the Launcher.
-
Click Configure in the OpenShift Deployment section of the screen. Log in using your OpenShift account credentials to connect your cluster to the Fabric8 Launcher tool.
-
Click Save when you are done.
-
-
Click Launch to deploy your project to the OpenShift cluster. Alternatively, click Download to download a ZIP file containing the generated project files.
Deploying an example to OpenShift Container Platform
-
Have an example created using developers.redhat.com/launch or the Fabric8 Launcher tool in a Minishift or CDK.
-
Have access to an OpenShift Container Platform Web console.
-
Have the
oc
CLI client installed.
-
Clone the Github repository with your example application, or download and extract the example application ZIP archive.
-
Get the command containing your authentication token for using the
oc
CLI client with your OpenShift Container Platform Web Console:-
Login to your OpenShift Container Platform Web console.
-
Click on the question mark icon in the top right-hand corner of the Web console, next to your user name.
-
Select Command Line Tools in the drop-down menu.
-
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.
-
-
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
-
Create a new project.
$ oc new-project MY_PROJECT_NAME
-
Navigate to the root directory of your application.
-
Deploy your example to OpenShift Container Platform.
-
If your example uses Maven:
$ mvn clean fabric8:deploy -Popenshift
-
If your example uses
npm
.$ npm install && npm run openshift
-
-
Open the
README.adoc
file in your example application’s project and follow the instructions for interacting with your example application.
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.
-
Have an example application deployed to OpenShift Online, or Minishift or CDK using the Deploy in OpenShift Online option.
-
Clone your project from GitHub:
$ git clone [email protected]:USERNAME/PROJECT-NAME.git
-
Open your project in your desired IDE or editor, such as Red Hat CodeReady Studio.
-
Make an update to the project.
-
Save your changes.
-
Commit and push your changes back to GitHub:
$ git add . $ git commit -m "Made an update" $ git push
-
Navigate back to the OpenShift Online or Minishift or CDK Web console and ensure the project of your example application is selected.
-
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. -
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.
-
Have an example application deployed to OpenShift Online, or Minishift or CDK using the Deploy in OpenShift Online option.
-
Have Red Hat CodeReady Studio downloaded from the Red Hat Developer Portal and installed.
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.
-
Your example application created and downloaded from developers.redhat.com/launch.
-
Red Hat CodeReady Studio running.
-
In Red Hat CodeReady Studio, Click File → Import.
-
Choose Git → Projects from Git and click Next.
-
Choose Existing local repository and click Next.
-
Click Add.
-
Click Browse.
-
Navigate to the project folder of your example application and click Open.
-
Click the check box next to your example application project and click Finish.
-
Make sure your example application project is selected and click Next.
-
Select Import as general project and click Next.
-
Click Finish.
-
Start editing your project after your import is complete.
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.
-
All files with changes that you intend to commit are saved.
-
In Red Hat CodeReady Studio, right click on the root of the project Project Explorer or Package Explorer view.
-
Choose Team → Commit….
-
Drag all the changes you want to commit from the Unstaged Changes section to the Staged Changes section.
-
Enter your commit message and click Commit and Push.
-
Click Close in the Push Results window when prompted.
-
Observe your changes are now available in your GitHub repository.
Appendix C: Glossary
Product and project names
- developers.redhat.com/launch
-
developers.redhat.com/launch is a stand-alone 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.
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.