microservices osgi-running-with-apache-karaf
TRANSCRIPT
![Page 1: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/1.jpg)
Microservices and OSGi
running with Apache Karaf
![Page 2: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/2.jpg)
•No free Lunch - microservices
•microservices or µService?
•Free Lunch? - OSGi µServices
•µServices in the Apache Karaf ecosystem
•https://github.com/ANierbeck/Karaf-Microservices-Tooling
•https://github.com/ANierbeck/Karaf-Microservices
2
Agenda
Showcase:
![Page 3: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/3.jpg)
3
@anierbeck
Senior IT-Consultant @codecentric
Apache Karaf PMC
Apache Member
OPS4j Pax Web Project lead
Co-Author Apache Karaf Cookbook
![Page 4: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/4.jpg)
No Free Lunch - with micro services_
4
![Page 5: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/5.jpg)
01
No Free Lunch - with micro services_
Operations overhead
Instead of one Application (cluster)
micro applications that need to be clustered / Orchestrated / Operated
![Page 6: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/6.jpg)
01
No Free Lunch - with micro services_
DevOps Skills Required
old school: One AppServer one application
now: applications that might run on different infrastructure
Instead of bigger boats, more boats are needed
![Page 7: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/7.jpg)
01
No Free Lunch - with micro services_
Implicit Interfaces
Changes in:
•syntax
•semantics
![Page 8: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/8.jpg)
01
No Free Lunch - with micro services_
Distributed System Complexity
network latency
fault tolerance
message serialization
distributed transactions
![Page 9: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/9.jpg)
01
No Free Lunch - with micro services_
A/Synchronicityis Difficult!communication is much more asynchronous
it gets complex when you need to correlate messages
or distributed transactions
![Page 10: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/10.jpg)
01
No Free Lunch - with micro services_
Testability Challenges
testing a single service is easy
monitoring the dynamic environment is hard
—> less testing, more monitoring
![Page 11: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/11.jpg)
µService - comparison of two definition_
11
![Page 12: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/12.jpg)
—Peter Kriens, March 2010
http://blog.osgi.org/2010/03/services.html
“What I am promoting is the idea of µServices, the concepts of an OSGi
service as a design primitive.”
12
![Page 13: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/13.jpg)
–Martin Fowler, March 2014
“In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight
mechanisms, often an HTTP resource API. These services are built around business capabilities and
independently deployable by fully automated deployment machinery. There is a bare mininum of centralized management of these services, which
may be written in different programming languages and use different data storage technologies.”
13
![Page 14: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/14.jpg)
• One main reason for using services as components (rather than libraries) is that services are independently deployable OSGi Bundle
• you can expect many single service changes to only require that service to be redeployedOSGi Service / Bundle • cohesive service boundaries and evolution mechanisms in the service contracts
OSGi Versioning
• Often it's only documentation and discipline that prevents clients breaking a component's encapsulation, leading to overly-tight coupling between components.OSGi Container enforces this
in detail_
14
![Page 15: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/15.jpg)
Free Lunch? OSGi µServices_
15
![Page 16: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/16.jpg)
01
Free Lunch? OSGi µServices_
Operations Overhead
OSGi Bundles - containing services
One container vessel
One Server to know
![Page 17: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/17.jpg)
Apache_
17
![Page 18: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/18.jpg)
OSGi Framework
18
JAAS
Deployer
Console
Blueprint
LoggingConfig
HttpWAR
Features
Instance
OBR
KAR
JMX
JPA JTA Cellar
Core
Stan
dard
Apache Karaf_
JNDI JMS JDBC
µServices µServices µServices
JAX-RS
µServices
![Page 19: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/19.jpg)
01
Free Lunch? OSGi µServices_
DevOps Skills Required
requirements are reduced!
- Karaf - Ops - OSGi - Devs
![Page 20: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/20.jpg)
01
Free Lunch? OSGi µServices_
Implicit Interfaces
semantic versioning
OSGi supports multiple versions
multiple service implementations
tools help
![Page 21: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/21.jpg)
21
Semantic Versioning_
1. major
Packages with versions that have different major parts are not compatible both for providers as well as consumers. For example, 1.2 and 2.3 are completely incompatible.
2. minor
API consumers are compatible with exporters that have the same major number and an equal or higher minor version. API providers are compatible with exporters that have the same major and minor version number. For example, 1.2 is backward compatible with 1.1 for consumers but for providers it is incompatible. Consumers should therefore import [1.2,2) and providers should import [1.2,1.3).
3. micro
A difference in the micro part does not signal any backward compatibility issues. The micro number is used to fix bugs that do not affect either consumers or providers of the API.
4. qualifier
The qualifier is usually used to indicate a build identity, for example a time stamp. Different qualifiers do not signal any backward compatibility issues.
![Page 22: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/22.jpg)
22
maven-bundle-plugin
Semantic Versioning - Tools_
![Page 23: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/23.jpg)
01
Semantic Versioning - Tools_
Release - Baselining
Fix version 1.0.0
Baseline new version with 1.0.0 version
![Page 24: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/24.jpg)
•Comparing bundle service-api version 1.0.0-SNAPSHOT to version 1.0.0-SNAPSHOT PACKAGE_NAME DELTA CUR_VER BASE_VER REC_VER WARNINGS= ================================================== ========== ========== ========== ========== ========== de.nierbeck.microservices.karaf.calculator unchanged 1.0.0 1.0.0 1.0.0 ------------------------------------------------------------------------------------------------------------ de.nierbeck.microservices.karaf.calculator.values unchanged 1.0.0 1.0.0 1.0.0 ------------------------------------------------------------------------------------------------------------ Baseline analysis complete, 0 error(s), 0 warning(s)
Semantic Versioning - Baselining_
24
Baselining
![Page 25: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/25.jpg)
01
Free Lunch? OSGi µServices_
Distributed System Complexity
complexity reduced -> one container
no network traffic
service calls -> method calls from services found in service registry.
Clustering: Apache Karaf Cellar Remote: DOSGi —> CXF, Cellar
![Page 26: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/26.jpg)
01
Free Lunch? OSGi µServices_
A/Synchronicityis Difficult!in JVM communication
service calls - transparent call
stateless services
event communication Out-Of-The-Box
![Page 27: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/27.jpg)
01
Free Lunch? OSGi µServices_
Testability Challenges
POJO tests for business logic
Pax EXAM - Integration tests of OSGi services. Shift Focus: More Testing, less monitoring
![Page 28: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/28.jpg)
28
Service tests - Pax EXAM - Continous Integration_
![Page 29: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/29.jpg)
µServices in the Apache Karaf ecosystem_
29
![Page 30: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/30.jpg)
30
µServices in the Apache Karaf ecosystem_
microservices made of µServices …
![Page 31: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/31.jpg)
01
µServices in the Apache Karaf ecosystem_
Apache Karaf Cellar
Hazelcast based cluster
Groups and Nodes
Services across Clusters
Failover
Load balanced
![Page 32: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/32.jpg)
01
µServices in the Apache Karaf ecosystem_
Apache Karaf Cave
OSGi Repository
Bundle Requirements Capabilities
![Page 33: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/33.jpg)
01
µServices in the Apache Karaf ecosystem_
Apache Karaf Decanter
Monitor
Elasticsearch
Kibana
![Page 34: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/34.jpg)
Continous Delivery with Apache Karaf_
34
![Page 35: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/35.jpg)
Continous Deployment_
35
![Page 36: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/36.jpg)
36
{ "type":"EXEC", "mbean":"org.apache.karaf:type=bundle,name=root", "operation":"install(java.lang.String,boolean)", "arguments":["mvn:${project.groupId}/${project.artifactId}/${project.version}", true] }
•deployment via REST
•Jolokia - REST
• JMX Management
•Maven Plugin
Continous Deployment_
![Page 37: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/37.jpg)
µServices - sum of all services_
37
![Page 38: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/38.jpg)
01
µServices - sum of all services_
Should I do microservices
YES!
Monolithic blocks are bad
Use: - Low Coupling - High Cohesion
![Page 39: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/39.jpg)
01
µServices - sum of all services_
The Silver Bullet?
NO!
OSGi isn’t the silver Bullet
A lot of issues which exist with µ-Services are already solved in the OSGi - Eco system
![Page 40: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/40.jpg)
01
µServices - sum of all services_
Blueprint?
YES!
Use it as blueprint for transition to microservices
OSGi - µServices will help in breaking up the Monolith
![Page 41: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/41.jpg)
01
µServices - sum of all services_
microservice based on µServices
instead of building micro-monolith
base on OSGi services.
![Page 42: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/42.jpg)
Questions ?
![Page 43: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/43.jpg)
•images found at flickr - thanks to that
•No Free Lunch with Microserviceshttp://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
•http://karaf.apache.org/
•http://blog.osgi.org/2010/03/services.html
•https://github.com/ANierbeck/Karaf-Microservices-Tooling
•https://github.com/ANierbeck/Karaf-Microservices
END_
43
Links:
Showcase:
![Page 44: Microservices OSGi-running-with-apache-karaf](https://reader031.vdocuments.us/reader031/viewer/2022021813/586fba4b1a28abe57d8b86e5/html5/thumbnails/44.jpg)
44