SlideShare a Scribd company logo
1 of 47
Download to read offline
Apache Karaf on cloud,
The kloud initiative
APACHECON North America Sept. 9-12, 2019
JB Onofré
jbonofre@apache.org
@jbonofre
1
Who am I ?
Jean-Baptiste Onofré <jbonofre@apache.org>
● Software Engineer/Fellow at Talend
● Member of the Apache Software Foundation
● PMC member and committer for ~ 20 Apache projects (Karaf, Camel, ActiveMQ, Felix,
Aries, Beam, Incubator, …)
Karaf track at ACNA ‘19 !
Full track about Apache Karaf with three talks:
1. Apache Karaf on Cloud, the kloud initiative (this talk)
2. Serverless: Multi-tenant Rule Engine Service powered by
Apache Karaf
3. Customer segmentation and personalization in
websites/PWAs using Apache Unomi
Why Apache Karaf on cloud ?
● Runtime addressing different use cases
● Provide bunch of “ready-to-use” features
● Can be used on premise or on cloud (easy “move”)
● Support different distribution and packaging to match your requirements
(devs/devops)
● Can leverage additional projects to provide extended features (monitoring, cluster, …)
Karaf use cases
● Applications (web, backend, …)
● IoT, messaging and integration (Camel, CXF, ActiveMQ, Kafka, ...)
● Micro-services
Transverse features:
● Monitoring/Alerting/BAM/Data Collection with Karaf Decanter
● Clustering with Karaf Cellar
● Artifacts repositories with Karaf Cave
● API management with Karaf Vineyard
● CDP with Unomi
● ...
Applications in Karaf
● Support applications “frameworks”: core Java, Spring,
WebApplication (not necessary OSGi !)
● Easy to migrate from a middleware to Karaf
● Support OSGi applications: micro-service approach internal
to Karaf runtime
● “Force” you to implement a clean design of your applications
(API, SPI, …)
● Support any OSGi programming model: pure “OSGi”,
blueprint, SCR
● Karaf features to extend and provision applications (JPA,
JTA, JMS, JDBC, …)
● Also possible to use hot deployment
Service based application example: API
module
public interface BookingService {
Collection<Booking> list();
Booking get(Long id);
void add(Booking booking);
}
public class Booking {
private Long id;
private String customer;
private String flight;
public Booking(String customer, String flight)
throws Exception {
this.id = new Random().nextLong();
this.customer = customer;
this.flight = flight;
}
…
}
Service based application example:
service impl (using SCR)
@Component
public class BookingServiceMemoryImpl implements BookingService {
private final Map<Long, Booking> bookings = new HashMap<>();
@Override
public Collection<Booking> list() {
return bookings.values();
}
@Override
public Booking get(Long id) {
return bookings.get(id);
}
@Override
public void add(Booking booking) {
bookings.put(booking.getId(), booking);
}
}
Application example: Karaf features
<features name="karaf-acna-2019" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="karaf-acna-api" version="1.0">
<bundle>mvn:org.apache.acna/karaf-acna-api/1.0</bundle>
</feature>
<feature name="karaf-acna-service" version="1.0">
<feature>karaf-acna-api</feature>
<feature prerequisite="true">scr</feature>
<bundle>mvn:org.apache.acna/karaf-acna-service/1.0</bundle>
</feature>
</features>
IoT and integration in Karaf
● Support Apache Camel as integration framework
○ Provide more than 100 of Camel components as Karaf
features
○ EIPs
○ Data Formats
● Easy to install and start with, supporting DSLs
● Use the same Karaf features provisioning mechanism
● Support hot deployment
● Support MoM with ActiveMQ, Kafka, …
● Support web/rest service with CXF
IoT example: camel blueprint DSL
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="example-http-inbound">
<from uri="jetty:http://0.0.0.0:9090/example"/>
<convertBodyTo type="java.lang.String"/>
<log message="[EXAMPLE INBOUND] Received: ${body}"/>
<setHeader headerName="service"><jsonpath>$.notification.service</jsonpath></setHeader>
<to uri="jetty:http://remote.service/there"/>
<setBody><simple>{ "status": "http requested", "service": "${header.service}" }</simple></setBody>
</camelContext>
</blueprint>
IoT example: Karaf features
<features name="karaf-acna-iot" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.apache.camel.karaf/apache-camel/2.24.1/xml/features</repository>
<feature name="karaf-acna-iot-common" version="1.0">
<feature prerequisite="true">aries-blueprint</feature>
<feature>camel-blueprint</feature>
<feature>camel-jetty</feature>
<feature>camel-jsonpath</feature>
</feature>
<feature name="karaf-acna-iot" version="1.0">
<feature>karaf-acna-iot-common</feature>
<bundle>blueprint:mvn:org.apache.acna/karaf-iot/1.0/xml/route</bundle>
</feature>
</features>
Microservice in Karaf
● OSGi service model fits perfectly with micro-service approach
● JAXRS whiteboard easily exposes OSGi services as REST services
● Leverage CXF under the hood with all great features supported by CXF
● Scale with Karaf Cellar DOSGi/RemoteImpl
● Karaf can mix integration/IoT/applications in the same platform
Microservice example: JAXRS
Whiteboard
@Path("/booking")
@Component(service = BookingServiceRest.class, property = {
"osgi.jaxrs.resource=true" })
public class BookingServiceRest implements BookingService {
private final Map<Long, Booking> bookings = new
HashMap<>();
@Override
@Path("/")
@Produces("application/json")
@GET
public Collection<Booking> list() {
return bookings.values();
}
@Override
@Path("/{id}")
@Produces("application/json")
@GET
public Booking get(@PathParam("id") Long id) {
return bookings.get(id);
}
@Override
@Path("/")
@Consumes("application/json")
@POST
public void add(Booking booking) {
bookings.put(booking.getId(), booking);
}
}
Microservice example: Karaf features
<features name="karaf-acna-microservice" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/1.0.3/xml</repository>
<feature name="karaf-acna-microservice" version="1.0">
<feature>http-whiteboard</feature>
<feature>aries-jax-rs-whiteboard</feature>
<feature>aries-jax-rs-whiteboard-jackson</feature>
<bundle>mvn:org.apache.acna/karaf-acna-microservice/1.0</bundle>
</feature>
</features>
Dynamic, custom, static distributions
● You have different ways to use Karaf depending of the provisioning you want.
● Karaf and applications can be “assembly” in different kind of distributions
● Any distribution is available as a archive or can be packaged as a Docker image
● We can distinguish three kind of distributions:
○ Dynamic distribution (standard one)
○ Custom distribution (based on dynamic)
○ Static distribution
● It’s the standard distribution you can download from Karaf website
● Fully administrable via the shell console (ssh) or web console
● The lifecycle is the following:
○ Download Apache Karaf from karaf.apache.org
○ Copy the archive where you want and extract
○ Run Karaf
○ Deploy applications on the running Karaf instance
$ curl -O https://www-eu.apache.org/dist/karaf/4.2.6/apache-karaf-4.2.6.tar.gz
$ tar zxvf apache-karaf-4.2.6.tar.gz
$ cd apache-karaf-4.2.6
$ ./bin/karaf
…
karaf@root()> feature:repo-add …
karaf@root()> feature:install ...
Dynamic distribution (mutable)
Download, run, deploy
Dynamic distribution and Docker
● Apache Karaf official Docker images available on Apache DockerHub
● You can create your Docker image based on any Karaf standard distribution thanks to
script provided: https://github.com/apache/karaf/tree/master/assemblies/docker
$ ./build.sh --from-release --karaf-version 4.2.6 --image-name my-karaf
Downloading apache-karaf-4.2.6.tar.gz from https://www-us.apache.org/dist/karaf/4.2.6/
Sending build context to Docker daemon 21.29MB
...
Successfully built d209a00ef33c
Successfully tagged my-karaf:latest
$ docker images|grep my-karaf
my-karaf latest d209a00ef33c About a minute ago 467MB
● You can create a Docker image directly on a running Karaf instance using the
docker:provision Karaf command
karaf@root()> feature:install docker
karaf@root()> docker:provision mykaraf
● Similar to dynamic distribution but “pre-packaged” to include some “boot” applications
● It also support the deployment at runtime (like the dynamic distribution)
● Karaf tooling and features allows you to easily create your own custom distribution and
docker image
Custom distribution (mutable)
Download, extend, run, optionally deploy
Create your own custom dynamic
runtime powered by Apache Karaf
● Use an existing features.xml or generate a features XML for your application
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>features-generate-descriptor</goal>
</goals>
<configuration>
<includeProjectArtifact>true</includeProjectArtifact>
</configuration>
</execution>
</executions>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:features xmlns:ns2="http://karaf.apache.org/xmlns/features/v1.6.0"
name="karaf-acna-app">
<ns2:feature name="karaf-acna-app" version="1.0.SNAPSHOT">
<ns2:bundle>mvn:org.apache.acna/karaf-acna-app/1.0-SNAPSHOT</ns2:bundle>
</ns2:feature>
</ns2:features>
● Generate archive, Dockerfile or even Docker image
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>process-resources</id>
<phase>process-resources</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
<execution>
<id>package</id>
<goals>
<goal>archive</goal>
</goals>
</execution>
<execution>
<id>dockerfile</id>
<goals>
<goal>dockerfile</goal>
</goals>
<configuration>
<command>["karaf"]</command>
</configuration>
</execution>
<execution>
<id>docker-image</id>
<goals>
<goal>docker</goal>
</goals>
</execution>
</executions>
<configuration>
<configuration>
<imageName>acna</imageName>
</configuration>
<bootFeatures>
...
<feature>karaf-acna-app</feature>
</bootFeatures>
<javase>1.8</javase>
</configuration>
</plugin>
Dynamic runtime packages and run
● Ready to use tar.gz & zip archives
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
karaf-acna-dynamic latest 13fb21f44dfc 7 seconds ago 485MB
$ docker run --name mykaraf -a -t karaf-acna-dynamic
…
karaf@root()>
● Ready to use Dockerfile
● Ready to use Docker image
$ tar zxvf acna-dynamic.tar.gz && cd acna-dynamic
$ ./bin/karaf
...
karaf@root()>
● This time, Karaf and your applications are packaged all together at build time
● Not deployment at runtime, all is prepared at build
● It’s similar to spring-boot approach
● Very convenient for docker/microservice provisioning
● Karaf tooling and features to easily create the static distribution and the docker image
Static distribution (immutable)
Build, run
Create your own static runtime
powered by Apache Karaf
● Can start like custom distribution using existing features or generating the features
descriptor for your application
● Karaf tooling package all in a “static” package and can create the Docker image
● Static means that all resolution is performed at build time: the execution is full static,
predictable, all resolved.
● It’s similar to spring-boot approach.
● We start from the same as dynamic distribution: a Karaf features XML
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
...
</executions>
<configuration>
<startupFeatures>
<startupFeature>static-framework</startupFeature>
<startupFeature>scr</startupFeature>
<startupFeature>http-whiteboard</startupFeature>
<startupFeature>karaf-docker-example-app</startupFeature>
</startupFeatures>
<framework>static</framework>
<useReferenceUrls>true</useReferenceUrls>
<environment>static</environment>
</configuration>
</plugin>
</plugins>
</build>
● Generate archive, Dockerfile or even Docker image
Static runtime packages and run
● Ready to use tar.gz & zip archives
● Ready to use Dockerfile
● Ready to use Docker image
$ tar zxvf acna-static.tar.gz && cd acna-static
$ ./bin/karaf run
Sep 06, 2019 9:08:55 AM org.apache.karaf.main.Main launch
...
$ docker run --name mykaraf -d karaf-docker-example-static-dist
karaf: Ignoring predefined value for KARAF_HOME
Sep 06, 2019 7:14:34 AM org.apache.karaf.main.Main launch
...
Karaf on cloud VM (EC2, …)
● Like on prem:
○ Create virtual machine
○ Upload Karaf
○ Start Karaf
● Can work with dynamic, custom, or static distribution
Karaf on EC2
Karaf on EC2
ssh -i "karaf.pem" ec2-user@ec2-63-35-225-69.eu-west-1.compute.amazonaws.com
Last login: Thu Sep 5 13:11:24 2019 from 82-64-90-43.subs.proxad.net
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|___|___|
https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-3-164 ~]$ cd karaf/bin
[ec2-user@ip-172-31-3-164 ~/karaf]$ ./karaf
Karaf on cloud VMs with Cellar (EC2, …)
● Several VMs with Karaf runtimes, install Cellar on each
instance
● No SPOF
● Cellar is able to sync (features, applications, configurations)
between Karaf runtimes
● Support cluster groups to target deployment
● Support RPC between Karaf runtimes
Karaf on Cloud (ECR/ECS, …)
Push your Karaf Docker image (dynamic or static) on a Docker Registry (for instance ECR)
● Create a ECR repository
Karaf on Cloud - ECR
Karaf on Cloud - ECR
● Tag your Karaf image
$ docker tag acna:latest 295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna:latest
● Push Karaf Docker image on AWS ECR
$ docker push 295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna:latest
The push refers to repository [295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna]
4fa480d86d2e: Pushing [=> ] 447.5kB/21.33MB
...
Karaf on Cloud - ECR
● Karaf image is now available on AWS ECR
Karaf on Cloud - ECS
● Running our Karaf based runtime on AWS ECS
Karaf on Cloud - ECS
Karaf on Cloud - ECS
Karaf on Cloud - ECS
Karaf on Cloud - ECS
Karaf on Cloud - ECS
Karaf on Cloud - ECS
Karaf with Kubernetes (EKS, …)
● Push your Karaf based runtime on Docker registry (ECR)
● Use or create a Kubernetes cluster
Karaf on Cloud - EKS
● Use the “regular” kubectl command to create the deployment
$ kubectl run karaf --image=aws...acna:latest --port=8181
$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
karaf 1/1 1 1 44s
$ kubectl logs karaf-cc9c6bd5d-6wbzk
karaf: Ignoring predefined value for KARAF_HOME
Jun 25, 2019 12:52:29 PM org.apache.karaf.main.Main launch
● expose a service
$ kubectl expose deployment/karaf --type="NodePort" --port=8181
service/karaf exposed
● scale up and down
$ kubectl scale deployments/karaf --replicas=2
NAME READY UP-TO-DATE AVAILABLE AGE
karaf 2/2 2 2 4m34s
Karaf on cloud: current state and
roadmap
● Even easier way to create distributions/runtimes
● New tooling (CLI, Gradle, ..) in addition of the Karaf Maven plugin
● Tooling to create K8S deployment model (HELM packages ?)
● Improved K8S support in Cellar for even better scalability
Karaf Community
● WELCOME to Karaf !
● We love contributions and ideas !
● Updated website
● Periodical release cycle (~ every 3 months)
Powered by Karaf (some ;) )
Apache
http://karaf.apache.org
GitHub mirrors:
https://github.com/apache/karaf
https://github.com/apache/karaf-cellar
https://github.com/apache/karaf-cave
https://github.com/apache/karaf-decanter
https://github.com/jbonofre/karaf-boot
https://github.com/jbonofre/karaf-vineyard
Mailing Lists:
users@karaf.apache.org
dev@karaf.apache.org

