SlideShare a Scribd company logo
1 of 20
Cloud Native Java Development
Patterns and Principles for Designing Kubernetes Applications
FOSDEM
February 2017
Bilgin Ibryam
Cloud Native Java Development2
Bilgin Ibryam
●
Architect at Red Hat
●
Apache Isis, Camel, OFBiz Committer
●
Author of Apache Camel books
●
Blogs about Cloud Native and Microservices
●
Twitter: @bibryam
●
Email: bibryam@gmail.com
●
Blog: http://ofbizian.com
●
Github: https://github.com/bibryam
Cloud Native Java Development3
The Move to Cloud Native
?
Cloud Native Java Development4
Are You Cloud Native?
Applications adopting the principles of
Microservices packaged as
Containers orchestrated by
Platforms running on top of
Cloud infrastructure
Cloud Native Java Development5
Cloud Native Platforms
Cloud Native Java Development6
How to Run k8s as a Dev (not Ops)
●
Google Container Engine (GKE) – Kubernetes as a service
●
Microsoft Azure Container Service (ACS) – DC/OS, Swarm, Kubernetes as a service
●
Red Hat OpenShift Online – The largest multi-tenanted Kubernetes cluster
●
Minikube – For local development and testing
●
Maven plugin - mvn fabric8:cluster-start
https://fabric8.io/
Cloud Native Java Development7
k8s Primitives for Devs
●
How to package apps? → Container
●
What is the deployment unit? → Pod
●
How to group artifacts? → Labels
●
How to isolate resources? → Namespaces
●
How to mange configs? → ConfigMap/Secret
●
How to get storage? → PC/PVC
●
How to do service discovery & load balancing? → Service & Route
●
How to update/rollback services? → Deployment
Cloud Native Java Development8
Java Runtimes and Packaging
●
Spring Boot – the most popular
●
DropWizard – the second most popular
●
WildFly-Swarm – for JEE compliance
●
Immutable Karaf – for OSGI addicts
●
Standalone Java – for NIHS
●
MicroProfile – new initiative
HTTP Server, REST, JSON, Health
Checks, Circuit Breaker, Service Discovery,
Metrics, Configuration, Logging...
Cloud Native Java Development9
Dockerizing Java Applications
●
Java - OpenJDK or Oracle JDK? JDK or JRE?
●
Licensing and Distribution - Does Running Java on Docker Violate
Agreements?
●
CPU - Runtime.availableProcessors() ignores Linux taskset (JDK-6515172)
● $ echo '0-1' > /tmp/online
$ mount --bind /tmp/online /sys/devices/system/cpu/online
●
Memory - XX:+UseCGroupLimits (JDK-8170888)
● -XX:MaxRAM=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
●
Many “Container Best Practices” to learn
●
Fabric8 docker-maven-plugin: mvn package fabric8:build
Common issues:
Cloud Native Java Development10
Interacting with k8s
How to tell Kubernetes to:
●
Keep 3 instances of my-service up
●
Use the command "/bin/echo", "hello", "world" to start
●
Allocate 512MiB memory and one core for it
●
Make port 80 accessible
●
Set foo environment variable with bar value
●
Mount configs with name my-service to location /my-service
●
Mount a 5GB R/W persistent volume
●
And for updates do rolling update by bringing only 30% of containers down
Cloud Native Java Development11
Generating Application Descriptor
Start Kubernetes: mvn fabric8:cluster-start
Build (maven artifacts and docker image): mvn package fabric8:build
Deploy a service to Kubernetes: mvn fabric8:json fabric8:apply
Cloud Native Java Development12
Observable Interior
In order to be a good cloud native citizen, every app should be able to report
its health status.
●
Spring Boot Actuator
●
Dropwizard Metrics
●
WildFly Swarm Monitor
●
MicroProfile Healthchecks Proposal (MP-0003)
Cloud Native Java Development13
Observable Interior
R E V I S E D
AGAIN
Cloud Native Java Development14
Life Cycle Conformance
Allows applications to do graceful shutdown and startup.
●
To stop a pod, Kubernetes will send SIGTERM 30 seconds before SIGKILL
●
PreStop lifecycle hook executed prior to sending SIGTERM.
●
PostStart sent immediately after a container is created.
●
Termination message - /dev/termination-log
Cloud Native Java Development16
Service Discovery & Load Balancing
Provided by the platform
Cloud Native Java Development18
Application Resilience on the JVM
Netflix Hystrix: Circuit Breaker, TimeOuts, BulkHead, Retry
Cloud Native Java Development19
For true resilience you must go
outside of the JVM!
●
Infinite loops: CPU shares and quotas
●
Memory leaks: OOM yourself
●
Disk hogs: Quotas
●
Fork bombs: Process limits
●
Process Bulkhead with Containers
●
Hardware Bulkhead through the Scheduler
●
Self Healing
●
AntiFragile
Cloud Native Java Development20
More Kubernetes Patterns
●
SideCar, Adapter, Ambassador - Pod
●
Managed Configurations – ConfigMaps/Secrets
●
Singleton Services (File, RDB, NoSQL, Message Queue) - replicas: 1
●
Batch Jobs (JDK Timer, JDK ScheduledExecutorService, Quartz Scheduler) - CronJob
●
Initializers, Daemon Services – Init Container, Daemon Sets
●
Self Healing – Containers, Pods, Health Checks, Scheduler
●
AntiFragile – Infrastructure and application Autoscaler
Cloud Native Java Development21
In Summary
✔ Let the platform handle the repeating boring tasks.
✔ Use Java to focus on the problem domain instead.
✔ Don't reinvent the wheel, use Fabric8 tools.
Q & A
@bibryam
Fabric8 https://fabric8.io
Kubernetes http://kubernetes.io
Kubernetes Patterns – book coming soon!

