This content is brought to you by http://developers.redhat.com - Register today!

rhdevelopers

This is the frontend screenshot that you will see after the deployment of all microservices:

frontend
Table of Contents

Prepare Environment

Install Openshift Client

You can download and unpack the CLI from the Github for use on Linux, MacOSX, and Windows clients.

(Option 1) Use CDK (OpenShift Container Platform 3.2)

  • Install a virtualization provider (hypervisor) for your system such as VirtualBox, VMware, or KVM/libvirt.

  • Install Vagrant, from vagrantup.com, or from your operating system’s packages.

  • From Red Hat CDK Download page download Red Hat Container Tools (cdk-2.2.0.zip) and the RHEL 7.2 Vagrant box that matches your virtualization provider: VirtualBox, VMare, or KVM/libvirt.

  • Unzip cdk-2.2.0.zip into a directory of your choosing.

Install the required vagrant plugins:

$ vagrant plugin install vagrant-service-manager vagrant-registration vagrant-sshfs

Add the RHEL 7.2 Vagrant box to Vagrant with the command:

$ vagrant box add --name cdkv2 <path to downloaded .box file>

Update CDK Memory and CPU

$ cd <CDK-PATH>/components/rhel/rhel-ose
$ export VM_MEMORY=6000

Execute Vagrant:

$ export SUB_USERNAME=<your-subscription-username>
$ export SUB_PASSWORD=<your-subscription-password>
$ vagrant up

Access Openshift console

Open Openshift console: https://10.1.2.2:8443/console/
(Accept the certificate and proceed)

Log in Openshift
Use openshift-dev/devel as your credentials

(Option 2) Use "oc cluster up" (OpenShift Container Platform 3.3)

This option only needs a docker-machine installed.

Execute:

$ oc cluster up --create-machine=true   \
                --use-existing-config   \
                --host-data-dir=/mydata \
                --image=registry.access.redhat.com/openshift3/ose \
                --version=latest

Access Openshift console

Open Openshift console: https://<openshift_ip>:8443/console/
(Accept the certificate and proceed)

Log in Openshift
Use openshift-dev/devel as your credentials

(Option 1) Install all microservices using Ansible

Ansible can be used to automate the bootstrap process to setup Helloworld-MSA in CDK.

Make sure you have the following requirenments installed:

  • Git

  • Ansible 1.9+

  • Maven 3.1+

  • JDK 1.8

  • NPM

And run the following commands:

$ git clone https://github.com/redhat-helloworld-msa/helloworld-msa
$ cd helloworld-msa/ansible

First, edit the vars.yaml file to define the 'workdir' variable and set the absolute path where you want to "git checkout" the source code of the microservices.

Then execute:

$ ansible-playbook helloworld-msa.yml

The playbook will take approximately 20 minutes to complete. After that OpenShift should take more 10 minutes to finish the installation and boot of each microservice. The bootstrap process should complete within 30 minutes.

This approach is used to make it easy to create an environment with all pieces of this demo. However in a real MSA environment, each microservice can and should be deployed independently. The following instructions allow you to understand the individual process to deploy each microservice.

(Option 2) Install each microservice individually

Create a project

In Openshift, click in the "New Project" button. Give it the name "helloworld-msa"

You must use the exact project name since it will affect the generate endpoint’s URLs

Or run:

$ oc login <Openshift IP>:8443 -u openshift-dev -p devel
$ oc new-project helloworld-msa

Deploy hola (JAX-RS/Wildfly Swarm) microservice

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/hola
$ cd hola/
$ oc new-build --binary --name=hola -l app=hola
$ mvn package; oc start-build hola --from-dir=. --follow
$ oc new-app hola -l app=hola,hystrix.enabled=true
$ oc expose service hola
(Optional) Enable Readiness probe
$ oc set probe dc/hola --readiness --get-url=http://:8080/api/health

