riga dev day 2016 - microservices with apache camel & fabric8 on kubernetes
TRANSCRIPT
![Page 1: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/1.jpg)
Microservices with
Apache Camel & fabric8 on Kubernetes
Claus Ibsen
@davsclaus davsclaus
davsclaus.com
![Page 2: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/2.jpg)
I was here in 2011
![Page 3: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/3.jpg)
Claus Ibsen• Principal Software Engineer
at Red Hat
• Apache Camel8 years working with Camel
• Author of Camel in Action books
@davsclaus davsclaus
davsclaus.com
![Page 4: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/4.jpg)
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
![Page 5: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/5.jpg)
Twitter Example
• Twitter search w/ keyword
• Live update web page
![Page 6: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/6.jpg)
Twitter Example
![Page 7: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/7.jpg)
Twitter Example• camel-core
• camel-twitter
• 2 java classes
• 1 html page
• 1 maven pom.xml
![Page 8: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/8.jpg)
Main Class
![Page 9: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/9.jpg)
Camel Route
![Page 10: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/10.jpg)
Camel Route (cont.)
![Page 11: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/11.jpg)
html
![Page 12: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/12.jpg)
pom.xml
![Page 13: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/13.jpg)
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservice with Kubernetes
• More Information
![Page 14: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/14.jpg)
![Page 15: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/15.jpg)
![Page 16: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/16.jpg)
![Page 17: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/17.jpg)
?
![Page 18: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/18.jpg)
?
![Page 19: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/19.jpg)
OS Level Virtualisation
Docker Orchestration
PaaS Platform on top of Kubernetes
Services and Tools forKubernetes and OpenShift
![Page 20: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/20.jpg)
kubernetes
![Page 21: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/21.jpg)
Kubernetes
‣ Open Source orchestration platform for Docker containers
• Rewrite of Google’s internal framework “Borg”‣ Declarative specification of a desired state‣ Self-healing‣ Service discovery‣ Scheduling across hosts‣ Replication
![Page 22: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/22.jpg)
Architecture
![Page 23: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/23.jpg)
Concepts
‣Pods• Collection of one or more Docker containers‣Replication Controller
• Creates and takes care of Pods‣Services
• Proxy for a collection of Pods‣Labels
• Grouping and organization of Objects‣Namespaces
• Virtual clusters backend by same physical cluster
![Page 24: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/24.jpg)
Pod
‣ Collection of Docker containers running on the same host.
‣ Pods have unique IPs‣ Containers in a Pod ….
• …. share the same IP address• …. can reach each other via local ports• …. can share data via volumes‣ Pods can have one or more Labels
![Page 25: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/25.jpg)
Replication Controller
‣ Controls Pods selected by Labels‣ Ensures that a specified number of Pod replicas is
running‣ Holds Pod templates for creating new Pods‣ Autoscaling‣ Rolling Updates
![Page 26: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/26.jpg)
Service
‣ View on a set of Pods with single IP address and port
‣ Pods are selected by Label‣ Services are referenced by
environment variables‣ Service addresses stay stable
• Pods come and go (with different IPs)
![Page 27: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/27.jpg)
![Page 28: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/28.jpg)
fabric8
‣ Tools and Services for value add to Kubernetes and OpenShift
• Management: console, logging, metrics, dashboards, …• Continuous Delivery Workflow• iPaaS: Camel route visualization, API registry, Messaging as
a Service, …• Tools: Kubernetes/OpenShift build integration, Kubernetes
component test support, CDI extensions• Quickstarts: Ready to use examples, also available as
Maven archetypes
![Page 29: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/29.jpg)
Agenda
• Apache Camel Introduction
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
![Page 30: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/30.jpg)
Hello Service
Hello Service
![Page 31: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/31.jpg)
Hello Service
Hello Service
name=Claus
Hello Claus how are you today?
![Page 32: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/32.jpg)
Implementation
Hello Service
Camel CDI Apache Tomcat
HTTP
![Page 33: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/33.jpg)
Implementation
Camel CDI Apache Tomcat
HTTP
from timer to http to log
from servlet transform
hello service
![Page 34: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/34.jpg)
Apache Tomcat
![Page 35: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/35.jpg)
Camel CDI
![Page 36: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/36.jpg)
CounterBean
![Page 37: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/37.jpg)
Ready to run local
Camel CDI Apache Tomcat
HTTP 8080
from timer to netty to log
from servlet transform
hello service
![Page 38: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/38.jpg)
How to build Docker Image?
Maven Project Docker Image
![Page 39: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/39.jpg)
Docker Maven Plugin
Maven Project Docker Maven Plugin Docker Imagebuild
![Page 40: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/40.jpg)
Docker Maven Plugin in pom.xml
![Page 41: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/41.jpg)
Build Docker Imagemvn clean install docker:build
![Page 42: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/42.jpg)
Local Docker Repository
Apache Tomcat
Camel CDI
![Page 43: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/43.jpg)
Our Demo
Camel CDI Apache Tomcat
HTTP 8080
from timer to http to log
from servlet transform
hello service
![Page 44: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/44.jpg)
Static vs Dynamic Platform
Camel CDI Apache Tomcat
HTTP 8080
from timer to http to log
from servlet transform
hello service
Hardcoded hostname and port
![Page 45: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/45.jpg)
Dynamic Platform
Apache Tomcat
HTTP 8080
Camel CDI
from timer to http to log
from servlet transform
hello service
Kubernetes Service
![Page 46: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/46.jpg)
Kubernetes Service• Network Connection to one or more Pods
• Own fixed IP address and port
![Page 47: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/47.jpg)
Kubernetes Service
HTTP 8080
from timer to http to log
from servlet transform
hello service
kube proxy
Kubernetes Master
enlisted on deployment
changes
pod
node
pod
node
![Page 48: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/48.jpg)
Kubernetes Servicefrom user point of view
service ip:port
from timer to http to log
from servlet transform
hello service
pod pod
![Page 49: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/49.jpg)
Service defined in pom.xml
Apache Tomcat
from servlet transform
hello serviceContainer Port =
Inside
Service Port = Outside
![Page 50: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/50.jpg)
Using Kubernetes Service
Camel CDI
from timer to http to log
We want to use hello service
How do we do that?
![Page 51: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/51.jpg)
Using Kubernetes Service
• Environment Variables
• Hostname
• Port
Camel CDI
from timer to http to log
Service Discovery using DNS is available in newer versions of Kubernetes.
![Page 52: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/52.jpg)
Camel using service
• Use {{service:hello}} Camel CDI
from timer to http to log
![Page 53: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/53.jpg)
Ready to run in Kubernetes
Camel CDI Apache Tomcat
service:hello
from timer to netty to log
from servlet transform
hello service
kube proxy
![Page 54: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/54.jpg)
How to deploy to Kubernetes?
Maven Project
![Page 55: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/55.jpg)
How to deploy to Kubernetes?
Maven Project fabric8 Maven Plugin
apply
![Page 56: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/56.jpg)
Deploy - myweb
Apache Tomcat
from servlet transform
hello service• mvn -Pf8-local-deploy
![Page 57: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/57.jpg)
Deploy - mycdi
• mvn -Pf8-local-deploy Camel CDI
from timer to http to log
![Page 58: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/58.jpg)
fabric8 web console
![Page 59: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/59.jpg)
OpenShift CLI• oc get pods
You can also use CLI from docker
kubernetes
![Page 60: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/60.jpg)
OpenShift CLI• oc get services
![Page 61: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/61.jpg)
OpenShift CLI• oc logs -f <pod name>
![Page 62: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/62.jpg)
OpenShift CLI• oc get routes
![Page 63: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/63.jpg)
Scaling• Change replication controller replicas
![Page 64: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/64.jpg)
Scaling• Service load balancing
Load balancing is random in newer version of
Kubernetes
![Page 65: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/65.jpg)
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
![Page 66: Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes](https://reader030.vdocument.in/reader030/viewer/2022020213/587081601a28ab57368b66cd/html5/thumbnails/66.jpg)
Links
• What is Apache Camel • http://java.dzone.com/articles/open-source-
integration-apache • hawtio
• http://hawt.io • fabric8
• http://fabric8.io
@davsclaus davsclaus
davsclaus.com