More Related Content

What's hot

Modernizing Traditional Applications with Docker EE: From PoC to Production
Modernizing Traditional Applications with Docker EE: From PoC to ProductionModernizing Traditional Applications with Docker EE: From PoC to Production
Modernizing Traditional Applications with Docker EE: From PoC to Production
Docker, Inc.
 

What's hot (20)

The evolving container landscape
The evolving container landscapeThe evolving container landscape
The evolving container landscape
 
Google Cloud Platform and Kubernetes
Google Cloud Platform and KubernetesGoogle Cloud Platform and Kubernetes
Google Cloud Platform and Kubernetes
 
High Performance Cloud-Native Microservices With Distributed Caching
High Performance Cloud-Native Microservices With Distributed CachingHigh Performance Cloud-Native Microservices With Distributed Caching
High Performance Cloud-Native Microservices With Distributed Caching
 
Webinar: End-to-End CI/CD with GitLab and DC/OS
Webinar: End-to-End CI/CD with GitLab and DC/OSWebinar: End-to-End CI/CD with GitLab and DC/OS
Webinar: End-to-End CI/CD with GitLab and DC/OS
 
Episode 4: Operating Kubernetes at Scale with DC/OS
Episode 4: Operating Kubernetes at Scale with DC/OSEpisode 4: Operating Kubernetes at Scale with DC/OS
Episode 4: Operating Kubernetes at Scale with DC/OS
 
3 - Delen Private Bank: FOSS adventures in a Cloud Native world
3 - Delen Private Bank: FOSS adventures in a Cloud Native world3 - Delen Private Bank: FOSS adventures in a Cloud Native world
3 - Delen Private Bank: FOSS adventures in a Cloud Native world
 
Microservices with Spring
Microservices with SpringMicroservices with Spring
Microservices with Spring
 
Modernization patterns to refactor a legacy application into event driven mic...
Modernization patterns to refactor a legacy application into event driven mic...Modernization patterns to refactor a legacy application into event driven mic...
Modernization patterns to refactor a legacy application into event driven mic...
 
Serverless stream processing of Debezium data change events with Knative | De...
Serverless stream processing of Debezium data change events with Knative | De...Serverless stream processing of Debezium data change events with Knative | De...
Serverless stream processing of Debezium data change events with Knative | De...
 
Cncf storage-final-filip
Cncf storage-final-filipCncf storage-final-filip
Cncf storage-final-filip
 
Cloud Native Development
Cloud Native DevelopmentCloud Native Development
Cloud Native Development
 
WebSphere 20th - Application modernization
WebSphere 20th - Application modernizationWebSphere 20th - Application modernization
WebSphere 20th - Application modernization
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Storage os kubernetes clusters need persistent data
Storage os   kubernetes clusters need persistent dataStorage os   kubernetes clusters need persistent data
Storage os kubernetes clusters need persistent data
 
