Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes

2,047 views

Published on

The so-called experts are saying microservices and containers will change the way we build, maintain, operate, and integrate applications. This talk is intended for Java developers who wants to hear and see how you can develop Java microservices that runs in containers.

This talk uses Apache Camel as the Java library to build microservice architectured applications. At first we introduce you to Apache Camel and show how you can easily get started with Camel on your computer, and build a microservice application that runs on CDI and Spring-Boot.

The second part of this talk is about running Camel (or any Java project) on Docker and Kubernetes.

We start covering the basic concepts you as a Java developer must understand about Kubernetes. Then we show how to migrate Java projects to build as Docker images and deployable on Kubernetes, with help from fabric8 Maven tooling.

You will also hear about how to make your microservices scalable and distributed by leveraging the facilities that Kubernetes provides for truly distributed services with load balancing and location independence.

You will also see how to manage your container using the Kubernetes CLI and the fabric8 web console.

At the end we have a bit of fun with scaling up and down your Camel application to see how resilient the application is, when we kill containers.

This talk is a 50/50 mix between slides and demo.

Published in: Software
  • Why not using the twitter-camel example, instead of hello-world?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes

  1. 1. Microservices with Apache Camel & fabric8 on Kubernetes Claus Ibsen
 @davsclaus davsclaus davsclaus.com
  2. 2. I was here in 2011
  3. 3. Claus Ibsen • Principal Software Engineer
 at Red Hat • Apache Camel
 8 years working with Camel • Author of
 Camel in Action books @davsclaus davsclaus davsclaus.com
  4. 4. Agenda • Quick Apache Camel Demo • Kubernetes and fabric8 • Java Microservices with Kubernetes • More Information
  5. 5. Twitter Example • Twitter search w/ keyword • Live update web page
  6. 6. Twitter Example
  7. 7. Twitter Example • camel-core • camel-twitter • 2 java classes • 1 html page • 1 maven pom.xml
  8. 8. Main Class
  9. 9. Camel Route
  10. 10. Camel Route (cont.)
  11. 11. html
  12. 12. pom.xml
  13. 13. Agenda • Quick Apache Camel Demo • Kubernetes and fabric8 • Java Microservice with Kubernetes • More Information
  14. 14. ?
  15. 15. ?
  16. 16. OS Level Virtualisation Docker Orchestration PaaS Platform on top of Kubernetes Services and Tools for Kubernetes and OpenShift
  17. 17. kubernetes
  18. 18. 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
  19. 19. Architecture
  20. 20. 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
  21. 21. 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
  22. 22. 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
  23. 23. 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)
  24. 24. 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
  25. 25. Agenda • Apache Camel Introduction • Kubernetes and fabric8 • Java Microservices with Kubernetes • More Information
  26. 26. Hello Service Hello Service
  27. 27. Hello Service Hello Service name=Claus Hello Claus how are you today?
  28. 28. Implementation Hello Service Camel CDI Apache Tomcat HTTP
  29. 29. Implementation Camel CDI Apache Tomcat HTTP from timer to http to log from servlet transform helloservice
  30. 30. Apache Tomcat
  31. 31. Camel CDI
  32. 32. CounterBean
  33. 33. Ready to run local Camel CDI Apache Tomcat HTTP 8080 from timer to netty to log from servlet transform helloservice
  34. 34. How to build Docker Image? Maven Project Docker Image
  35. 35. Docker Maven Plugin Maven Project Docker Maven Plugin Docker Image build
  36. 36. Docker Maven Plugin
 in pom.xml
  37. 37. Build Docker Image mvn clean install docker:build
  38. 38. Local Docker Repository Apache Tomcat Camel CDI
  39. 39. Our Demo Camel CDI Apache Tomcat HTTP 8080 from timer to http to log from servlet transform helloservice
  40. 40. Static vs Dynamic Platform Camel CDI Apache Tomcat HTTP 8080 from timer to http to log from servlet transform helloservice Hardcoded hostname and port
  41. 41. Dynamic Platform Apache Tomcat HTTP 8080 Camel CDI from timer to http to log from servlet transform helloservice Kubernetes Service
  42. 42. Kubernetes Service • Network Connection to one or more Pods • Own fixed IP address and port
  43. 43. Kubernetes
 Service HTTP 8080 from timer to http to log from servlet transform helloservice kubeproxy Kubernetes Master enlisted on deployment changes pod node pod node
  44. 44. Kubernetes Service
 from user point of view service ip:port from timer to http to log from servlet transform helloservice pod pod
  45. 45. Service defined
 in pom.xml Apache Tomcat from servlet transform helloservice Container Port = Inside Service Port = Outside
  46. 46. Using Kubernetes Service Camel CDI from timer to http to log We want to use hello service How do we do that?
  47. 47. 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.
  48. 48. Camel using service • Use {{service:hello}} Camel CDI from timer to http to log
  49. 49. Ready to run in Kubernetes Camel CDI Apache Tomcat service:hello from timer to netty to log from servlet transform helloservice kubeproxy
  50. 50. How to deploy to Kubernetes? Maven Project
  51. 51. How to deploy to Kubernetes? Maven Project fabric8 Maven Plugin apply
  52. 52. Deploy - myweb Apache Tomcat from servlet transform helloservice • mvn -Pf8-local-deploy
  53. 53. Deploy - mycdi • mvn -Pf8-local-deploy Camel CDI from timer to http to log
  54. 54. fabric8 web console
  55. 55. OpenShift CLI • oc get pods You can also use CLI from docker kubernetes
  56. 56. OpenShift CLI • oc get services
  57. 57. OpenShift CLI • oc logs -f <pod name>
  58. 58. OpenShift CLI • oc get routes
  59. 59. Scaling • Change replication controller replicas
  60. 60. Scaling • Service load balancing Load balancing is random in newer version of Kubernetes
  61. 61. Agenda • Quick Apache Camel Demo • Kubernetes and fabric8 • Java Microservices with Kubernetes • More Information
  62. 62. 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

×