오픈시프트 기반 마이크로 서비스 아키텍처 샘플 애플리케이션입니다. 참고하여 주십시오. 
BUILDING MICROSERVICES ON OPENSHIFT CONTAINER PLATFORM WITH FUSE INTEGRATION SERVICES

Lab: Using Templates

Application description

In this lab, we’re going to deploy a complete backend application, consisting of an REST API backend and a mongo database. The complete application will already be wired together and described as a backend for the map visualization tool, so that once the application is build and deployed, you will be able to see the new map.

Application architecture

Background: Templates

Running all these individual commands can be tedious and error prone. Fortunately for you, all of this configuration can be put together into a single Template which can then be processed to create a full set of resources. As you saw with MongoDB, a Template may define parameters for certain values, such as DB username or password, and they can be automatically generated by OpenShift at processing time.

Administrators can load Templates into OpenShift and make them available to all users, even via the web console. Users can create Templates and load them into their own Projects for other users (with access) to share and use.

The great thing about Templates is that they can speed up the deployment workflow for application development by providing a "recipe" of sorts that can be deployed with a single command. Not only that, they can be loaded into OpenShift from an external URL, which will allow you to keep your templates in a version control system. And, even further, they can be stored in a version control system (even in the same repository as the application source code) — they’re just serialized text data!

Let’s combine all of the exercises we have performed in the last several labs by using a Template that we can instantiate with a single command. While we could have used templates to deploy everything in the workshop today, remember that it is important for you to understand how to create, deploy, and wire resources together.

Exercise: Instantiate a Template

The front end application we’ve been working with this whole time will display as many back end services' data as are created. Adding more stuff with the right Label will make more stuff show up on the map.

Now you will deploy a map of Major League Baseball stadiums in the US by using a template. It is pre-configured to build the back end Java application, and deploy the Mongo database. It also uses a Hook to call the /ws/data/load endpoint to cause the data to be loaded into the database from a JSON file in the source code repository. Execute the following command:

$ oc create -f https://raw.githubusercontent.com/openshift-roadshow/mlbparks/1.0.0/ose3/application-template-eap.json

What just happened? What did you just create? The item that we passed to the create command is a Template. create simply makes the template available in your Project. You can see this with the following command:

$ oc get template

You will see output like the following:

mlbparks      Application template MLBParks backend running on WildFly and using MongoDB   15 (5 blank)   8

Are you ready for the magic command? Here it is:

oc new-app mlbparks -p APPLICATION_NAME=mlbparks -p GIT_REF=1.0.0

You will see the following output:

--> Deploying template mlbparks

     mlbparks
     ---------
     Application template MLBParks backend running on WildFly and using MongoDB

     * With parameters:
        * Application Name=mlbparks
        * Application route=
        * Mongodb App=mongodb-mlbparks
        * Git source repository=https://github.com/openshift-roadshow/mlbparks
        * Git branch/tag reference=1.0.0
        * Database name=mongodb
        * MONGODB_NOPREALLOC=
        * MONGODB_SMALLFILES=
        * MONGODB_QUIET=
        * Database user name=userGhR # generated
        * Database user password=KhnHKCQI # generated
        * Database admin password=UyUV6ReU # generated
        * GitHub Trigger=dAOuD7s4 # generated
        * Generic Trigger=tWSkmNLn # generated

--> Creating resources ...
    configmap "mlbparks" created
    service "mongodb-mlbparks" created
    deploymentconfig "mongodb-mlbparks" created
    imagestream "mlbparks" created
    buildconfig "mlbparks" created
    deploymentconfig "mlbparks" created
    service "mlbparks" created
    route "mlbparks" created
--> Success
    Build scheduled, use 'oc logs -f bc/mlbparks' to track its progress.
    Run 'oc status' to view your app.

OpenShift will now:

  • Configure and start a build

    • From the supplied source code repository

  • Configure and deploy MongoDB

    • Using auto-generated user, password, and database name

  • Configure environment variables for the app to connect to the DB

  • Create the correct services

  • Label the app service with type=parksmap-backend

