red hat openshift application runtimes 0.1 wildfly swarm ... · pdf fileusing hystrix...

44
Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide For Use with Red Hat OpenShift Application Runtimes Last Updated: 2017-09-29

Upload: duongthuan

Post on 06-Mar-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Red Hat OpenShift ApplicationRuntimes 0.1

WildFly Swarm Runtime Guide

For Use with Red Hat OpenShift Application Runtimes

Last Updated: 2017-09-29

Page 2: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype
Page 3: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime

Guide

For Use with Red Hat OpenShift Application Runtimes

Page 4: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Legal Notice

Copyright © 2017 Red Hat, Inc.

The text of and illustrations in this document are licensed by Red Hat under a Creative CommonsAttribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA isavailable athttp://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you mustprovide 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 Infinitylogo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and othercountries.

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 UnitedStates and/or other countries.

MySQL ® is a registered trademark of MySQL AB in the United States, the European Union andother countries.

Node.js ® is an official trademark of Joyent. Red Hat Software Collections is not formally relatedto 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 marksor trademarks/service marks of the OpenStack Foundation, in the United States and othercountries 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.

Abstract

This guide provides details on using the WildFly Swarm runtime with Red Hat OpenShiftApplication Runtimes.

Page 5: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Table of Contents

PREFACE

CHAPTER 1. RUNTIME DETAILS

CHAPTER 2. MISSIONS2.1. REST API LEVEL 0 MISSION - WILDFLY SWARM BOOSTER

2.1.1. Building and Deploying the Booster2.1.1.1. Deploying the Booster to a Single-node OpenShift Cluster

2.1.1.1.1. Deploying Using developers.redhat.com/launch2.1.1.1.2. Deploying Using the oc CLI Client

2.1.1.2. Deploying your Booster to OpenShift Online2.1.2. Interacting with the Unmodified WildFly Swarm Booster2.1.3. REST Resources

2.2. CONFIGMAP MISSION - WILDFLY SWARM BOOSTER2.2.1. About ConfigMap2.2.2. Why ConfigMap is Important2.2.3. Building and Deploying the Booster

2.2.3.1. Deploying the Booster to a Single-node OpenShift Cluster2.2.3.1.1. Deploying Using developers.redhat.com/launch2.2.3.1.2. Deploying Using the oc CLI Client

2.2.3.2. Deploying your Booster to OpenShift Online2.2.4. Interacting with the Unmodified WildFly Swarm Booster2.2.5. ConfigMap Resources

2.3. RELATIONAL DATABASE BACKEND MISSION - WILDFLY SWARM BOOSTER2.3.1. Building and Deploying the Booster

2.3.1.1. Deploying the Booster to a Single-node OpenShift Cluster2.3.1.1.1. Deploying Using developers.redhat.com/launch2.3.1.1.2. Deploying Using the oc CLI Client

2.3.1.2. Deploying your Booster to OpenShift Online2.3.2. Interacting with the Application API2.3.3. Running Integration Tests2.3.4. Relational Database Resources

2.4. HEALTH CHECK MISSION - WILDFLY SWARM BOOSTER2.4.1. Building and Deploying the Booster

2.4.1.1. Deploying the Booster to a Single-node OpenShift Cluster2.4.1.1.1. Deploying Using developers.redhat.com/launch2.4.1.1.2. Deploying Using the oc CLI Client

2.4.1.2. Deploying your Booster to OpenShift Online2.4.2. Interacting with the Unmodified WildFly Swarm Booster2.4.3. Health Check Resources

2.5. CIRCUIT BREAKER MISSION - WILDFLY SWARM BOOSTER2.5.1. About Circuit Breaker2.5.2. Why Circuit Breaker is Important2.5.3. Building and Deploying the Booster

2.5.3.1. Deploying the Booster to a Single-node OpenShift Cluster2.5.3.1.1. Deploying Using developers.redhat.com/launch2.5.3.1.2. Deploying Using the oc CLI Client

2.5.3.2. Deploying your Booster to OpenShift Online2.5.4. Interacting with the Unmodified WildFly Swarm Booster2.5.5. Running Integration Tests2.5.6. Using Hystrix Dashboard to Monitor the Circuit Breaker2.5.7. Circuit Breaker Resources

4

5

667777999

1010101111111113131414161616161818

20202122222222232425252626272727272929313132

Table of Contents

1

Page 6: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

APPENDIX A. THE SOURCE-TO-IMAGE (S2I) BUILD PROCESS

APPENDIX B. BREAKDOWN OF POM COMPONENTS

APPENDIX C. ADDITIONAL RESOURCES

APPENDIX D. PROFICIENCY LEVELSFoundationalAdvancedExpert

APPENDIX E. GLOSSARYE.1. PRODUCT AND PROJECT NAMESE.2. TERMS SPECIFIC TO DEVELOPERS.REDHAT.COM/LAUNCH

33

34

38

39393939

404040

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

2

Page 7: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Table of Contents

3

Page 8: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

PREFACEThis guide covers concepts as well as practical details needed by developers to use the WildFly Swarmruntime.

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

4

Page 9: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

CHAPTER 1. RUNTIME DETAILSWildFly Swarm deconstructs the features in WildFly Java Application Server and allows them to beselectively reconstructed based on the needs of your application. This allows you to createmicroservices that run on a just-enough-appserver that supports the exact subset of APIs you need.Check out Additional Resources for further reading on WildFly Swarm.

The WildFly Swarm runtime enables you to run WildFly Swarm applications and services in OpenShiftwhile providing all the advantages and conveniences of the OpenShift platform such as rolling updates,service discovery, and canary deployments. OpenShift also makes it easier for your applications toimplement common microservice patterns such as ConfigMap, HealthCheck, Circuit Breaker, andFailover.

WildFly Swarm has a product version of its runtime that runs on OpenShift and is provided as part of aRed Hat subscription.

IMPORTANT

WildFly Swarm has a community version of its runtime that runs on OpenShift and isprovided outside of a Red Hat subscription.

CHAPTER 1. RUNTIME DETAILS

5

Page 10: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

CHAPTER 2. MISSIONSMissions are working applications that showcase different fundamental pieces of building cloud nativeapplications and services, such as creating HTTP APIs, interoperating with a database, or implementingthe health check pattern. A booster is the implementation of a mission in a specific runtime. Boostersare preconfigured, functioning applications based on a mission that demonstrate a fundamental aspectof modern application development running in an environment similar to production. Missions andboosters can be used as a proof of technology demonstration, a teaching tool, or even a sandbox forunderstanding how to develop applications. They can also be updated or extended for your own usecase.

NOTE

Each mission has different boosters that show how to implement the same mission indifferent runtimes. For example, the REST API Level 0 mission has a Spring Boot Tomcatbooster, a Eclipse Vert.x booster, and a WildFly Swarm booster.

2.1. REST API LEVEL 0 MISSION - WILDFLY SWARM BOOSTER

Mission proficiency level: Foundational.

