Topic: Helidon: A Simple Native Cloud Framework
Technology: Helidon is one of the frameworks designed by Oracle for creating container friendly microservices with less amount of code, running on Java SE.
This framework helps in moving the legacy monolithic way to micro service pattern, where instead of maintaining everything (validation, security, business logic, data retrieval, manipulation) in one big application to multiple micro services for each of the module, by communication between micro services, we can achieve the same result as monolithic application, Each of the micro service can be scaled-in and scaled-out based on usage/ any other factor.
Micro services Advantages over Monolithic design:
1. Deployment: for Monolithic application even for small change in source code, we need to build the entire application, testing application, deployment of the application will take longer time. Micro service pattern will take small amount of time as build/ test only specific module where the source code is modified.
2. Dependencies, Frameworks, and Language: Monolithic style of development will be locked in selecting the language, frameworks for entire application, but for micro services style of Java software development we can chose our own framework/ language based on business requirements.
3. Single of Point of Failure: Monolithics are brittle, if the hosted web-server is down, the entire application will not be accessed, for microservices pattern only portion of the application will not be accessed, if the micro service goes down.
4, Scaling: Scaling Monolithic will costly, as entire application has to be scaled in, even though some modules of the application is/are not needed, but micro service pattern, we can selectively scale in/out based on business use cases.
Oracle has developed the new framework for creating the micro-services called Helidon.
Helidon comes with two flavours SE and MP.
Helidon SE is simple, light weight functional, reactive. It runs on Netty web server (Default for server for Reactive applications).
Helidon MP: Helidon MP is micro profile-based framework which uses annotations and component like JAX-RS, and JSON-P.
Getting stated with Helidon SE:
To get started with Helidon framework, make sure that you have installed on Java 8+ version, and Maven 3.5 or later version. Helidon will generate docker files, and kubernetes files, to take the advantage of it, make sure that docker installed version will be 18.02 or later, and Kubernetes version will be 1.7.4 or later (we can use any flavour of the Kubernetes like Minikube or Docker supported Kubernetes).
Once you have the above tools installed we can generate the application using below Maven archetype.
mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=io.helidon.archetypes -DarchetypeArtifactId=helidon-quickstart-se -DarchetypeVersion=1.1.1 -DgroupId=io.helidon.examples -DartifactId=helidon-quickstart-se -Dpackage=io.helidon.examples.quickstart.se
Once we execute the command
the folder structure will look like below:
Package the application using mvn package command, it will compile the source files, and execute all tests and create the jar file, if tests are success.
During this command execution all class-path entries will be copied into target/lib folder.
As Helidon comes with Netty as default embedded server, we can run the application by using the below command:
java -jar target/helidon-quickstart-se.jar
We can see the above log, once the application started and running on port default port (8080).
Navigate to http://localhost:8080/greet we can see the hello world message in browser.
Building Docker Images:
Navigate the project folder and execute the below command:
docker build -t helidon-se-demo .
it will build local docker image, output may vary base on executing the first time/ second time onwards as docker will cache the each of the layer.
We can also our project image and dependent images are created or not using below command.
Running Application docker machine:
docker run -d -p 8080:8080 helidon-se-demo is the command to execute the application on docker machine.
Installing Application on Kubernetes:
Helidon framework will create app.yaml file while creating the archetype for deploying the application into Kubernetes.
If you have Kubernetes cluster installed machine, then execute the below command to deploy application into Kubernetes cluster.
kubectl apply -f app.yaml
it will create deployment with replica count as 1, service for application so that it will be accessible outside the container in a targetPort.
Later we can check the Kubernetes services using below command:
kubectl get services
We can find the application service with the name helidon-quickstart-se running.
Conclusion: Helidon is the one of the microservice framework written by Oracle, for easier development, by default all required files for Docker and Kubernetes files will be generated with maven archetype.
- Category: Miscellaneous
- Specification: Framework