Deploy aloha (Vert.x) microservice

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/aloha
$ cd aloha/
$ oc new-build --binary --name=aloha -l app=aloha
$ mvn package; oc start-build aloha --from-dir=. --follow
$ oc new-app aloha -l app=aloha,hystrix.enabled=true
$ oc expose service aloha
(Optional) Enable Jolokia and Readiness probe
$ oc env dc/aloha AB_ENABLED=jolokia; oc patch dc/aloha -p '{"spec":{"template":{"spec":{"containers":[{"name":"aloha","ports":[{"containerPort": 8778,"name":"jolokia"}]}]}}}}'
$ oc set probe dc/aloha --readiness --get-url=http://:8080/api/health

Deploy ola (Spring Boot) microservice

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/ola
$ cd ola/
$ oc new-build --binary --name=ola -l app=ola
$ mvn package; oc start-build ola --from-dir=. --follow
$ oc new-app ola -l app=ola,hystrix.enabled=true
$ oc expose service ola
(Optional) Enable Jolokia and Readiness probe
$ oc env dc/ola AB_ENABLED=jolokia; oc patch dc/ola -p '{"spec":{"template":{"spec":{"containers":[{"name":"ola","ports":[{"containerPort": 8778,"name":"jolokia"}]}]}}}}'
$ oc set probe dc/ola --readiness --get-url=http://:8080/api/health

Deploy bonjour (NodeJS) microservice

Choose one of the following options/approaches to deploy this microservice.

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/bonjour
$ cd bonjour/
$ oc new-build --binary --name=bonjour -l app=bonjour
$ npm install; oc start-build bonjour --from-dir=. --follow
$ oc new-app bonjour -l app=bonjour
$ oc expose service bonjour
(Optional) Enable Readiness probe
$ oc set probe dc/bonjour --readiness --get-url=http://:8080/api/health

Deploy api-gateway (Spring Boot)

The API-Gateway is a microservices architectural pattern. For more information about this pattern, visit: http://microservices.io/patterns/apigateway.html

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/api-gateway
$ cd api-gateway/
$ oc new-build --binary --name=api-gateway -l app=api-gateway
$ mvn package; oc start-build api-gateway --from-dir=. --follow
$ oc new-app api-gateway -l app=api-gateway,hystrix.enabled=true
$ oc expose service api-gateway
(Optional) Enable Jolokia and Readiness probe
$ oc env dc/api-gateway AB_ENABLED=jolokia; oc patch dc/api-gateway -p '{"spec":{"template":{"spec":{"containers":[{"name":"api-gateway","ports":[{"containerPort": 8778,"name":"jolokia"}]}]}}}}'
$ oc set probe dc/api-gateway --readiness --get-url=http://:8080/health

Deploy frontend (NodeJS/HTML5/JS)

frontend

Choose one of the following options/approaches to deploy the UI.

Deploy project via oc CLI

Basic project creation
$ git clone https://github.com/redhat-helloworld-msa/frontend
$ cd frontend/
$ oc new-build --binary --name=frontend -l app=frontend
$ npm install; oc start-build frontend --from-dir=. --follow
$ oc new-app frontend -l app=frontend
$ oc expose service frontend

Deploy Kubeflix

Kubeflix provides Kubernetes integration with Netflix open source components such as Hystrix, Turbine and Ribbon.

Specifically it provides:

  • Kubernetes Instance Discovery for Turbine and Ribbon

  • Kubernetes configuration and images for Turbine Server and Hystrix Dashboard

kubeflix

Deploy using oc CLI

Execute:

$ oc create -f http://central.maven.org/maven2/io/fabric8/kubeflix/packages/kubeflix/1.0.17/kubeflix-1.0.17-kubernetes.yml
$ oc new-app kubeflix
$ oc expose service hystrix-dashboard --port=8080
$ oc policy add-role-to-user admin system:serviceaccount:helloworld-msa:turbine

Enable the Hystrix Dashboard in the Frontend

Execute:

$ oc env dc/frontend ENABLE_HYSTRIX=true

Deploy Kubernetes Zipkin

Kubernetes Zipkin provides all the required resources to start the required Zipkin components in Kubernetes to trace your microservices.

Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in microservice architectures.