The REST API Level 0 Mission provides a basic example of mapping business operations to a remoteprocedure call endpoint over HTTP using a REST framework. This corresponds to Level 0 in theRichardson Maturity Model. Creating an HTTP endpoint using REST and its underlying principals todefine your API enables you to quickly prototype and design your API in a flexible manner. Morebackground information on REST is available in Section 2.1.3, “REST Resources”.

This is an introduction to the mechanics of opening a service that is called remotely. Specifically, thisbooster is an application that allows a user to:

Execute an HTTP GET request on the api/greeting endpoint.

Receive a response in JSON format with a payload consisting of the Hello, World! String.

Execute an HTTP GET request on the api/greeting endpoint while passing in a Stringargument. This uses the name request parameter in the query string.

Receive a response in JSON format with a payload of Hello, $name! with $name replacedby the value of the name parameter passed into the request.

NOTE

To view the source code and README file of this booster, download and extract the ZIPfile with the booster. To get the download link of the ZIP file, follow the instructions inthe Using OpenShift to Create a Booster chapter of the Getting Started Guide.

Table 2.1. Design Tradeoffs

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

6

Page 11: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Pros Cons

Fast prototyping

Flexible API Design

HTTP endpoints allow clients to belanguage agnostic

As an application or service matures, theREST API Level 0 approach may not scalewell to properly support a clean API designor use cases involving databaseinteractions. Any operations involvingshared, mutable state must be integratedwith an appropriate backing datastore. Allrequests handled by an API designed in thismanner will be scoped only to the containerservicing the request. Therefore there is noguarantee that subsequent requests will beserved by the same container.

2.1.1. Building and Deploying the Booster

2.1.1.1. Deploying the Booster to a Single-node OpenShift Cluster

1. Before you can use a Single-node OpenShift Cluster, you need to have it installed, configured,and running. You can find more details in Install and Configure a Single-node OpenShiftCluster.

2. Once you have a Single-node OpenShift Cluster running, check the console output for the URLyou can use to access it.

Example Console Output from a Single-node OpenShift Cluster Startup

2.1.1.1.1. Deploying Using developers.redhat.com/launch

Once you have the developers.redhat.com/launch application installed and configured, navigate to it inyour Single-node OpenShift Cluster and use it to create and launch your booster.

2.1.1.1.2. Deploying Using the oc CLI Client

...-- Removing temporary directory ... OK-- Server Information ... OpenShift server started. The server is accessible via web console at: https://192.168.42.152:8443

You are logged in as: User: developer Password: developer

To login as administrator: oc login -u system:admin

CHAPTER 2. MISSIONS

7

Page 12: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

IMPORTANT

You must still create a booster using the developers.redhat.com/launch applicationbefore you can deploy it using the oc CLI client.

If you choose I will build and run locally, unzip the ZIP file you downloaded. If you choseUse OpenShift Online to build and deploy you need to clone the GitHub repository createdby developers.redhat.com/launch.

1. Get the command containing your authentication token for using the oc CLI client with yourSingle-node OpenShift Cluster account:

a. Click on the question mark icon in the top right-hand corner of the Web console, next toyour user name.

b. Select Command Line Tools in the drop-down menu.

c. Find the text box that contains the oc login … command with the hidden token, andclick the button next to it to copy its content to your clipboard.

2. Paste the command you copied in the previous step into a terminal to authenticate your oc CLIclient with your Single-node OpenShift Cluster account by using your authentication token.

3. Create a new project in Single-node OpenShift Cluster.

4. Navigate to the root directory of your booster.

5. Use maven to start the deployment to Single-node OpenShift Cluster.

This command uses the Fabric8 Maven Plugin to launch the S2I process on Single-nodeOpenShift Cluster and to start the pod.

6. Check the status of your booster and ensure your pod is running.

You MY_APP_NAME-1-aaaaa pod should have a status of Running once its fully deployed andstarted.

7. Once your booster is deployed and started, determine its route.

Example Route Information

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc new-project MY_PROJECT_NAME

$ mvn clean fabric8:deploy -Popenshift

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-aaaaa 1/1 Running 0 58sMY_APP_NAME-s2i-1-build 0/1 Completed 0 2m

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

8

Page 13: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

A pod’s route information gives you the base URL which you use to access it. In the exampleabove, you would use http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME as the base URL to access theapplication.

2.1.1.2. Deploying your Booster to OpenShift Online

Navigate to developers.redhat.com/launch and use it to create and launch your booster. You can alsouse the oc CLI Client to deploy a booster to OpenShift Online. To use the oc CLI Client with OpenShiftOnline, you follow the same steps as with your Single-node OpenShift Cluster but use theauthentication token and URL from the OpenShift Online Web Console.

2.1.2. Interacting with the Unmodified WildFly Swarm Booster

The booster provides a default HTTP endpoint that accepts GET requests.

1. Use curl to execute a GET request against the booster. You can also use a browser to do this.

2. Use curl to execute a GET request with the name URL parameter against the booster. You canalso use a browser to do this.

NOTE

From a browser you can also use a form provided by the booster to perform these sameinteractions. The form is located at the root of the project http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME.

2.1.3. REST Resources

More background and related information on REST can be found here:

Architectural Styles and the Design of Network-based Software Architectures -Representational State Transfer (REST)

Richardson Maturity Model

JSR 311: JAX-RS: The JavaTM API for RESTful Web Services

RESTEasy Documentation

$ oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATIONMY_APP_NAME MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME 8080

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello, World!"}

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting?name=Sarah{"content":"Hello, Sarah!"}

CHAPTER 2. MISSIONS

9

Page 14: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

REST API Level 0 Mission - Spring Boot Tomcat Booster

REST API Level 0 Mission - Eclipse Vert.x Booster

2.2. CONFIGMAP MISSION - WILDFLY SWARM BOOSTER

Mission proficiency level: Foundational.

The ConfigMap Mission provides a basic example of using ConfigMap to take advantage of externalconfiguration sources. This mission shows you how to:

Setup and configuration of ConfigMap.

Use the configuration provided by ConfigMap within an application.

Deploy changes to ConfigMap to applications that are already running.

2.2.1. About ConfigMap

ConfigMap is an object used by OpenShift to inject configuration data as simple key and value pairs intoone or more Linux containers while keeping the containers agnostic of OpenShift. You can create aConfigMap object in a variety of different ways, including using a YAML file, and inject it into the Linuxcontainer. You can find more information about ConfigMap in the OpenShift documentation.

2.2.2. Why ConfigMap is Important

It is important for an application’s configuration to be externalized and separate from it’s code. Thisallows for the application’s configuration to change as it moves through different environments whileleaving the code unchanged. This also keeps sensitive or internal information out of your codebase andversion control. Many languages and application servers provide environment variables to supportexternalizing an application’s configuration. Microservices and Linux containers increase thecomplexity of this by adding pods, or groups of containers representing a deployment, and polyglotenvironments. ConfigMap enables application configuration to be externalized and used in individualLinux containers and pods in a language agnostic way. ConfigMap also allows sets of configuration datato be easily grouped and scaled, which enables you to configure an arbitrarily large number ofenvironments beyond the basic Dev, Stage, and Production.

NOTE

