Apache Camel in the belly of the Docker whale
-
Upload
henryk-konsek -
Category
Technology
-
view
5.165 -
download
5
description
Transcript of Apache Camel in the belly of the Docker whale
![Page 1: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/1.jpg)
in the belly of the
![Page 2: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/2.jpg)
Brought to you by...
![Page 3: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/3.jpg)
What is...
Server for running and managing Linux containers.
![Page 4: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/4.jpg)
What are Linux containers?
Para-virtualized Linux instances.
![Page 5: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/5.jpg)
Why not regular virtualization?
● slooooooow● gigantic images● aggressive resource allocation● bad API
![Page 6: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/6.jpg)
Key concepts
● image (immutable, no state)● container (has state)
Container is the running image.
![Page 7: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/7.jpg)
Docker awesomeness #1
Commands.
![Page 8: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/8.jpg)
Docker awesomeness #2
Layers.
WAR
Tomcat
JRE
Ubuntu base
![Page 9: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/9.jpg)
Docker awesomeness #3
Registries.
![Page 10: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/10.jpg)
Docker awesomeness #4
Build once. Deploy everywhere!
![Page 11: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/11.jpg)
Dockerfiles
“Recipes” for the new images.
FROM ubuntu
EXPOSE 8080
RUN apt-get install java
RUN mkdir /jars
ADD target/app.jar /jars/
CMD ["java", "-jar", "/jars/app.jar"]
![Page 12: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/12.jpg)
Create new image in the local repo
$ docker build -t com.me/app:1.0
$ docker run -t com.me/app:1.0
![Page 13: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/13.jpg)
Apache Camel
Framework that routes messages like crazy.
![Page 14: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/14.jpg)
How to deploy Camel?
● Karaf (JBoss Fuse, ServiceMix, Talend ESB)● Tomcat● WildFly (JBoss EAP)● standalone/embeded● Akka plugin● Grails plugin● Spring Boot
![Page 15: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/15.jpg)
Camel and Docker
How to split it? What should I dockerize?
![Page 16: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/16.jpg)
Messaging architecture in a nutshell
![Page 17: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/17.jpg)
Concrete messaging architecture
![Page 18: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/18.jpg)
![Page 19: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/19.jpg)
Dockerized example
![Page 20: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/20.jpg)
In-endpoint routefrom(“netty-http:http://0.0.0.0:18080”).
setBody(randomUUID()).
inOnly("jms:invoices");
...
new ActiveMQConnectionFactory("tcp://amqbroker:6162")
![Page 21: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/21.jpg)
Processing routefrom("jms:invoices").
setBody().
groovy("new Invoice(request.body,currentTimeMillis())").
to("mongodb:mongo?...operation=insert");
...
new ActiveMQConnectionFactory("tcp://amqbroker:6162");
...
new MongoClient("mongodb");
![Page 22: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/22.jpg)
How can I get database images?
docker run -d -p 27017:27017
--name mongodb dockerfile/mongodb
Provided by database community/vendor.
![Page 23: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/23.jpg)
How can I put fresh jar into image?
Docker Maven plugin by Roland ‘Jolokia’ Huß
![Page 24: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/24.jpg)
How to bootstrap Camel?
● no Karaf bundle activators● no server (Tomcat, etc.)● how can we start CamelContext?
![Page 25: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/25.jpg)
Custom class with the main method
![Page 26: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/26.jpg)
Spring Boot for Camel
http://projects.spring.io/spring-boot
![Page 27: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/27.jpg)
Camel + Spring Boot: step #1
Take a Spring Boot fat jar.
![Page 28: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/28.jpg)
Camel + Spring Boot: step #2
Add camel-spring-boot jar to your classpath.
![Page 29: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/29.jpg)
Camel + Spring Boot: step #3
Add Camel route to your classpath.
![Page 30: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/30.jpg)
Camel + Spring Boot: step #4
Dockerize your fat jar and run it!
![Page 31: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/31.jpg)
ENV-centric runtime configuration# override endpoint definition via ENV variable
docker run -e FROM=jms:queue -it my-springboot-camel-app
# run with the given Spring profile
docker run -e spring.profiles.active=production -it my-springboot-camel-app
![Page 32: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/32.jpg)
Monitoring
Expose JMX via REST with the Jolokia base image.
![Page 33: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/33.jpg)
Kubernetes
● orchestration of many Docker containers● ...and many Docker servers!● logical container groups (pods)● auto-scaling● wiring your Docker stuff together
![Page 34: Apache Camel in the belly of the Docker whale](https://reader033.fdocuments.net/reader033/viewer/2022042816/559446191a28aba37f8b4572/html5/thumbnails/34.jpg)
Thank you!