All with one command!

When the build is complete, visit the parks map. Does it work? Think about how this could be used in your environment. For example, a template could define a large set of resources that make up a "reference application", complete with several app servers, databases, and more. You could deploy the entire set of resources with one command, and then hack on them to develop new features, microservices, fix bugs, and more.

As a final exercise, look at the template that was used to create the resources for our mlbparks application.

$ oc get template mlbparks -o yaml

Lab: Clustering Stateful Java EE Applications

JBoss EAP Clustering

Clustering in JBoss EAP is achieved using the Kubernetes discovery mechanism for finding other JBoss EAP containers and forming a cluster. This is done by configuring the JGroups protocol stack in standalone-openshift.xml with <openshift.KUBE_PING/> elements.

For KUBE_PING to work, the following steps must be taken:

  1. The OPENSHIFT_KUBE_PING_NAMESPACE environment variable must be set. If not set, the server will act as if it is a single-node cluster (a "cluster of one").

  2. The OPENSHIFT_KUBE_PING_LABELS environment variables should be set. If not set, pods outside of your application (albeit in your namespace) will try to join.

  3. Authorization must be granted to the service account the pod is running under to be allowed to access Kubernetes' REST api.

You have already configured the default service account to have access to Kubernetes' REST api during previous labs. Now you can scale up the mlbparks pod to two by clicking on the upper arrows on the console. Alternatively, you can use the command line to scale up the pods and form a two-member cluster.

$ oc scale dc/mlbparks --replicas=2

For pods based on Java images, the web console also exposes access to a hawt.io-based JVM console for viewing and managing any relevant Java components. A link is displayed in the pod’s details on the ApplicationsPods page, provided the container has a port named jolokia. On the console, click on mlbparks pods, then on any of the two pods deployed. On the Details tab, click on Open Java Console.

Java Console Link

In the Java Console, use the JMX browser and click on jgroups → channel → ee. The right pane shows the list of clustering JMX attributes including view which is the current state of the cluster. This attribute shows the name of two pods which are currently members of the cluster. When mlbparks pod gets scaled up or down, JBoss EAP gets notified by calling Kubernetes' REST API and updates the cluster status based on the number of pods available.

Java Console - Clustering

Further Resources

The exercices in this workshop has shown you how OpenShift can be used not only for deploying stateless web applications, but also applications which require persistent file system storage.

This flexibility makes OpenShift an ideal platform for deploying both web applications and databases.

If you have finished this workshop early and want to experiment some more, we have additional exercises you can try out using our online interactive learning environment.

The online interactive learning environment is always available so you can continue to work on those exercises even after the workshop is over.

Below you will find further resources for learning about OpenShift and running OpenShift on your own computer, as well as details about OpenShift Online or other OpenShift related products and services.

  • OpenShift Origin - The upstream Open Source community project that powers OpenShift.

  • Minishift - A tool which can be used to install a local OpenShift cluster on your own computer, running in a virtual machine.

  • OpenShift Online - A shared public hosting environment for running your applications using OpenShift.

  • OpenShift.io - An online development environment for planning, creating and deploying hybrid cloud services using OpenShift.

  • OpenShift Dedicated - A dedicated hosting environment for running your applications, managed and supported for you by Red Hat.

  • OpenShift Container Platform - The Red Hat supported OpenShift product for installation on premise or in hosted cloud environments.

The following free online eBooks are also available for download related to OpenShift.

OpenShift for Developers
DevOps with OpenShift


'디지털 양피지 > Docker' 카테고리의 다른 글

openshift03  (0) 2017.07.04
openshift2  (0) 2017.07.04
8. Open Shift  (0) 2017.07.04
7.Kubernetes - Advanced  (0) 2017.07.03
6. Kubenetes 리소스 관리  (0) 2017.06.30
Posted by 빨간 양말