PKS - Solving Complexity for Modern Data Workloads
PKS - Solving Complexity for Modern Data Workloads PKS - Solving Complexity for Modern Data Workloads
PKS - Solving Complexity for Modern Data Workloads
 
Persist your data in an ephemeral k8 ecosystem
Persist your data in an ephemeral k8 ecosystemPersist your data in an ephemeral k8 ecosystem
Persist your data in an ephemeral k8 ecosystem
 
Google Anthos - Azure Stack - AWS Outposts :Comparison
Google Anthos - Azure Stack - AWS Outposts :ComparisonGoogle Anthos - Azure Stack - AWS Outposts :Comparison
Google Anthos - Azure Stack - AWS Outposts :Comparison
 
Modernizing Traditional Applications with Docker EE: From PoC to Production
Modernizing Traditional Applications with Docker EE: From PoC to ProductionModernizing Traditional Applications with Docker EE: From PoC to Production
Modernizing Traditional Applications with Docker EE: From PoC to Production
 
Cloud Native Use Cases / Case Studies - KubeCon 2019 San Diego - RECAP
Cloud Native Use Cases / Case Studies - KubeCon 2019 San Diego - RECAPCloud Native Use Cases / Case Studies - KubeCon 2019 San Diego - RECAP
Cloud Native Use Cases / Case Studies - KubeCon 2019 San Diego - RECAP
 
Best Practices for Managing Kubernetes and Stateful Services: Mesosphere & Sy...
Best Practices for Managing Kubernetes and Stateful Services: Mesosphere & Sy...Best Practices for Managing Kubernetes and Stateful Services: Mesosphere & Sy...
Best Practices for Managing Kubernetes and Stateful Services: Mesosphere & Sy...
 

Viewers also liked

Achieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
Achieving Cost and Resource Efficiency through Docker, OpenShift and KubernetesAchieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
Achieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
Dean Delamont
 
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Ростислав Фридман: “Kubernetes как средство управления микросервисами"Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Provectus
 

Viewers also liked (20)

Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design Patterns
 
Kubernetes networking in AWS
Kubernetes networking in AWSKubernetes networking in AWS
Kubernetes networking in AWS
 
Achieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
Achieving Cost and Resource Efficiency through Docker, OpenShift and KubernetesAchieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
Achieving Cost and Resource Efficiency through Docker, OpenShift and Kubernetes
 
Extend and build on Kubernetes
Extend and build on KubernetesExtend and build on Kubernetes
Extend and build on Kubernetes
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and TearsCamel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
 
Serverless on Kubernetes
Serverless on KubernetesServerless on Kubernetes
Serverless on Kubernetes
 
RackN DevOps meetup NYC
RackN DevOps meetup NYCRackN DevOps meetup NYC
RackN DevOps meetup NYC
 
Welcome talk for Moscow Kubernetes Meetup 1
Welcome talk for Moscow Kubernetes Meetup 1Welcome talk for Moscow Kubernetes Meetup 1
Welcome talk for Moscow Kubernetes Meetup 1
 
Opening: builderscon tokyo 2016
Opening: builderscon tokyo 2016Opening: builderscon tokyo 2016
Opening: builderscon tokyo 2016
 
Net core, mssql, container und kubernetes
Net core, mssql, container und kubernetesNet core, mssql, container und kubernetes
Net core, mssql, container und kubernetes
 
Mirantis Contributions to Kubernetes Ecosystem
Mirantis Contributions to Kubernetes EcosystemMirantis Contributions to Kubernetes Ecosystem
Mirantis Contributions to Kubernetes Ecosystem
 
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Ростислав Фридман: “Kubernetes как средство управления микросервисами"Ростислав Фридман: “Kubernetes как средство управления микросервисами"
Ростислав Фридман: “Kubernetes как средство управления микросервисами"
 
Microservices summit talk 1/31
Microservices summit talk   1/31Microservices summit talk   1/31
Microservices summit talk 1/31
 
Keeping up with Tech
Keeping up with Tech Keeping up with Tech
Keeping up with Tech
 
Docker Containers in Azure
Docker Containers in AzureDocker Containers in Azure
Docker Containers in Azure
 
Deploy your favorite apps on Kubernetes
Deploy your favorite apps on KubernetesDeploy your favorite apps on Kubernetes
Deploy your favorite apps on Kubernetes
 
Kubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning ControllerKubernetes as Orchestrator for A10 Lightning Controller
Kubernetes as Orchestrator for A10 Lightning Controller
 
Google Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKEGoogle Cloud Computing compares GCE, GAE and GKE
Google Cloud Computing compares GCE, GAE and GKE
 
Kubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserverKubernetes API - deep dive into the kube-apiserver
Kubernetes API - deep dive into the kube-apiserver
 
Bangalore Container Conference - Sponsor Deck
Bangalore Container Conference - Sponsor DeckBangalore Container Conference - Sponsor Deck
Bangalore Container Conference - Sponsor Deck
 

Similar to Cloud Native Java Development Patterns

20141111_SOS3_Gallo
20141111_SOS3_Gallo20141111_SOS3_Gallo
20141111_SOS3_Gallo
Andrea Gallo
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java framework
SVDevOps
 

Similar to Cloud Native Java Development Patterns (20)

Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroReactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
 
Red Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus IntroductionRed Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus Introduction
 
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
 
Cloud Native Practice
Cloud Native PracticeCloud Native Practice
Cloud Native Practice
 
[Global logic] container runtimes and kubernetes
[Global logic] container runtimes and kubernetes[Global logic] container runtimes and kubernetes
[Global logic] container runtimes and kubernetes
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Kubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mablKubernetes & Google Container Engine @ mabl
Kubernetes & Google Container Engine @ mabl
 
Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1
 
Java and Container - Make it Awesome !
Java and Container - Make it Awesome !Java and Container - Make it Awesome !
Java and Container - Make it Awesome !
 
Introduction to openshift
Introduction to openshiftIntroduction to openshift
Introduction to openshift
 
Kubernetes is all you need
Kubernetes is all you needKubernetes is all you need
Kubernetes is all you need
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
 
20141111_SOS3_Gallo
20141111_SOS3_Gallo20141111_SOS3_Gallo
20141111_SOS3_Gallo
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java framework
 

Recently uploaded

Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Marc Lester
 

Recently uploaded (20)

Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
Sourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing ManufacturerSourcing Success - How to Find a Clothing Manufacturer
Sourcing Success - How to Find a Clothing Manufacturer
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 