To view the source code and README file of this booster, download and extract the ZIPfile with the booster. To get the download link of the ZIP file, follow the instructions inthe Using OpenShift to Create a Booster chapter of the Getting Started Guide.

Table 2.2. Design Tradeoffs

Pros Cons

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

10

Page 15: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Configuration is separate fromdeployments

Can be updated independently

Can be shared across services

Configuration is separate fromdeployments

Has to be maintained separately

Requires coordination beyond the scope ofa service

Pros Cons

2.2.3. Building and Deploying the Booster

2.2.3.1. Deploying the Booster to a Single-node OpenShift Cluster

1. Before you can use a Single-node OpenShift Cluster, you need to have it installed, configured,and running. You can find more details in Install and Configure a Single-node OpenShiftCluster.

2. Once you have a Single-node OpenShift Cluster running, check the console output for the URLyou can use to access it.

Example Console Output from a Single-node OpenShift Cluster Startup

2.2.3.1.1. Deploying Using developers.redhat.com/launch

Once you have the developers.redhat.com/launch application installed and configured, navigate to it inyour Single-node OpenShift Cluster and use it to create and launch your booster.

2.2.3.1.2. Deploying Using the oc CLI Client

...-- Removing temporary directory ... OK-- Server Information ... OpenShift server started. The server is accessible via web console at: https://192.168.42.152:8443

You are logged in as: User: developer Password: developer

To login as administrator: oc login -u system:admin

CHAPTER 2. MISSIONS

11

Page 16: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

IMPORTANT

You must still create a booster using the developers.redhat.com/launch applicationbefore you can deploy it using the oc CLI client.

If you choose I will build and run locally, unzip the ZIP file you downloaded. If you choseUse OpenShift Online to build and deploy you need to clone the GitHub repository createdby developers.redhat.com/launch.

1. Get the command containing your authentication token for using the oc CLI client with yourSingle-node OpenShift Cluster account:

a. Click on the question mark icon in the top right-hand corner of the Web console, next toyour user name.

b. Select Command Line Tools in the drop-down menu.

c. Find the text box that contains the oc login … command with the hidden token, andclick the button next to it to copy its content to your clipboard.

2. Paste the command you copied in the previous step into a terminal to authenticate your oc CLIclient with your Single-node OpenShift Cluster account by using your authentication token.

3. Create a new project in your Single-node OpenShift Cluster.

4. Navigate to the root directory of your booster.

5. Deploy your ConfigMap configuration to your Single-node OpenShift Cluster using app-config.yml in the root of the booster.

6. Verify your ConfigMap configuration has been deployed.

7. Use Maven to start the deployment to your Single-node OpenShift Cluster.

This command uses the Fabric8 Maven Plugin to launch the S2I process on your Single-nodeOpenShift Cluster and to start the pod.

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc new-project MY_PROJECT_NAME

$ oc create configmap app-config --from-file=app-config.yml

$ oc get configmap app-config -o yaml

apiVersion: v1data: app-config.yml: |- greeting: message: Hello %s from a ConfigMap!...

$ mvn clean fabric8:deploy -Popenshift -DskipTests

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

12

Page 17: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

8. Check the status of your booster and ensure your pod is running.

Your MY_APP_NAME-1-aaaaa pod should have a status of Running once its fully deployedand started.

9. Once your booster is deployed and started, determine its route.

Example Route Information

A pod’s route information gives you the base URL which you use to access it. In the exampleabove, you would use http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME as the base URL to access theapplication.

2.2.3.2. Deploying your Booster to OpenShift Online

Navigate to developers.redhat.com/launch and use it to create and launch your booster. You can alsouse the oc CLI Client to deploy a booster to OpenShift Online. To use the oc CLI Client with OpenShiftOnline, you follow the same steps as with your Single-node OpenShift Cluster but use theauthentication token and URL from the OpenShift Online Web Console.

2.2.4. Interacting with the Unmodified WildFly Swarm Booster

The booster provides a default HTTP endpoint that accepts GET requests.

1. Use curl to execute a GET request against the booster. You can also use a browser to do this.

2. Update the deployed ConfigMap configuration.

Change the value for the greeting.message key to Bonjour %s from a ConfigMap!and save the file. After you save this, the changes will be propagated to your OpenShiftinstance.

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-aaaaa 1/1 Running 0 58sMY_APP_NAME-s2i-1-build 0/1 Completed 0 2m

$ oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATIONMY_APP_NAME MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME 8080

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello World from a ConfigMap!"}

$ oc edit configmap app-config

CHAPTER 2. MISSIONS

13

Page 18: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

3. Rollout the new version of your application so the ConfigMap configuration changes are pickedup.

4. Check the status of your booster and ensure your new pod is running.

You MY_APP_NAME-1-aaaaa pod should have a status of Running once its fully deployed andstarted.

5. Use curl to execute a GET request against the booster with the updated ConfigMapconfiguration. You can also use a browser to do this.

You should see your updated greeting.

2.2.5. ConfigMap Resources

More background and related information on ConfigMap can be found here:

OpenShift ConfigMap Documentation

Blog Post about ConfigMap in OpenShift

External Configuration with WildFly Swarm

ConfigMap - Spring Boot Tomcat Booster

ConfigMap - Eclipse Vert.x Booster

2.3. RELATIONAL DATABASE BACKEND MISSION - WILDFLY SWARMBOOSTER

IMPORTANT

This booster is not currently available on OpenShift Online but you can still run it using aSingle-node OpenShift Cluster.

Mission proficiency level: Foundational.

The Relational Database Backend booster expands on the REST API Level 0 booster to provide a basicexample of performing create, read, update and delete (CRUD) operations on a PostgreSQL databaseusing a simple HTTP API. CRUD operations are the four basic functions of persistent storage, widelyused when developing an HTTP API dealing with a database.

$ oc rollout latest dc/MY_APP_NAME

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-aaaaa 1/1 Running 0 58sMY_APP_NAME-s2i-1-build 0/1 Completed 0 2m

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Bonjour World from a ConfigMap!"}

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

14

Page 19: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

The booster also demonstrates the ability of the HTTP application to locate and connect to a databasein OpenShift. Each runtime determines in an opinionated manner how to implement the connectivitysolution that is best suited in the given case. The runtime can choose between using JDBC, JPA, oraccess ORM APIs directly.

The booster application exposes an HTTP API, which provides endpoints that allow you to manipulatedata by performing CRUD operations over HTTP. The CRUD operations are mapped to HTTP Verbs.The API uses JSON formatting to receive requests and return responses to the user. The user can alsouse an UI provided by the booster to use the application. Specifically, this booster provides anapplication that allows you to:

Navigate to the application web interface in your browser. This exposes a simple websiteallowing you to perform CRUD operations on the data in the my_data database.

Execute an HTTP GET request on the api/fruits endpoint.

Receive a response formatted as a JSON array containing the list of all fruits in the database.

