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

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

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