Cloud Native Java Development Patterns

  • 1. Cloud Native Java Development Patterns and Principles for Designing Kubernetes Applications FOSDEM February 2017 Bilgin Ibryam
  • 2. Cloud Native Java Development2 Bilgin Ibryam ● Architect at Red Hat ● Apache Isis, Camel, OFBiz Committer ● Author of Apache Camel books ● Blogs about Cloud Native and Microservices ● Twitter: @bibryam ● Email: bibryam@gmail.com ● Blog: http://ofbizian.com ● Github: https://github.com/bibryam
  • 3. Cloud Native Java Development3 The Move to Cloud Native ?
  • 4. Cloud Native Java Development4 Are You Cloud Native? Applications adopting the principles of Microservices packaged as Containers orchestrated by Platforms running on top of Cloud infrastructure
  • 5. Cloud Native Java Development5 Cloud Native Platforms
  • 6. Cloud Native Java Development6 How to Run k8s as a Dev (not Ops) ● Google Container Engine (GKE) – Kubernetes as a service ● Microsoft Azure Container Service (ACS) – DC/OS, Swarm, Kubernetes as a service ● Red Hat OpenShift Online – The largest multi-tenanted Kubernetes cluster ● Minikube – For local development and testing ● Maven plugin - mvn fabric8:cluster-start https://fabric8.io/
  • 7. Cloud Native Java Development7 k8s Primitives for Devs ● How to package apps? → Container ● What is the deployment unit? → Pod ● How to group artifacts? → Labels ● How to isolate resources? → Namespaces ● How to mange configs? → ConfigMap/Secret ● How to get storage? → PC/PVC ● How to do service discovery & load balancing? → Service & Route ● How to update/rollback services? → Deployment
  • 8. Cloud Native Java Development8 Java Runtimes and Packaging ● Spring Boot – the most popular ● DropWizard – the second most popular ● WildFly-Swarm – for JEE compliance ● Immutable Karaf – for OSGI addicts ● Standalone Java – for NIHS ● MicroProfile – new initiative HTTP Server, REST, JSON, Health Checks, Circuit Breaker, Service Discovery, Metrics, Configuration, Logging...
  • 9. Cloud Native Java Development9 Dockerizing Java Applications ● Java - OpenJDK or Oracle JDK? JDK or JRE? ● Licensing and Distribution - Does Running Java on Docker Violate Agreements? ● CPU - Runtime.availableProcessors() ignores Linux taskset (JDK-6515172) ● $ echo '0-1' > /tmp/online $ mount --bind /tmp/online /sys/devices/system/cpu/online ● Memory - XX:+UseCGroupLimits (JDK-8170888) ● -XX:MaxRAM=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) ● Many “Container Best Practices” to learn ● Fabric8 docker-maven-plugin: mvn package fabric8:build Common issues:
  • 10. Cloud Native Java Development10 Interacting with k8s How to tell Kubernetes to: ● Keep 3 instances of my-service up ● Use the command "/bin/echo", "hello", "world" to start ● Allocate 512MiB memory and one core for it ● Make port 80 accessible ● Set foo environment variable with bar value ● Mount configs with name my-service to location /my-service ● Mount a 5GB R/W persistent volume ● And for updates do rolling update by bringing only 30% of containers down
  • 11. Cloud Native Java Development11 Generating Application Descriptor Start Kubernetes: mvn fabric8:cluster-start Build (maven artifacts and docker image): mvn package fabric8:build Deploy a service to Kubernetes: mvn fabric8:json fabric8:apply
  • 12. Cloud Native Java Development12 Observable Interior In order to be a good cloud native citizen, every app should be able to report its health status. ● Spring Boot Actuator ● Dropwizard Metrics ● WildFly Swarm Monitor ● MicroProfile Healthchecks Proposal (MP-0003)
  • 13. Cloud Native Java Development13 Observable Interior R E V I S E D AGAIN
  • 14. Cloud Native Java Development14 Life Cycle Conformance Allows applications to do graceful shutdown and startup. ● To stop a pod, Kubernetes will send SIGTERM 30 seconds before SIGKILL ● PreStop lifecycle hook executed prior to sending SIGTERM. ● PostStart sent immediately after a container is created. ● Termination message - /dev/termination-log
  • 15. Cloud Native Java Development16 Service Discovery & Load Balancing Provided by the platform
  • 16. Cloud Native Java Development18 Application Resilience on the JVM Netflix Hystrix: Circuit Breaker, TimeOuts, BulkHead, Retry
  • 17. Cloud Native Java Development19 For true resilience you must go outside of the JVM! ● Infinite loops: CPU shares and quotas ● Memory leaks: OOM yourself ● Disk hogs: Quotas ● Fork bombs: Process limits ● Process Bulkhead with Containers ● Hardware Bulkhead through the Scheduler ● Self Healing ● AntiFragile
  • 18. Cloud Native Java Development20 More Kubernetes Patterns ● SideCar, Adapter, Ambassador - Pod ● Managed Configurations – ConfigMaps/Secrets ● Singleton Services (File, RDB, NoSQL, Message Queue) - replicas: 1 ● Batch Jobs (JDK Timer, JDK ScheduledExecutorService, Quartz Scheduler) - CronJob ● Initializers, Daemon Services – Init Container, Daemon Sets ● Self Healing – Containers, Pods, Health Checks, Scheduler ● AntiFragile – Infrastructure and application Autoscaler
  • 19. Cloud Native Java Development21 In Summary ✔ Let the platform handle the repeating boring tasks. ✔ Use Java to focus on the problem domain instead. ✔ Don't reinvent the wheel, use Fabric8 tools.
  • 20. Q & A @bibryam Fabric8 https://fabric8.io Kubernetes http://kubernetes.io Kubernetes Patterns – book coming soon!

Editor's Notes

  1. Architect Committer Blog books Middleware architect at RH consulting ½ day to over a year. Bug fix, healthcheck, design, implemented, POC Camel committer, contribited compoents such as aws-ses, aws-cloudwatch, aws- swf, aws-sdb, aws-ddb, solr, cmis, fop, redis, infinispan, jbpm, circuit breaker EIP, hystrix components Blogger about opensource, integration and came and author...Camel messages routing book which is an introduction to Camel and more recent book about Camel Design Patterns… which is the topic of this presentation. The goal today is to cover half of the more popular patterns from this book
  2. microservices - my blog about MSA years ago. But now there is a formalized, recognized, vocabulary