This code demonstrates the deployment of a Java based microservices application using MicroProfile and Microservice Builder on Kubernetes Cluster.
MicroProfile is a baseline platform definition that optimizes Enterprise Java for a microservices architecture and delivers application portability across multiple MicroProfile runtimes. Microservice Builder builds on top of MicroProfile.io, and provides extension for containerized apps created using the tool to be deployed to Kubernetes.
The Microservice Builder sample application is a web application for managing a conference and is based on a number of discrete microservices. The front end is written in Angular; the backing microservices are in Java. All run on WebSphere Liberty, in Docker containers managed by Kubernetes. Minikube instructions are present in this repository.
- Bluemix Container Service
- Kubernetes Cluster
- MicroProfile
- Microservice Builder
- Bluemix DevOps Toolchain Service
-
Create a Kubernetes cluster with IBM Bluemix Container Service. If you have not setup the Kubernetes cluster, please follow the Creating a Kubernetes cluster tutorial.
-
Install a Git client to obtain the sample code.
-
Install Maven and a Java 8 JDK.
-
Install a Docker engine.
If you want to deploy the wordpress directly to Bluemix, click on 'Deploy to Bluemix' button below to create a Bluemix DevOps service toolchain and pipeline for deploying the Java microservices using MicroProfile sample, else jump to Steps
Please follow the Toolchain instructions to complete your toolchain and pipeline.
- Install Docker CLI and Bluemix Container registry Plugin
- Get and build the application code
- Build application containers
- Create Services and Deployments
First, install Docker CLI.
Then, install the Bluemix container registry plugin.
bx plugin install container-registry -r bluemix
Once the plugin is installed you can log into the Bluemix Container Registry.
bx cr login
If this is the first time using the Bluemix Container Registry you must set a namespace which identifies your private Bluemix images registry. It can be between 4 and 30 characters.
bx cr namespace-add <namespace>
Verify that it works.
bx cr images
- Install the Microservice Builder fabric - which provides additional services that run on top of Kubernetes.
Note: For the following steps, you can get the code and build the package by running the get_code.sh script present in scripts directory.
-
git clone
the following projects:git clone https://github.com/WASdev/sample.microservicebuilder.web-app.git
git clone https://github.com/WASdev/sample.microservicebuilder.schedule.git
git clone https://github.com/WASdev/sample.microservicebuilder.speaker.git
git clone https://github.com/WASdev/sample.microservicebuilder.session.git
git clone https://github.com/WASdev/sample.microservicebuilder.vote.git cd sample.microservicebuilder.vote/ git checkout 4bd11a9bcdc7f445d7596141a034104938e08b22
-
mvn clean package
in each ../sample.microservicebuilder.* projects
Use the following commands to build the microservers containers.
Build the web-app microservice container
cd sample.microservicebuilder.web-app docker build -t registry.ng.bluemix.net/<namespace>/microservice-webapp . docker push registry.ng.bluemix.net/<namespace>/microservice-webapp
Build the vote microservice container
cd sample.microservicebuilder.vote docker build -t registry.ng.bluemix.net/<namespace>/microservice-vote . docker push registry.ng.bluemix.net/<namespace>/microservice-vote
Build the schedule microservice container
cd sample.microservicebuilder.schedule docker build -t registry.ng.bluemix.net/<namespace>/microservice-schedule . docker push registry.ng.bluemix.net/<namespace>/microservice-schedule
Build the speaker microservice container
cd sample.microservicebuilder.speaker docker build -t registry.ng.bluemix.net/<namespace>/microservice-speaker . docker push registry.ng.bluemix.net/<namespace>/microservice-speaker
Build the session microservice container
cd sample.microservicebuilder.session docker build -t registry.ng.bluemix.net/<namespace>/microservice-session . docker push registry.ng.bluemix.net/<namespace>/microservice-session
Build the nginx controller
cd nginx docker build -t registry.ng.bluemix.net/<namespace>/nginx-server . docker push registry.ng.bluemix.net/<namespace>/nginx-server
Change the image name given in the respective deployment YAML files for all the projects in the manifests directory with the newly build image names.
Get the public ip of the node
$ kubectl get nodes NAME STATUS AGE 169.47.241.106 Ready 23h
Set the value of SOURCE_IP
env variable present in deploy-nginx.yaml file present in manifests folder with the public ip of the node.
Deploy the microservice from the manifests directory with the command kubectl create -f <filename>
.
After you have created all the services and deployments, wait for 10 to 15 minutes. You can check the status of your deployment on Kubernetes UI. Run 'kubectl proxy' and go to URL 'http://127.0.0.1:8001/ui' to check when the application containers are ready.
After few minutes the following commands to get your public IP and NodePort number.
$ kubectl get nodes NAME STATUS AGE 169.47.241.106 Ready 23h $ kubectl get svc nginx-svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-svc 10.10.10.167 <nodes> 80:30056/TCP 11s
Now you can use the link http://[IP]:30056 to access your application on browser.
Web application home page
When you click on speaker name
When you click on schedules link
When you click on vote link