Date post: | 16-Apr-2017 |
Category: |
Software |
Upload: | claus-ibsen |
View: | 1,690 times |
Download: | 1 times |
Microservices with
Apache Camel & fabric8 on Kubernetes
Claus Ibsen
@davsclaus davsclaus
davsclaus.com
I was here in 2011
Claus Ibsen• Principal Software Engineer
at Red Hat
• Apache Camel8 years working with Camel
• Author of Camel in Action books
@davsclaus davsclaus
davsclaus.com
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
Twitter Example
• Twitter search w/ keyword
• Live update web page
Twitter Example
Twitter Example• camel-core
• camel-twitter
• 2 java classes
• 1 html page
• 1 maven pom.xml
Main Class
Camel Route
Camel Route (cont.)
html
pom.xml
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservice with Kubernetes
• More Information
?
?
OS Level Virtualisation
Docker Orchestration
PaaS Platform on top of Kubernetes
Services and Tools forKubernetes and OpenShift
kubernetes
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
Architecture
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
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
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
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)
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
Agenda
• Apache Camel Introduction
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
Hello Service
Hello Service
Hello Service
Hello Service
name=Claus
Hello Claus how are you today?
Implementation
Hello Service
Camel CDI Apache Tomcat
HTTP
Implementation
Camel CDI Apache Tomcat
HTTP
from timer to http to log
from servlet transform
hello service
Apache Tomcat
Camel CDI
CounterBean
Ready to run local
Camel CDI Apache Tomcat
HTTP 8080
from timer to netty to log
from servlet transform
hello service
How to build Docker Image?
Maven Project Docker Image
Docker Maven Plugin
Maven Project Docker Maven Plugin Docker Imagebuild
Docker Maven Plugin in pom.xml
Build Docker Imagemvn clean install docker:build
Local Docker Repository
Apache Tomcat
Camel CDI
Our Demo
Camel CDI Apache Tomcat
HTTP 8080
from timer to http to log
from servlet transform
hello service
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
Dynamic Platform
Apache Tomcat
HTTP 8080
Camel CDI
from timer to http to log
from servlet transform
hello service
Kubernetes Service
Kubernetes Service• Network Connection to one or more Pods
• Own fixed IP address and port
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
Kubernetes Servicefrom user point of view
service ip:port
from timer to http to log
from servlet transform
hello service
pod pod
Service defined in pom.xml
Apache Tomcat
from servlet transform
hello serviceContainer Port =
Inside
Service Port = Outside
Using Kubernetes Service
Camel CDI
from timer to http to log
We want to use hello service
How do we do that?
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.
Camel using service
• Use {{service:hello}} Camel CDI
from timer to http to log
Ready to run in Kubernetes
Camel CDI Apache Tomcat
service:hello
from timer to netty to log
from servlet transform
hello service
kube proxy
How to deploy to Kubernetes?
Maven Project
How to deploy to Kubernetes?
Maven Project fabric8 Maven Plugin
apply
Deploy - myweb
Apache Tomcat
from servlet transform
hello service• mvn -Pf8-local-deploy
Deploy - mycdi
• mvn -Pf8-local-deploy Camel CDI
from timer to http to log
fabric8 web console
OpenShift CLI• oc get pods
You can also use CLI from docker
kubernetes
OpenShift CLI• oc get services
OpenShift CLI• oc logs -f <pod name>
OpenShift CLI• oc get routes
Scaling• Change replication controller replicas
Scaling• Service load balancing
Load balancing is random in newer version of
Kubernetes
Agenda
• Quick Apache Camel Demo
• Kubernetes and fabric8
• Java Microservices with Kubernetes
• More Information
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