Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin...

76
Developing Cloud Ready Camel Microservices

Transcript of Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin...

Page 1: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Developing Cloud Ready

Camel Microservices

Page 2: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Claus Ibsen• Senior Principal Software Engineer

at Red Hat

• Apache Camel8 years working with Camel

• Author of Camel in Action books

@davsclaus davsclaus

davsclaus.com

Page 3: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Senior Developer vs Real Life

• Completed my first half marathon 3 days ago

Page 4: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Key Message

?

?or

Page 5: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Tip of Iceberg

Page 6: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Running Local OpenShift / Kubernetes

• MiniShift

• OpenShift CDK

• MiniKube (Kubernetes)

Page 7: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Running OpenShift Locally

• Download MiniShifthttps://github.com/minishift/minishift/releases

• Start MiniShiftminishift start --openshift-version v1.5.0

https://www.openshift.org/minishift/

minishift config set openshift-version 1.5.0TIP To force a

specific version

Page 8: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

How I installed OpenShift locally

Page 9: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift Web Console

minishift console

Page 10: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift CLI (oc) Installation

• Instructions from Web Console

Page 11: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Build a Camel Demo

Time

Page 12: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Source Code & Slides

https://github.com/davsclaus/minishift-hello

Page 13: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Hello Service

Hello ServiceClient

Page 14: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Hello Service

Hello Service

Hello I am $HOSTNAME

Client

Page 15: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Implementation

Client Hello Service

HTTP

WildFySwarmSpring Boot WildFly Swarm

Page 16: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Implementation

Hello Service

Client Hello Service

HTTP

Page 17: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Implementation

Client Hello Service

HTTP

from timer to http4

logfrom undertow

transform

hello service

Page 18: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

WildFly Swarm Generator

Page 19: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Hello Service

Page 20: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Hello Service

Page 21: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Spring Boot Starter

Page 22: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Apache Camel IDEA plugin

https://github.com/camel-idea-plugin/camel-idea-plugin

Great plugin for IDEA users

Page 23: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Client

Page 24: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Ready to run local

Client Hello Service

HTTP 8080

from timer to http4

logfrom undertow

transform

hello service

Page 25: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

How to build Docker Image?

Maven Project

Docker Image

Page 26: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Fabric8 Maven Plugin

Maven Project

Fabric8 Maven Plugin

Docker Image

build

https://maven.fabric8.io

Page 27: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

https://maven.fabric8.io

Fabric8 Maven Plugin

Page 28: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

mvn io.fabric8:fabric8-maven-plugin:3.3.5:setup

https://maven.fabric8.io

Installing Fabric8 Maven Plugin

Page 29: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Fabric8 Maven Plugin

Page 30: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Build Docker Image

mvn package fabric8:build

OpenShift S2I Build

Page 31: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift S2I BuildLive

Build Log Output

Page 32: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift S2I Build

Page 33: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

MiniShift Docker Repository

$ docker images REPOSITORY TAG 172.30.1.1:5000/myproject/client latest 172.30.1.1:5000/myproject/helloswarm latest openshift/origin-sti-builder v1.5.0 openshift/origin-deployer v1.5.0 openshift/origin-docker-registry v1.5.0 openshift/origin-haproxy-router v1.5.0 openshift/origin v1.5.0 openshift/origin-pod v1.5.0 fabric8/s2i-java 2.0

Hello Service

Client

TIP Run minishift docker-env to setup Docker CLI

Page 34: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Our Demo

Client Hello Service

http://localhost:8080

from timer to http4

logfrom undertow

transform

hello service

Page 35: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Static vs Dynamic Platform

Client Hello Service

from timer to http4

logfrom undertow

transform

hello service

Hardcoded hostname and port

http://localhost:8080

Page 36: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Hello ServiceClient

from timer to http4

logfrom undertow

transform

hello service

Expose as Kubernetes

Service

Page 37: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Client

hello service

pod

pod

Hello Service

Page 38: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Client

hello service

pod

hello service

pod

pod

Hello Service

Page 39: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Client

hello service

pod

hello service

pod

Service

pod

Hello Service

Page 40: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Client

hello service

pod

hello service

pod

ServiceIP:Port

pod

Hello Service

Static

Page 41: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Dynamic Platform

