You are on page 1of 11

Eclipse Vert.

x
Chapter 06
Reactive Microservices
in OpenShift
Firmansyah.profess@gmail.com
2018
01. OpenShift
a. Definition:
1. RedHat OpenShift is an open source container platform.
2. OpenShift is built on top of Kubernetes (https://kubernetes.io/).
3. Kubernetes is a project with lots of functionality for running clusters
of microservices inside Linux containers at scale.
4. The OpenShift container platform:

OpenShift

Kubernetes
01. OpenShift
b. The OpenShift Components:

1. Build Configuration: The build is the process of creating container


images that will be used by OpenShift to instantiate the different
containers that make up an application.
a) OpenShift builds can use different strategies:
• Docker: Build an image from a Dockerfile.
• Source to Image (S2I): Build an image from the
application source, built on OpenShift by a builder
image.
01. OpenShift
b. The OpenShift Components:
• Jenkins Pipeline—Build an image using a Jenkins pipeline
(https://jenkins.io/doc/book/pipeline) potentially containing
multiple stages such as build, tests, and deployment.
b) A build configuration can be triggered automatically by:
• A Git push.
• A change in the configuration or an update in a dependent
image.
• Manual.
2. Deployment Configurations:
a) It defines the instantiation of the image produced by a build.
b) It defines which image is used to create the containers and the
number of instances we need to keep alive.
c) It also describes when a deployment should be triggered.
d) It acts as a replication controller and is responsible for keeping
containers alive. To achieve this, you pass the number of
desired instances. The number of desired instances can
be adjusted over time or based on the load fluctuation
(auto-scaling).
e) It can also specify health checks to manage rolling
updates and detect dead containers.
01. OpenShift
b. The OpenShift Components:
3. Pods:
a) A pod is a group of one or more containers. However, it is
typically comprised of a single container.
b) The pod orchestration, scheduling, and management are
delegated to Kubernetes.
c) Pods are fungible, and can be replaced at any time by another
instance. For example, if the container crashes, another
instance will be spawned.
4. Services:
a) Services allow us to communicate with the pods without relying
on their addresses but by using the service virtual address.
b) A service acts as a proxy in front of a group of pods.
c) It may also implement a load-balancing strategy.
5. Routes:
a) It exposes a service at a hostname like www.myservice.com so
that external clients can reach it by name.
b) Other applications running in OpenShift can access the
functionality offered by the pods using the service,
but external applications need a route.
02. OpenShift Installation
a. Options for install OpenShift:
1. Minishift (https://github.com/minishift/minishift). In this demo we will
install this option and requires a VirtualBox, please download at
https://www.virtualbox.org/wiki/Downloads and follow its installation
guides.
2. OpenShift Starter Online
(https://www.openshift.com/products/pricing/), need sign up.
3. Red Hat Container Development Kit
(https://developers.redhat.com/products/cdk/download/)
b. Minishift Installation:
1. Download the latest version for your OS from the Minishift releases
page (https://github.com/minishift/minishift/releases),
2. Unpack it to your preferred location,
3. Create variable name MINISHIFT_HOME inside environment
variable and its value is your unpacking preferred location.
4. Add the MINISHIFT_HOME (minishift binary) to your PATH
environment variable.
5. (Optional) Remove C:\Windows\System32\OpenSSH from
your PATH environment variable, if there are some error
occurred.
02. OpenShift Installation
b. Minishift Installation:
6. Once installed, start Minishift using:
minishift start --vm-driver virtualbox --show-
libmachine-logs -v5
7. Once started, you should be able to connect to your OpenShift
instance using web browser with launch following command:
Minishift console
8. You may have to validate the SSL certificate.
9. Log in with developer/developer.
c. OpenShift client (oc):
1. Find oc binary in MINISHIFT_HOME\cache\oc\v3.11.0\windows
2. Add the oc binary to your PATH environment variable.
3. Connect to your OpenShift instance using:
oc login https://192.168.99.100:8443 -u
developer -p developer
4. Create example project, execute:
oc new-project project-example
oc policy add-role-to-user admin developer -n project-example
oc policy add-role-to-user view -n project-example -z default
5. In your browser, open:
https://192.168.99.100:8443/console/project/project-example/.
03. Create OsHttpMicro01
a. Create a directory called “chapter06” and sub
directory called “oshttpmicro01”
b. Generate the project structure using maven inside
oshttpmicro01 folder:
mvn io.reactiverse:vertx-maven-plugin:1.0.18:setup \
-DprojectGroupId=io.vertx.chapter06 \
-DprojectArtifactId=os-http-micro-vertx-app \
-Dverticle=io.vertx.chapter06.OsHttpMicro01 \
-Ddependencies=web
c. Modify io.vertx.chapter06.OsHttpMicro01 class
d. Modify pom.xml file
e. Login into openshift:
oc login https://192.168.99.100:8443 -u developer -p
developer
f. Package and deploy OsHttpMicro01 to
OpenShift, launch:
mvn fabric8:deploy -Popenshift
04. Create OsHttpMicro02
a. Create a directory called “oshttpmicro02” under
directory “chapter06”
b. Generate the project structure using maven inside
oshttpmicro02 folder:
mvn io.reactiverse:vertx-maven-plugin:1.0.18:setup \
-DprojectGroupId=io.vertx.chapter06 \
-DprojectArtifactId=os-http-micro02-vertx-app \
-Dverticle=io.vertx.chapter06.OsHttpMicro02 \
-Ddependencies=web,rx,web-client,service-discovery,vertx-
service-discovery-bridge-kubernetes,circuit-breaker
c. Modify io.vertx.chapter06.OsHttpMicro02 class
d. Modify pom.xml file
e. Login into openshift and make sure has access right:
oc login https://192.168.99.100:8443 -u developer -p developer
oc policy add-role-to-user admin developer -n myproject
oc policy add-role-to-user view -n myproject -z default
f. Package and deploy OsHttpMicro02 to OpenShift,
launch:
mvn fabric8:deploy -Popenshift
Thank You!
Any questions? You can find me at
firmansyah.profess@gmail.com

Credits
PPT: ALLPPT.com
Music: https://www.bensound.com

You might also like