Execute an HTTP GET request on the api/fruits/* endpoint while passing in a valid item IDas an argument.

Receive a response in JSON format containing the name of the fruit with the given ID. If noitem matches the specified ID, the call results in an HTTP error 404.

Execute an HTTP POST request on the api/fruits endpoint passing in a valid name value tocreate a new entry in the database.

Execute an HTTP PUT request on the api/fruits/* endpoint passing in a valid ID and aname as an argument. This updates the name of the item with the given ID to match the namespecified in your request.

Execute an HTTP DELETE request on the api/fruits/* endpoint, passing in a valid ID as anargument. This removes the item with the specified ID from the database and returns an HTTPcode 204 (No Content) as a response. If you pass in an invalid ID, the call results in an HTTPerror 404.

This booster also contains a set of automated integration test that can be used to verify that theapplication is fully integrated with the database.

This booster does not showcase a fully matured RESTful model (level 3), but it does use compatibleHTTP verbs and status, following the recommended HTTP API practices.

NOTE

To view the source code and README file of this booster, download and extract the ZIPfile with the booster. To get the download link of the ZIP file, follow the instructions inthe Using OpenShift to Create a Booster chapter of the Getting Started Guide.

Table 2.3. Design Tradeoffs

CHAPTER 2. MISSIONS

15

Page 20: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Pros Cons

Each runtime decides how the databaseinteractions are implemented. One can useJDBC while others can use JPA or accessORM APIs directly. Each runtime decideswhat would be the best way.

Each runtime decides how the schema isgoing to be created.

The example PostgreSQL databaseprovided with the Relational DatabaseBackend Missions is not backed up withpersistent storage. Changes to thedatabase are lost if you stop or redeploy thedatabase application.

2.3.1. Building and Deploying the Booster

2.3.1.1. Deploying the Booster to a Single-node OpenShift Cluster

1. Before you can use a Single-node OpenShift Cluster, you need to have it installed, configured,and running. You can find more details in Install and Configure a Single-node OpenShiftCluster.

2. Once you have a Single-node OpenShift Cluster running, check the console output for the URLyou can use to access it.

Example Console Output from a Single-node OpenShift Cluster Startup

2.3.1.1.1. Deploying Using developers.redhat.com/launch

Once you have the developers.redhat.com/launch application installed and configured, navigate to it inyour Single-node OpenShift Cluster and use it to create and launch your booster.

2.3.1.1.2. Deploying Using the oc CLI Client

...-- Removing temporary directory ... OK-- Server Information ... OpenShift server started. The server is accessible via web console at: https://192.168.42.152:8443

You are logged in as: User: developer Password: developer

To login as administrator: oc login -u system:admin

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

16

Page 21: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

IMPORTANT

You must still create a booster using the developers.redhat.com/launch applicationbefore you can deploy it using the oc CLI client.

If you choose I will build and run locally, unzip the ZIP file you downloaded. If you choseUse OpenShift Online to build and deploy you need to clone the GitHub repository createdby developers.redhat.com/launch.

1. Get the command containing your authentication token for using the oc CLI client with yourSingle-node OpenShift Cluster account:

a. Click on the question mark icon in the top right-hand corner of the Web console, next toyour user name.

b. Select Command Line Tools in the drop-down menu.

c. Find the text box that contains the oc login … command with the hidden token, andclick the button next to it to copy its content to your clipboard.

2. Paste the command you copied in the previous step into a terminal to authenticate your oc CLIclient with your Single-node OpenShift Cluster account by using your authentication token.

3. Create a new project in your Single-node OpenShift Cluster.

4. Navigate to the root directory of your booster.

5. Deploy the PostgreSQL database to your Single-node OpenShift Cluster.

6. Check the status of your database and ensure the pod is running.

Your my-database-1-aaaaa pod should have a status of Running and should be indicated asready once it is fully deployed and started.

7. Use maven to start the deployment to Single-node OpenShift Cluster.

This command uses the Fabric8 Maven Plugin to launch the S2I process on your Single-nodeOpenShift Cluster and to start the pod.

8. Check the status of your booster and ensure your pod is running.

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc new-project MY_PROJECT_NAME

$ oc new-app -e POSTGRESQL_USER=luke -ePOSTGRESQL_PASSWORD=secret -ePOSTGRESQL_DATABASE=my_data openshift/postgresql-92-centos7 --name=my-database

$ oc get pods -wmy-database-1-aaaaa 1/1 Running 0 45smy-database-1-deploy 0/1 Completed 0 53s

$ mvn clean fabric8:deploy -Popenshift

CHAPTER 2. MISSIONS

17

Page 22: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Your MY_APP_NAME-1-aaaaa pod should have a status of Running and should be indicated asready once it is fully deployed and started.

9. Once your booster is deployed and started, determine its route.

Example Route Information

A pod’s route information gives you the base URL which you use to access it. In the exampleabove, you would use http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME as the base URL to access theapplication.

2.3.1.2. Deploying your Booster to OpenShift Online

Navigate to developers.redhat.com/launch and use it to create and launch your booster. You can alsouse the oc CLI Client to deploy a booster to OpenShift Online. To use the oc CLI Client with OpenShiftOnline, you follow the same steps as with your Single-node OpenShift Cluster but use theauthentication token and URL from the OpenShift Online Web Console.

2.3.2. Interacting with the Application API

1. Once the application is running, you can access it using the application URL. To obtain the URL,execute the following command:

2. To access the web interface of the database application, navigate to the application URL in yourbrowser:

Alternatively, you can make requests directly on the api/fruits/* endpoint using curl:

List all entries in the database:

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-aaaaa 1/1 Running 0 58sMY_APP_NAME-s2i-1-build 0/1 Completed 0 2m

$ oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATIONMY_APP_NAME MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME 8080

oc get route MY_APP_NAME

NAME HOST/PORT PATH SERVICES PORT TERMINATIONMY_APP_NAME MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME 8080

http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

18

Page 23: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

[ { "id" : 1, "name" : "Apple",}, { "id" : 2, "name" : "Orange",}, { "id" : 3, "name" : "Pear",} ]

Retrieve an entry with a specific ID

{ "id" : 3, "name" : "Pear",}

Create a new entry:

{ "id" : 4, "name" : "apple",}

Update an Entry

{ "id" : 1, "name" : "pineapple",}

Delete an Entry:

curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/fruits

curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/fruits/3

curl -H "Content-Type: application/json" -X POST -d '{"name":"apple"}' http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/fruits

curl -H "Content-Type: application/json" -X PUT -d '{"name":"pineapple"}' http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/fruits/1

curl -X DELETE http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/fruits/1

CHAPTER 2. MISSIONS

19

Page 24: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

If you receive an HTTP Error code 503 as a response after executing these commands, it means thatthe application is not ready yet.

2.3.3. Running Integration Tests

This booster includes a self-contained set of integration tests. When you run the tests inside an emptyOpenShift project, they:

deploy a test instance of the application to the project,

execute the individual tests on that instance,

remove the test instance of the application from the project when the testing is done.

Before running the tests, ensure that you:

are logged into your OpenShift account,

have selected a project within that account.

WARNING

Running the integration tests in an OpenShift project already containing aninstance of the tested application removes the pre-existing instance of theapplication from the project when the testing finishes.

To run the integration tests, execute the following command:

2.3.4. Relational Database Resources

More background and related information on running relational databases in OpenShift, CRUD, HTTPAPI and REST can be found here:

HTTP Verbs

Architectural Styles and the Design of Network-based Software Architectures -Representational State Transfer (REST)

The never ending REST API design debase

REST APIs must be Hypertext driven

Richardson Maturity Model

JSR 311: JAX-RS: The JavaTM API for RESTful Web Services

RESTEasy Documentation

Relational Database Backend Mission - Spring Boot Tomcat Booster

mvn clean verify -Popenshift,openshift-it

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

20

Page 25: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Relational Database Backend Mission - Eclipse Vert.x Booster

2.4. HEALTH CHECK MISSION - WILDFLY SWARM BOOSTER

Mission proficiency level: Foundational.

When you deploy an application, its important to know if it is available and if it can start handlingincoming requests. Implementing the health check pattern allows you to monitor the health of anapplication, which includes if an application is available and whether it is able to service requests.

In order to understand the health check pattern, you need to first understand the following concepts:

Liveness

Liveness defines whether an application is running or not. Sometimes a running application movesinto an unresponsive or stopped state and needs to be restarted. Checking for liveness helpsdetermine whether or not an application needs to be restarted.

Readiness

Readiness defines whether a running application can service requests. Sometimes a runningapplication moves into an error or broken state where it can no longer service requests. Checkingreadiness helps determine whether or not requests should continue to be routed to thatapplication.

Fail-over

Fail-over enables failures in servicing requests to be handled gracefully. If an application fails toservice a request, that request and future requests can then fail-over or be routed to anotherapplication, which is usually a redundant copy of that same application.

Resilience and Stability

Resilience and Stability enable failures in servicing requests to be handled gracefully. If anapplication fails to service a request due to connection loss, in a resilient system that request canbe retried after the connection is re-established.

Probe

A probe is a Kubernetes action that periodically performs diagnostics on a running container.

The purpose of this use case is to demonstrate the health check pattern through the use of probing.Probing is used to report the liveness and readiness of an application. In this use case, you configurean application which exposes an HTTP health endpoint to issue HTTP requests. If the container isalive, according to the liveness probe on the health HTTP endpoint, the management platformreceives 200 as return code and no further action is required. If the health HTTP endpoint does notreturn a response, for example if the JVM is no longer running or a thread is blocked, then theapplication is not considered alive according to the liveness probe. In that case, the platform kills thepod corresponding to that application and recreates a new pod to restart the application.

This use case also allows you to demonstrate and use a readiness probe. In cases where the applicationis running but is unable to handle requests, such as when the application returns an HTTP 503response code during restart, this application is not considered ready according to the readinessprobe. If the application is not considered ready by the readiness probe, requests are not routed to thatapplication until it is considered ready according to the readiness probe.

NOTE

To view the source code and README file of this booster, download and extract the ZIPfile with the booster. To get the download link of the ZIP file, follow the instructions inthe Using OpenShift to Create a Booster chapter of the Getting Started Guide.

CHAPTER 2. MISSIONS

21

Page 26: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

2.4.1. Building and Deploying the Booster

2.4.1.1. Deploying the Booster to a Single-node OpenShift Cluster

1. Before you can use a Single-node OpenShift Cluster, you need to have it installed, configured,and running. You can find more details in Install and Configure a Single-node OpenShiftCluster.

2. Once you have a Single-node OpenShift Cluster running, check the console output for the URLyou can use to access it.

Example Console Output from a Single-node OpenShift Cluster Startup

2.4.1.1.1. Deploying Using developers.redhat.com/launch

Once you have the developers.redhat.com/launch application installed and configured, navigate to it inyour Single-node OpenShift Cluster and use it to create and launch your booster.

2.4.1.1.2. Deploying Using the oc CLI Client

IMPORTANT

You must still create a booster using the developers.redhat.com/launch applicationbefore you can deploy it using the oc CLI client.

If you choose I will build and run locally, unzip the ZIP file you downloaded. If you choseUse OpenShift Online to build and deploy you need to clone the GitHub repository createdby developers.redhat.com/launch.

1. Get the command containing your authentication token for using the oc CLI client with yourSingle-node OpenShift Cluster account:

a. Click on the question mark icon in the top right-hand corner of the Web console, next toyour user name.

b. Select Command Line Tools in the drop-down menu.

c. Find the text box that contains the oc login … command with the hidden token, andclick the button next to it to copy its content to your clipboard.

...-- Removing temporary directory ... OK-- Server Information ... OpenShift server started. The server is accessible via web console at: https://192.168.42.152:8443

You are logged in as: User: developer Password: developer

To login as administrator: oc login -u system:admin

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

22

Page 27: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

2. Paste the command you copied in the previous step into a terminal to authenticate your oc CLIclient with your Single-node OpenShift Cluster account by using your authentication token.

3. Create a new project in your Single-node OpenShift Cluster.

4. Navigate to the root directory of your booster.

5. Use maven to start the deployment to Single-node OpenShift Cluster.

This command uses the Fabric8 Maven Plugin to launch the S2I process on Single-nodeOpenShift Cluster and to start the pod.

6. Check the status of your booster and ensure your pod is running.

Your MY_APP_NAME-1-aaaaa pod should have a status of Running once it’s fully deployedand started. You should also wait for your pod to be ready before proceeding, which is shown inthe READY column. For example, PROJECT_NAME-1-aaaaa is ready when the READY columnis 1/1.

7. Once your booster is deployed and started, determine its route.

Example Route Information

A pod’s route information gives you the base URL which you use to access it. In the exampleabove, you would use http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME as the base URL to access theapplications.

2.4.1.2. Deploying your Booster to OpenShift Online

Navigate to developers.redhat.com/launch and use it to create and launch your booster. You can alsouse the oc CLI Client to deploy a booster to OpenShift Online. To use the oc CLI Client with OpenShiftOnline, you follow the same steps as with your Single-node OpenShift Cluster but use theauthentication token and URL from the OpenShift Online Web Console.

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc new-project MY_PROJECT_NAME

$ mvn clean fabric8:deploy -Popenshift

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-aaaaa 1/1 Running 0 14sMY_APP_NAME-1-deploy 0/1 Completed 0 22s

$ oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARDMY_APP_NAME MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME 8080 None

CHAPTER 2. MISSIONS

23

Page 28: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

2.4.2. Interacting with the Unmodified WildFly Swarm Booster

Once you have the WildFly Swarm booster deployed, you will have a service called MY_APP_NAMErunning that exposes a two REST endpoints: /api/greeting which returns a name as a String and /api/killme, which forces the service to become unresponsive as means to simulate a failure.

In the following we demonstrate the basic interactions on the command line that can be used verify theservice availability and simulate a failure that causes the OpenShift self-healing capabilities to betrigger on the service. Alternatively you can use the service web interface to perform these steps (See#4).

1. Use curl to execute a GET request against the MY_APP_NAME service. You can also use abrowser to do this.

2. To simulate a service internal failure and to trigger the OpenShift selfhealing capabilities,invoke the /api/killme endpoint and verify the availability of the /api/greeting endpointshortly after that. It should return a HTTP status 503:

3. While performing these operations you can use the OpenShift console, or the oc client tools towatch the self-healing capabilities in action. Use oc get pods -w to continuously watch theservice state from another terminal window. You should see that number pods in a READY statemoves to zero (0/1) and after a while (~30 sec to 1 min) back up to one ( 1/1). In addition the RESTARTS count increases every time you kill the service:

4. Alternatively to the interaction using the terminal window, you can use the web interfaceprovided by the service to invoke the different methods and watch the service move throughthe life cycle phases:

1. Optional: Use the web console to view the log output generated by the application at eachstage of the self-healing process.

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello, World!"}

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/killme

(followed by)

$ curl http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting

<html> <head><title>Error</title></head> <body>503 - Service Unavailable</body></html>

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-1-26iy7 0/1 Running 5 18mMY_APP_NAME-1-26iy7 1/1 Running 5 19m

$ http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

24

Page 29: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

1. Navigate to your project.

2. On the sidebar, click on Monitoring.

3. In the upper right-hand corner of the screen, click on Events to display the log messages.

4. Optional: Click View Details to display a detailed view of the Event log.

The health check application generates the following messages:

Message Status

Unhealthy Readiness probe failed. This message is expectedand indicates that the simulated failure of the /api/greeting endpoint has been detected andthe self-healing process starts.

Killing The unavailable Docker container running theservice is being killed before being re-created.

Pulling Downloading the latest version of docker image tore-create the container.

Pulled Docker image downloaded successfully.

Created Docker container has been successfully created

Started Docker container is ready to handle requests

2.4.3. Health Check Resources

More background and related information on health checking can be found here:

Overview of Application Health in OpenShift

Health Checking in Kubernetes

Kubernetes Liveness and Readiness Probes

Kubernetes Probes

Health Check - Spring Boot Tomcat Booster

Health Check - Eclipse Vert.x Booster

2.5. CIRCUIT BREAKER MISSION - WILDFLY SWARM BOOSTER

IMPORTANT

This booster is not currently available on OpenShift Online but you can still run it using aSingle-node OpenShift Cluster.

CHAPTER 2. MISSIONS

25

Page 30: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Mission proficiency level: Foundational.

The Circuit Breaker Mission demonstrates a generic pattern for reporting the failure of a service andthen limiting access to the failed service until it becomes available to handle requests. This helpsprevent cascading failure in other services that depend on the failed services for functionality.

This mission shows you how to implement a Circuit Breaker and Fallback pattern in your services.

2.5.1. About Circuit Breaker

The Circuit Breaker is a pattern intended to mitigate the impact of network failure and high latency onservice architectures where services synchronously invoke other services. In such cases, if one of theservices becomes unavailable due to network failure or incurs unusually high latency values due tooverwhelming traffic, other services attempting to call its endpoint may end up exhausting criticalresources in an attempt to reach it, rendering themselves unusable. This condition is also known ascascading failure and can render the entire microservice architecture unusable.

Essentially, the Circuit Breaker acts as a proxy between a protected function and a remote function,which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips, andall further calls to the circuit breaker return with an error or a predefined fallback response, withoutthe protected call being made at all. The Circuit Breaker usually also contain an error reportingmechanism that notifies you when the Circuit Breaker trips.

2.5.2. Why Circuit Breaker is Important

In an architecture where multiple services depend on each other for functionality, a failure in oneservice can rapidly propagate to its dependent services, causing the entire architecture to collapse.Implementing a Circuit Breaker pattern helps prevent this. With the Circuit Breaker patternimplemented, a service client invokes a remote service endpoint via a proxy at regular intervals. If thecalls to the remote service endpoint fail repeatedly and consistently, the Circuit Breaker trips, makingall calls to the service fail immediately over a set timeout period and returns a predefined fallbackresponse. When the timeout period expires, a limited number of test calls are allowed to pass throughto the remote service to determine whether it has healed, or remains unavailable. If these test calls fail,the Circuit Breaker keeps the service unavailable and keeps returning the fallback responses toincoming calls. If the test calls succeed, the Circuit Breaker closes, fully enabling traffic to reach theremote service again.

NOTE

To view the source code and README file of this booster, download and extract the ZIPfile with the booster. To get the download link of the ZIP file, follow the instructions inthe Using OpenShift to Create a Booster chapter of the Getting Started Guide.

Table 2.4. Design Tradeoffs

Pros Cons

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

26

Page 31: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

Enables a service to handle the failure ofother services it invokes.

Optimizing the timeout values can bechallenging

Larger-than-necessary timeout valuesmay generate excessive latency.

Smaller-than-necessary timeoutvalues may introduce false positives.

Pros Cons

2.5.3. Building and Deploying the Booster

2.5.3.1. Deploying the Booster to a Single-node OpenShift Cluster

1. Before you can use a Single-node OpenShift Cluster, you need to have it installed, configured,and running. You can find more details in Install and Configure a Single-node OpenShiftCluster.

2. Once you have a Single-node OpenShift Cluster running, check the console output for the URLyou can use to access it.

Example Console Output from a Single-node OpenShift Cluster Startup

2.5.3.1.1. Deploying Using developers.redhat.com/launch

Once you have the developers.redhat.com/launch application installed and configured, navigate to it inyour Single-node OpenShift Cluster and use it to create and launch your booster.

2.5.3.1.2. Deploying Using the oc CLI Client

...-- Removing temporary directory ... OK-- Server Information ... OpenShift server started. The server is accessible via web console at: https://192.168.42.152:8443

You are logged in as: User: developer Password: developer

To login as administrator: oc login -u system:admin

CHAPTER 2. MISSIONS

27

Page 32: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

IMPORTANT

You must still create a booster using the developers.redhat.com/launch applicationbefore you can deploy it using the oc CLI client.

If you choose I will build and run locally, unzip the ZIP file you downloaded. If you choseUse OpenShift Online to build and deploy you need to clone the GitHub repository createdby developers.redhat.com/launch.

1. Get the command containing your authentication token for using the oc CLI client with yourSingle-node OpenShift Cluster account:

a. Click on the question mark icon in the top right-hand corner of the Web console, next toyour user name.

b. Select Command Line Tools in the drop-down menu.

c. Find the text box that contains the oc login … command with the hidden token, andclick the button next to it to copy its content to your clipboard.

2. Paste the command you copied in the previous step into a terminal to authenticate your oc CLIclient with your Single-node OpenShift Cluster account by using your authentication token.

3. Create a new project in your Single-node OpenShift Cluster.

4. Navigate to the root directory of your booster.

5. Use Maven to start the deployment to your Single-node OpenShift Cluster.

This command uses the Fabric8 Maven Plugin to launch the S2I process on your Single-nodeOpenShift Cluster and to start the pod.

6. Check the status of your booster and ensure your pod is running.

Both the MY_APP_NAME-greeting-1-aaaaa and MY_APP_NAME-name-1-aaaaa podsshould have a status of Running once they are fully deployed and started. You should also waitfor your pods to be ready before proceeding, which is shown in the READY column. For

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc new-project MY_PROJECT_NAME

$ mvn clean fabric8:deploy -Popenshift

$ oc get pods -wNAME READY STATUS RESTARTS AGEMY_APP_NAME-greeting-1-aaaaa 1/1 Running 0 17sMY_APP_NAME-greeting-1-deploy 0/1 Completed 0 22sMY_APP_NAME-name-1-aaaaa 1/1 Running 0 14sMY_APP_NAME-name-1-deploy 0/1 Completed 0 28s

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

28

Page 33: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

example, PROJECT_NAME-1-aaaaa is ready when the READY column is 1/1.

7. Once your booster is deployed and started, determine its route.

Example Route Information

A pod’s route information gives you the base URL which you use to access it. In the exampleabove, you would use http://MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME as the base URL to access theapplications.

2.5.3.2. Deploying your Booster to OpenShift Online

Navigate to developers.redhat.com/launch and use it to create and launch your booster. You can alsouse the oc CLI Client to deploy a booster to OpenShift Online. To use the oc CLI Client with OpenShiftOnline, you follow the same steps as with your Single-node OpenShift Cluster but use theauthentication token and URL from the OpenShift Online Web Console.

2.5.4. Interacting with the Unmodified WildFly Swarm Booster

Once you have the WildFly Swarm booster deployed, you have the following services running:

MY_APP_NAME-name

Exposes the following endpoints:

the /api/name endpoint, which returns a name when this service is working, and an errorwhen this service is set up to demonstrate failure.

the /api/state endpoint, which controls the behavior of the /api/name endpoint anddetermines whether the service works correctly or demonstrates failure.

MY_APP_NAME-greeting

Exposes the following endpoints:

the /api/greeting endpoint that you can call to get a personalized greeting response.When you call the /api/greeting endpoint, it issues a call against the /api/nameendpoint of the MY_APP_NAME-name service as part of processing your request. The callmade against the /api/name endpoint is protected by the Circuit Breaker.

If the remote endpoint is available, it responds with an HTTP code 200 and you receive thefollowing greeting:

{"content":"Hello, World!"}

$ oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARDMY_APP_NAME-greeting MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME-greeting 8080 NoneMY_APP_NAME-name MY_APP_NAME-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME MY_APP_NAME-name 8080 None

CHAPTER 2. MISSIONS

29

Page 34: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

If the remote endpoint is unavailable, it responds with an HTTP code 500 and you receive apredefined fallback response:

{"content":"Hello, Fallback!"}

the /api/cb-state endpoint, which returns the state of the Circuit Breaker. The state canbe open or closed.

The following steps demonstrate how to verify the service availability, simulate a failure and receive afallback response.

NOTE

The following steps use the command line to interact with the service. Alternatively, youcan use the web interface to perform the same steps.

1. Use curl to execute a GET request against the MY_APP_NAME-greeting service. You canalso use the Invoke button in the web interface to do this.

2. To simulate the failure of the MY_APP_NAME-name service you can:

use the Toggle button in the web interface.

scale the number of replicas of the pod running the MY_APP_NAME-name service down to0.

execute an HTTP PUT request against the /api/state endpoint of the MY_APP_NAME-name service to set its state to fail.

3. The Circuit Breaker state indicator in the web interface changes from CLOSED to OPEN and theCircuit Breaker issues the fallback response when you invoke the /api/greeting endpoint.

4. Restore the name MY_APP_NAME-name service to availability. To do this you can:

use the Toggle button in the web interface.

scale the number of replicas of the pod running the MY_APP_NAME-name service back upto 1.

$ curl http://MY_APP_NAME-greeting-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello, World!"}

$ curl -X PUT -H "Content-Type: application/json" -d '{"state": "fail"}' http://MY_APP_NAME-name-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/state

$ curl http://MY_APP_NAME-greeting-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello, Fallback!"}

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

30

Page 35: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

execute an HTTP PUT request against the /api/state endpoint of the MY_APP_NAME-name service to set its state back to ok.

5. Invoke the /api/greeting endpoint again. If the MY_APP_NAME-name service is available,you should receive the Hello World! greeting as the response:

2.5.5. Running Integration Tests

This booster contains a set of integration tests. To run them, you must be connected to an OpenShiftinstance and select the project that will be used for testing.

To run the integration tests, execute the following command:

2.5.6. Using Hystrix Dashboard to Monitor the Circuit Breaker

Hystrix Dashboard lets you easily monitor the health of your services in real time by aggregatingHystrix metrics data from an event stream and displaying them on one screen. For more detail, see theHystrix Dashboard wiki page.

NOTE

You must have the Circuit Breaker booster application deployed before proceeding withthe steps below.

1. Log in to your Single-node OpenShift Cluster cluster.

2. To access the Web console, use your browser to navigate to your Single-node OpenShiftCluster URL.

3. Navigate to the project that contains your Circuit Breaker application.

4. Import the YAML template for the Hystrix Dashboard application. You can do this by clickingAdd to Project, then selecting the Import YAML / JSON tab, and copying the contents of theYAML file into the text box. Alternatively, you can execute the following command.

$ curl -X PUT -H "Content-Type: application/json" -d '{"state": "ok"}' http://MY_APP_NAME-name-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/state

$ curl http://MY_APP_NAME-greeting-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/api/greeting{"content":"Hello, World!"}

$ mvn clean verify -Popenshift,openshift-it

$ oc login OPENSHIFT_URL --token=MYTOKEN

$ oc project MY_PROJECT_NAME

oc create -f https://raw.githubusercontent.com/snowdrop/openshift-templates/master/hystrix-dashboard/hystrix-dashboard.yml

CHAPTER 2. MISSIONS

31

Page 36: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

5. Click the Create button to create the Hystrix Dashboard application based on the template.Alternatively, you can execute the following command.

6. Wait for the pod containing Hystrix Dashboard to deploy.

7. Obtain the route of your Hystrix Dashboard application.

8. To access the Dashboard, open the Dashboard application route URL in your browser.Alternatively, you can navigate to the Overview screen in the Web console and click the routeURL in the header above the pod containing your Hystrix Dashboard application.

9. To use the Dashboard to monitor the MY_APP_NAME-greeting service, replace the defaultevent stream address with the following address and click the Monitor Stream button.

2.5.7. Circuit Breaker Resources

Follow the links below for more background information on the design principles behind the CircuitBreaker pattern

microservices.io: Microservice Patterns: Circuit Breaker

Martin Fowler: CircuitBreaker

Circuit Breaker Mission - Spring Boot Tomcat Booster

Circuit Breaker Mission - Eclipse Vert.x Booster

oc new-app --template=hystrix-dashboard

oc get route hystrix-dashboardNAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARDhystrix-dashboard hystrix-dashboard-MY_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME hystrix-dashboard <all> None

http://MY_APP_NAME-greeting/hystrix.stream

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

32

Page 37: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

APPENDIX A. THE SOURCE-TO-IMAGE (S2I) BUILD PROCESSSource-to-Image (S2I) is a build tool that allows you to generate reproducible Docker-formattedcontainer images from application sources hosted in an online SCM repository. With S2I builds you caneasily deliver the latest version of your application into production while achieving shorter build times,decreased resource and network usage, improved security and a number of advantages.

You need to provide three key elements as the input to the S2I process:

application sources (hosted in an online SCM repository, such as a Git Hub repo)

S2I scripts

the Builder image, which serves as the foundation for the assembled image and provides theecosystem within which your application is running

The process combines these inputs by injecting your application source and dependencies into theBuilder image according to instructions specified in the S2I script and generates a Docker-formattedcontainer image that runs the assembled application. For more detail, check the S2I buildrequirements and build options sections of the OpenShift Container Platform documentation .

APPENDIX A. THE SOURCE-TO-IMAGE (S2I) BUILD PROCESS

33

Page 38: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

APPENDIX B. BREAKDOWN OF POM COMPONENTS

wfswarm-rest-http/pom.xml

<?xml version="1.0" encoding="UTF-8"?><!-- ~ ~ Copyright 2016-2017 Red Hat, Inc, and individual contributors. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. ~ --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<parent> 1 <groupId>io.openshift</groupId> <artifactId>booster-parent</artifactId> <version>4</version> </parent>

<groupId>io.openshift.booster</groupId> <artifactId>wfswarm-rest-http</artifactId> <version>7-SNAPSHOT</version> <packaging>war</packaging>

<name>Simple HTTP Example</name> <description>WildFly Swarm - Rest</description>

<properties> 2 <version.wildfly.swarm>2017.6.0</version.wildfly.swarm> <version.resteasy>3.0.19.Final</version.resteasy> </properties>

<dependencyManagement> <dependencies> <dependency> <groupId>org.wildfly.swarm</groupId>

<artifactId>bom</artifactId> 3 <version>${version.wildfly.swarm}</version> <type>pom</type>

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

34

Page 39: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

<scope>import</scope> </dependency> </dependencies> </dependencyManagement>

<dependencies> <dependency> <groupId>org.wildfly.swarm</groupId>

<artifactId>jaxrs</artifactId> 4 </dependency>

<dependency> <groupId>org.jboss.resteasy</groupId>

<artifactId>resteasy-client</artifactId> 5 <version>${version.resteasy}</version> <scope>test</scope> </dependency>

<dependency> <groupId>org.wildfly.swarm</groupId>

<artifactId>arquillian</artifactId> 6 <scope>test</scope> </dependency>

<dependency> <groupId>org.jboss.arquillian.junit</groupId>

<artifactId>arquillian-junit-container</artifactId> 7 <version>1.1.12.Final</version> <scope>test</scope> </dependency> </dependencies>

<build> <plugins> <plugin> <groupId>org.wildfly.swarm</groupId>

<artifactId>wildfly-swarm-plugin</artifactId> 8 <version>${version.wildfly.swarm}</version> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin>

<plugin>

<artifactId>maven-war-plugin</artifactId> 9 <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build>

APPENDIX B. BREAKDOWN OF POM COMPONENTS

35

Page 40: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

1 Parent POM which contains the necessary dependencies and the required versions for thebooster projects.

<profiles> <profile>

<id>openshift</id> 10 <build> <plugins> <plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> <configuration> <generator> <includes> <include>wildfly-swarm</include> </includes> <excludes> <exclude>webapp</exclude> </excludes> </generator> </configuration> </plugin> </plugins> </build> </profile> <profile>

<id>openshift-it</id> 11 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles></project>

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

36

Page 41: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

2

3

4

5

6

7

8

9

10

11

Properties for setting the WildFly Swarm and RESTEasy version.

BOM for building WildFly Swarm applications with Maven.

Swarm Fraction that brings JAX-RS functionality for creating REST services.

RESTEasy client dependency for connecting to other REST services which is used in testing.

Swarm Fraction that brings Arquillian functionality for testing.

Arquillian APIs for testing with JUnit.

WildFly Swarm Maven Plugin used to create the application uberjar.

The Maven WAR Plugin collects all artifact dependencies, classes and resources of your webapplication, and packages them into a WAR file.

The profile for building and deploying the booster to OpenShift. It uses the Fabric8 Maven Plugin(FMP) to build and deploy the application with the S2I Build Process.

The profile for running integration tests when the application is deployed on OpenShift. Forexample, a test can require a database pod or a ConfigMap value.

APPENDIX B. BREAKDOWN OF POM COMPONENTS

37

Page 42: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

APPENDIX C. ADDITIONAL RESOURCESWildFly Swarm HowTo Guide

WildFly Swarm Reference

WildFly Swarm User Guide

WildFly Swarm Presentations

WildFly Swarm, Microservices & OpenShift Lab

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

38

Page 43: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

APPENDIX D. PROFICIENCY LEVELSEach mission available on developers.redhat.com/launch teaches you about certain topics, butrequires certain minimum knowledge, which varies by mission. For clarity, the minimum requirementsand concepts are organized in several proficiency levels. In addition to the levels described in thischapter, there can be additional requirements with each mission, specific to its aim or the technologiesit uses.

FoundationalThe missions rated at Foundational proficiency generally require no prior knowledge of the subjectmatter; they provide general awareness and demonstration of key elements, concepts, andterminology. There are no special requirements except those directly mentioned in the description ofthe mission.

AdvancedWhen using Advanced missions, the assumption is that you are familiar with the common concepts andterminology of the subject area of the mission in addition to Kubernetes and OpenShift. You must alsobe able to perform basic tasks on your own, for example configure services and applications, oradminister networks. If a service is needed by the mission, but configuring it is not in the scope of themission, the assumption is that you have the knowledge to to properly configure it, and only theresulting state of the service is described in the documentation.

ExpertExpert missions require the highest level of knowledge of the subject matter. You are expected toperform many tasks based on feature-based documentation and manuals, and the documentation isaimed at most complex scenarios.

APPENDIX D. PROFICIENCY LEVELS

39

Page 44: Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm ... · PDF fileUsing Hystrix Dashboard to Monitor the Circuit Breaker ... define your API enables you to quickly prototype

APPENDIX E. GLOSSARY

E.1. PRODUCT AND PROJECT NAMES

developers.redhat.com/launch

The web application you launch boosters with.

Single-node OpenShift Cluster

An OpenShift cluster running on your machine using Minishift.

E.2. TERMS SPECIFIC TO DEVELOPERS.REDHAT.COM/LAUNCH

Booster

An language-specific implementation of a particular mission on a particular runtime. Boosters arelisted in a booster catalog.For example, a booster is a web service with a REST API implemented using the WildFly Swarmruntime.

Booster Catalog

A Git repository that contains information about boosters.

Mission

An application specification, for example a web service with a REST API.Missions generally do not specify which language or platform they should run on; the descriptiononly contains the intended functionality.

Runtime

A platform that executes boosters. For example, WildFly Swarm or Eclipse Vert.x.

Red Hat OpenShift Application Runtimes 0.1 WildFly Swarm Runtime Guide

40