Client

hello service

pod

hello service

pod

ServiceIP:Port

pod

Hello Service

Static

Dynamic

DynamicDynamic

Page 42: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Kubernetes Service

service ip:port

from timer to http4

logfrom undertow

transform

hello service

kube proxy

Kubernetes Master

enlisted on deployment

changes

pod

node

pod

node

Page 43: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Kubernetes Servicefrom user point of view

service ip:port

from timer to http4

log

pod

from undertow transform

hello service

pod

Page 44: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Using Kubernetes Service

Client

from timer to http4

log

We want to use hello service

How do we do that?

Page 45: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Using Kubernetes Service

• Environment Variables

• Hostname

• Port

Client

from timer to http4

log

Service Discovery using DNS is also available

Page 46: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Service using ENV• {{service:name}} Client

from timer to http4

log

Page 47: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Service using DNS• servicename:port Client

from timer to http4

log

Page 48: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Ready to run in OpenShift

Client Hello Service

{{service:helloswarm}}

from timer to http4

logfrom undertow

transform

hello service

Page 49: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

How to deploy to OpenShift?

Maven Project

Page 50: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

How to deploy to OpenShift?

Maven Project fabric8 Maven Plugin

deploy

Page 51: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Deploy - Hello Service

Hello Service

from undertow transform

hello service

• mvn fabric8:deploy

Page 52: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Deploy - Client

• mvn fabric8:deploy Client

from timer to http4

log

Page 53: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Run - Client

• mvn fabric8:run Client

from timer to http4

logRuns in foreground, tail log,

undeploys when ctrl + c

Page 54: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Debugging• Debugging Pods

mvn fabric8:debug

Page 55: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Remote Debug

Port 5005

Page 56: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Remote Debug

Breakpoint hit

Page 57: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift CLI• oc get pods

You can also use CLI from docker &

kubernetes

Page 58: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift CLI• oc logs -f <pod name>

Page 59: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift CLI• oc get service

Page 60: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

OpenShift CLI• oc get routes

Can call service from your computer

Page 61: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

• minishift openshift service helloswarm -n myproject

Access Service from your computer

Name of project (namespace)

Page 62: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

• Change deployment replicas

Scaling

Page 63: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Scaling• Service load balancing

Load balancing is random

Page 64: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Error Handling• Client Side Retry

service ip:port

from timer to http4

log

pod

from undertow transform

hello service

pod

service ip:port

service ip:port

service ip:port

Page 65: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Error Handling• Client Side Retry

Page 66: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Error Handling• Client Side Retry

Figure by Christian Posta

Thundering Herd Problem

Page 67: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Error Handling• Client Side Circuit Breaker with Hystrix

Page 68: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Error Handling• Client Side Circuit Breaker with Hystrix

Page 69: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Key Message

or

Page 70: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Tip of Iceberg

Figure by Bilgin Ibryam

Page 71: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

More Details

http://developers.redhat.com/promotions/microservices-for-java-developers/

Page 72: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

More Details

https://www.openshift.com/promotions/for-developers.html

Page 73: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Shameless Promotion

http://manning.com/ibsen2

Coupon code: camel39

gives 39% discount

Page 74: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

INTERACT | DISCUSS | DESIGN

CONVERTING A TIBCO BUSINESSWORKS APPLICATION TO APACHE CAMEL

Ashwin Karpe, Integration Practice LeadSundar Rajendran, Architect - Integration

Thursday, May 4, 11:30 AM - 12:15 PM

Located at the Consulting Discovery Zone at the Services Showcase in the Partner Pavilion

To learn more, visit red.ht/discoveryzone

Other Camel Talks

Page 75: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Boot Session Community Central

Wednesday 3-5 pm

Christian Posta

Claus Ibsen

Page 76: Developing Cloud Ready Camel Microservices · 2018-02-06 · APPLICATION TO APACHE CAMEL Ashwin Karpe, Integration Practice Lead Sundar Rajendran, Architect - Integration Thursday,

Links

• MiniShift • https://www.openshift.org/minishift

• fabric8 Maven Tool • https://maven.fabric8.io

• Slides and demo source code • https://github.com/davsclaus/minishift-hello

@davsclaus davsclaus

davsclaus.com