More Related Content

What's hot

What's hot (20)

ApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platformApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platform
 
JEEConf 2018 - Camel microservices with Spring Boot and Kubernetes
JEEConf 2018 - Camel microservices with Spring Boot and KubernetesJEEConf 2018 - Camel microservices with Spring Boot and Kubernetes
JEEConf 2018 - Camel microservices with Spring Boot and Kubernetes
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migration
 
"Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ..."Continuously delivering infrastructure using Terraform and Packer" training ...
"Continuously delivering infrastructure using Terraform and Packer" training ...
 
Integrating systems in the age of Quarkus and Camel
Integrating systems in the age of Quarkus and CamelIntegrating systems in the age of Quarkus and Camel
Integrating systems in the age of Quarkus and Camel
 
Terraform – Infrastructure as Code (Kielux'18)
Terraform – Infrastructure as Code (Kielux'18)Terraform – Infrastructure as Code (Kielux'18)
Terraform – Infrastructure as Code (Kielux'18)
 
Apache Camel Introduction & What's in the box
Apache Camel Introduction & What's in the boxApache Camel Introduction & What's in the box
Apache Camel Introduction & What's in the box
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetes
 
Apache development with GitHub and Travis CI
Apache development with GitHub and Travis CIApache development with GitHub and Travis CI
Apache development with GitHub and Travis CI
 
Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2Apache Camel K - Copenhagen v2
Apache Camel K - Copenhagen v2
 
Apache Camel K - Fredericia
Apache Camel K - FredericiaApache Camel K - Fredericia
Apache Camel K - Fredericia
 
CamelOne 2013 Karaf A-MQ Camel CXF Security
CamelOne 2013 Karaf A-MQ Camel CXF SecurityCamelOne 2013 Karaf A-MQ Camel CXF Security
CamelOne 2013 Karaf A-MQ Camel CXF Security
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
 
Apache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel QuarkusApache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel Quarkus
 
Terraform + ansible talk
Terraform + ansible talkTerraform + ansible talk
Terraform + ansible talk
 
Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...
 
Terraform
TerraformTerraform
Terraform
 
What's new with Apache Camel 3? | DevNation Tech Talk
What's new with Apache Camel 3? | DevNation Tech TalkWhat's new with Apache Camel 3? | DevNation Tech Talk
What's new with Apache Camel 3? | DevNation Tech Talk
 
Developingapiplug insforcs-151112204727-lva1-app6891
Developingapiplug insforcs-151112204727-lva1-app6891Developingapiplug insforcs-151112204727-lva1-app6891
Developingapiplug insforcs-151112204727-lva1-app6891
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 

Similar to ApacheCon NA '19 - Apache karaf on cloud, the kloud initiative

Similar to ApacheCon NA '19 - Apache karaf on cloud, the kloud initiative (20)

2_ESNOG_arista.pptx
2_ESNOG_arista.pptx2_ESNOG_arista.pptx
2_ESNOG_arista.pptx
 
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
Create a Varnish cluster in Kubernetes for Drupal caching - DrupalCon North A...
 
Spinnaker - Bay Area AWS Meetup - 20160726
Spinnaker - Bay Area AWS Meetup - 20160726Spinnaker - Bay Area AWS Meetup - 20160726
Spinnaker - Bay Area AWS Meetup - 20160726
 
Manila, an update from Liberty, OpenStack Summit - Tokyo
Manila, an update from Liberty, OpenStack Summit - TokyoManila, an update from Liberty, OpenStack Summit - Tokyo
Manila, an update from Liberty, OpenStack Summit - Tokyo
 
Backend frx for movmi
Backend frx for movmiBackend frx for movmi
Backend frx for movmi
 
Presentation on Japanese doc sprint
Presentation on Japanese doc sprintPresentation on Japanese doc sprint
Presentation on Japanese doc sprint
 
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
Getting Started With Spark Structured Streaming With Dustin Vannoy | Current ...
 
Bee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installingBee con2016 presentation_20160125004_installing
Bee con2016 presentation_20160125004_installing
 
Introduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunIntroduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud Run
 
Servicemix4.5.0
Servicemix4.5.0Servicemix4.5.0
Servicemix4.5.0
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
 
Hands on with CoAP and Californium
Hands on with CoAP and CaliforniumHands on with CoAP and Californium
Hands on with CoAP and Californium
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
Meetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdfMeetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdf
 
Apache servicemix1
Apache servicemix1Apache servicemix1
Apache servicemix1
 
Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22Getting Started with Spark Structured Streaming - Current 22
Getting Started with Spark Structured Streaming - Current 22
 
2012 09-08-josug-jeff
2012 09-08-josug-jeff2012 09-08-josug-jeff
2012 09-08-josug-jeff
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to Rest
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

ApacheCon NA '19 - Apache karaf on cloud, the kloud initiative

  • 1. Apache Karaf on cloud, The kloud initiative APACHECON North America Sept. 9-12, 2019 JB Onofré jbonofre@apache.org @jbonofre 1
  • 2. Who am I ? Jean-Baptiste Onofré <jbonofre@apache.org> ● Software Engineer/Fellow at Talend ● Member of the Apache Software Foundation ● PMC member and committer for ~ 20 Apache projects (Karaf, Camel, ActiveMQ, Felix, Aries, Beam, Incubator, …)
  • 3. Karaf track at ACNA ‘19 ! Full track about Apache Karaf with three talks: 1. Apache Karaf on Cloud, the kloud initiative (this talk) 2. Serverless: Multi-tenant Rule Engine Service powered by Apache Karaf 3. Customer segmentation and personalization in websites/PWAs using Apache Unomi
  • 4. Why Apache Karaf on cloud ? ● Runtime addressing different use cases ● Provide bunch of “ready-to-use” features ● Can be used on premise or on cloud (easy “move”) ● Support different distribution and packaging to match your requirements (devs/devops) ● Can leverage additional projects to provide extended features (monitoring, cluster, …)
  • 5. Karaf use cases ● Applications (web, backend, …) ● IoT, messaging and integration (Camel, CXF, ActiveMQ, Kafka, ...) ● Micro-services Transverse features: ● Monitoring/Alerting/BAM/Data Collection with Karaf Decanter ● Clustering with Karaf Cellar ● Artifacts repositories with Karaf Cave ● API management with Karaf Vineyard ● CDP with Unomi ● ...
  • 6. Applications in Karaf ● Support applications “frameworks”: core Java, Spring, WebApplication (not necessary OSGi !) ● Easy to migrate from a middleware to Karaf ● Support OSGi applications: micro-service approach internal to Karaf runtime ● “Force” you to implement a clean design of your applications (API, SPI, …) ● Support any OSGi programming model: pure “OSGi”, blueprint, SCR ● Karaf features to extend and provision applications (JPA, JTA, JMS, JDBC, …) ● Also possible to use hot deployment
  • 7. Service based application example: API module public interface BookingService { Collection<Booking> list(); Booking get(Long id); void add(Booking booking); } public class Booking { private Long id; private String customer; private String flight; public Booking(String customer, String flight) throws Exception { this.id = new Random().nextLong(); this.customer = customer; this.flight = flight; } … }
  • 8. Service based application example: service impl (using SCR) @Component public class BookingServiceMemoryImpl implements BookingService { private final Map<Long, Booking> bookings = new HashMap<>(); @Override public Collection<Booking> list() { return bookings.values(); } @Override public Booking get(Long id) { return bookings.get(id); } @Override public void add(Booking booking) { bookings.put(booking.getId(), booking); } }
  • 9. Application example: Karaf features <features name="karaf-acna-2019" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0"> <feature name="karaf-acna-api" version="1.0"> <bundle>mvn:org.apache.acna/karaf-acna-api/1.0</bundle> </feature> <feature name="karaf-acna-service" version="1.0"> <feature>karaf-acna-api</feature> <feature prerequisite="true">scr</feature> <bundle>mvn:org.apache.acna/karaf-acna-service/1.0</bundle> </feature> </features>
  • 10. IoT and integration in Karaf ● Support Apache Camel as integration framework ○ Provide more than 100 of Camel components as Karaf features ○ EIPs ○ Data Formats ● Easy to install and start with, supporting DSLs ● Use the same Karaf features provisioning mechanism ● Support hot deployment ● Support MoM with ActiveMQ, Kafka, … ● Support web/rest service with CXF
  • 11. IoT example: camel blueprint DSL <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route id="example-http-inbound"> <from uri="jetty:http://0.0.0.0:9090/example"/> <convertBodyTo type="java.lang.String"/> <log message="[EXAMPLE INBOUND] Received: ${body}"/> <setHeader headerName="service"><jsonpath>$.notification.service</jsonpath></setHeader> <to uri="jetty:http://remote.service/there"/> <setBody><simple>{ "status": "http requested", "service": "${header.service}" }</simple></setBody> </camelContext> </blueprint>
  • 12. IoT example: Karaf features <features name="karaf-acna-iot" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0"> <repository>mvn:org.apache.camel.karaf/apache-camel/2.24.1/xml/features</repository> <feature name="karaf-acna-iot-common" version="1.0"> <feature prerequisite="true">aries-blueprint</feature> <feature>camel-blueprint</feature> <feature>camel-jetty</feature> <feature>camel-jsonpath</feature> </feature> <feature name="karaf-acna-iot" version="1.0"> <feature>karaf-acna-iot-common</feature> <bundle>blueprint:mvn:org.apache.acna/karaf-iot/1.0/xml/route</bundle> </feature> </features>
  • 13. Microservice in Karaf ● OSGi service model fits perfectly with micro-service approach ● JAXRS whiteboard easily exposes OSGi services as REST services ● Leverage CXF under the hood with all great features supported by CXF ● Scale with Karaf Cellar DOSGi/RemoteImpl ● Karaf can mix integration/IoT/applications in the same platform
  • 14. Microservice example: JAXRS Whiteboard @Path("/booking") @Component(service = BookingServiceRest.class, property = { "osgi.jaxrs.resource=true" }) public class BookingServiceRest implements BookingService { private final Map<Long, Booking> bookings = new HashMap<>(); @Override @Path("/") @Produces("application/json") @GET public Collection<Booking> list() { return bookings.values(); } @Override @Path("/{id}") @Produces("application/json") @GET public Booking get(@PathParam("id") Long id) { return bookings.get(id); } @Override @Path("/") @Consumes("application/json") @POST public void add(Booking booking) { bookings.put(booking.getId(), booking); } }
  • 15. Microservice example: Karaf features <features name="karaf-acna-microservice" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0"> <repository>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/1.0.3/xml</repository> <feature name="karaf-acna-microservice" version="1.0"> <feature>http-whiteboard</feature> <feature>aries-jax-rs-whiteboard</feature> <feature>aries-jax-rs-whiteboard-jackson</feature> <bundle>mvn:org.apache.acna/karaf-acna-microservice/1.0</bundle> </feature> </features>
  • 16. Dynamic, custom, static distributions ● You have different ways to use Karaf depending of the provisioning you want. ● Karaf and applications can be “assembly” in different kind of distributions ● Any distribution is available as a archive or can be packaged as a Docker image ● We can distinguish three kind of distributions: ○ Dynamic distribution (standard one) ○ Custom distribution (based on dynamic) ○ Static distribution
  • 17. ● It’s the standard distribution you can download from Karaf website ● Fully administrable via the shell console (ssh) or web console ● The lifecycle is the following: ○ Download Apache Karaf from karaf.apache.org ○ Copy the archive where you want and extract ○ Run Karaf ○ Deploy applications on the running Karaf instance $ curl -O https://www-eu.apache.org/dist/karaf/4.2.6/apache-karaf-4.2.6.tar.gz $ tar zxvf apache-karaf-4.2.6.tar.gz $ cd apache-karaf-4.2.6 $ ./bin/karaf … karaf@root()> feature:repo-add … karaf@root()> feature:install ... Dynamic distribution (mutable) Download, run, deploy
  • 18. Dynamic distribution and Docker ● Apache Karaf official Docker images available on Apache DockerHub ● You can create your Docker image based on any Karaf standard distribution thanks to script provided: https://github.com/apache/karaf/tree/master/assemblies/docker $ ./build.sh --from-release --karaf-version 4.2.6 --image-name my-karaf Downloading apache-karaf-4.2.6.tar.gz from https://www-us.apache.org/dist/karaf/4.2.6/ Sending build context to Docker daemon 21.29MB ... Successfully built d209a00ef33c Successfully tagged my-karaf:latest $ docker images|grep my-karaf my-karaf latest d209a00ef33c About a minute ago 467MB ● You can create a Docker image directly on a running Karaf instance using the docker:provision Karaf command karaf@root()> feature:install docker karaf@root()> docker:provision mykaraf
  • 19. ● Similar to dynamic distribution but “pre-packaged” to include some “boot” applications ● It also support the deployment at runtime (like the dynamic distribution) ● Karaf tooling and features allows you to easily create your own custom distribution and docker image Custom distribution (mutable) Download, extend, run, optionally deploy
  • 20. Create your own custom dynamic runtime powered by Apache Karaf ● Use an existing features.xml or generate a features XML for your application <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>karaf-maven-plugin</artifactId> <executions> <execution> <goals> <goal>features-generate-descriptor</goal> </goals> <configuration> <includeProjectArtifact>true</includeProjectArtifact> </configuration> </execution> </executions> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:features xmlns:ns2="http://karaf.apache.org/xmlns/features/v1.6.0" name="karaf-acna-app"> <ns2:feature name="karaf-acna-app" version="1.0.SNAPSHOT"> <ns2:bundle>mvn:org.apache.acna/karaf-acna-app/1.0-SNAPSHOT</ns2:bundle> </ns2:feature> </ns2:features>
  • 21. ● Generate archive, Dockerfile or even Docker image <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>karaf-maven-plugin</artifactId> <executions> <execution> <id>process-resources</id> <phase>process-resources</phase> <goals> <goal>assembly</goal> </goals> </execution> <execution> <id>package</id> <goals> <goal>archive</goal> </goals> </execution> <execution> <id>dockerfile</id> <goals> <goal>dockerfile</goal> </goals> <configuration> <command>["karaf"]</command> </configuration> </execution> <execution> <id>docker-image</id> <goals> <goal>docker</goal> </goals> </execution> </executions> <configuration> <configuration> <imageName>acna</imageName> </configuration> <bootFeatures> ... <feature>karaf-acna-app</feature> </bootFeatures> <javase>1.8</javase> </configuration> </plugin>
  • 22. Dynamic runtime packages and run ● Ready to use tar.gz & zip archives $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE karaf-acna-dynamic latest 13fb21f44dfc 7 seconds ago 485MB $ docker run --name mykaraf -a -t karaf-acna-dynamic … karaf@root()> ● Ready to use Dockerfile ● Ready to use Docker image $ tar zxvf acna-dynamic.tar.gz && cd acna-dynamic $ ./bin/karaf ... karaf@root()>
  • 23. ● This time, Karaf and your applications are packaged all together at build time ● Not deployment at runtime, all is prepared at build ● It’s similar to spring-boot approach ● Very convenient for docker/microservice provisioning ● Karaf tooling and features to easily create the static distribution and the docker image Static distribution (immutable) Build, run
  • 24. Create your own static runtime powered by Apache Karaf ● Can start like custom distribution using existing features or generating the features descriptor for your application ● Karaf tooling package all in a “static” package and can create the Docker image ● Static means that all resolution is performed at build time: the execution is full static, predictable, all resolved. ● It’s similar to spring-boot approach. ● We start from the same as dynamic distribution: a Karaf features XML
  • 26. Static runtime packages and run ● Ready to use tar.gz & zip archives ● Ready to use Dockerfile ● Ready to use Docker image $ tar zxvf acna-static.tar.gz && cd acna-static $ ./bin/karaf run Sep 06, 2019 9:08:55 AM org.apache.karaf.main.Main launch ... $ docker run --name mykaraf -d karaf-docker-example-static-dist karaf: Ignoring predefined value for KARAF_HOME Sep 06, 2019 7:14:34 AM org.apache.karaf.main.Main launch ...
  • 27. Karaf on cloud VM (EC2, …) ● Like on prem: ○ Create virtual machine ○ Upload Karaf ○ Start Karaf ● Can work with dynamic, custom, or static distribution
  • 29. Karaf on EC2 ssh -i "karaf.pem" ec2-user@ec2-63-35-225-69.eu-west-1.compute.amazonaws.com Last login: Thu Sep 5 13:11:24 2019 from 82-64-90-43.subs.proxad.net __| __|_ ) _| ( / Amazon Linux 2 AMI ___|___|___| https://aws.amazon.com/amazon-linux-2/ [ec2-user@ip-172-31-3-164 ~]$ cd karaf/bin [ec2-user@ip-172-31-3-164 ~/karaf]$ ./karaf
  • 30. Karaf on cloud VMs with Cellar (EC2, …) ● Several VMs with Karaf runtimes, install Cellar on each instance ● No SPOF ● Cellar is able to sync (features, applications, configurations) between Karaf runtimes ● Support cluster groups to target deployment ● Support RPC between Karaf runtimes
  • 31. Karaf on Cloud (ECR/ECS, …) Push your Karaf Docker image (dynamic or static) on a Docker Registry (for instance ECR) ● Create a ECR repository
  • 32. Karaf on Cloud - ECR
  • 33. Karaf on Cloud - ECR ● Tag your Karaf image $ docker tag acna:latest 295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna:latest ● Push Karaf Docker image on AWS ECR $ docker push 295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna:latest The push refers to repository [295331841498.dkr.ecr.eu-west-1.amazonaws.com/acna] 4fa480d86d2e: Pushing [=> ] 447.5kB/21.33MB ...
  • 34. Karaf on Cloud - ECR ● Karaf image is now available on AWS ECR
  • 35. Karaf on Cloud - ECS ● Running our Karaf based runtime on AWS ECS
  • 36. Karaf on Cloud - ECS
  • 37. Karaf on Cloud - ECS
  • 38. Karaf on Cloud - ECS
  • 39. Karaf on Cloud - ECS
  • 40. Karaf on Cloud - ECS
  • 41. Karaf on Cloud - ECS
  • 42. Karaf with Kubernetes (EKS, …) ● Push your Karaf based runtime on Docker registry (ECR) ● Use or create a Kubernetes cluster
  • 43. Karaf on Cloud - EKS ● Use the “regular” kubectl command to create the deployment $ kubectl run karaf --image=aws...acna:latest --port=8181 $ kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE karaf 1/1 1 1 44s $ kubectl logs karaf-cc9c6bd5d-6wbzk karaf: Ignoring predefined value for KARAF_HOME Jun 25, 2019 12:52:29 PM org.apache.karaf.main.Main launch ● expose a service $ kubectl expose deployment/karaf --type="NodePort" --port=8181 service/karaf exposed ● scale up and down $ kubectl scale deployments/karaf --replicas=2 NAME READY UP-TO-DATE AVAILABLE AGE karaf 2/2 2 2 4m34s
  • 44. Karaf on cloud: current state and roadmap ● Even easier way to create distributions/runtimes ● New tooling (CLI, Gradle, ..) in addition of the Karaf Maven plugin ● Tooling to create K8S deployment model (HELM packages ?) ● Improved K8S support in Cellar for even better scalability
  • 45. Karaf Community ● WELCOME to Karaf ! ● We love contributions and ideas ! ● Updated website ● Periodical release cycle (~ every 3 months)
  • 46. Powered by Karaf (some ;) )