SlideShare a Scribd company logo
Application Modernization Technical Conference 2019
Live Coding 12-Factor
App
Emily Jiang
Java Champion
STSM, IBM
Liberty Microservice Architect, Advocate
MicroProfile Guru
@emilyfhjiang
Contents
Basic concept of 12 factor app
On stage hacking of creating 12 factor microservices using MicroProfile
12 Factors in a nut shell
– A Methodologie
– Best Practices
– Manifesto
https://12factor.net/ by Heroku
Why 12 factor?
• Define the contract between applications and infrastructure
Application Infrastructure
What is a Twelve-Factor App?
In the modern era, software is commonly delivered as a service: called web apps, or software-as-a-service. The
twelve-factor app is a methodology for building software-as-a-service apps that:
Use declarative formats for setup automation, to minimize time and cost for new developers joining the project;
Have a clean contract with the underlying operating system, offering maximum portability between execution
environments;
Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems
administration;
Minimize divergence between development and production, enabling continuous deployment for maximum
agility;
And can scale up without significant changes to tooling, architecture, or development practices.
The twelve-factor methodology can be applied to apps written in any programming language, and which use any
combination of backing services (database, queue, memory cache, etc).
From https://12factor.net
THE FACTORS
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release, Run
6. Processes
7. Port binding
8. Concurrency
9. Disposability
10.Dev / Prod parity
11.Logs
12.Admin Processes
How to build 12-Factor App?
MicroProfile and Kubernetes come to rescue!
Community
Driven
Lightweight, Iterative
Processes
Specs, APIs, TCKs
NO Reference
Implementation
MicroProfile Community
● Over a dozen vendors and
Java user groups
● Around 169 individual
contributors and growing
● Around a dozen
independent
implementations
✓ Open specifications
✓ Wide vendor support
✓ REST Client
✓ OpenAPI support
✓ Security
✓ Fault Tolerance
✓ Configuration
✓ Metrics
✓ Health
✓ Open Tracing
https://wiki.eclipse.org/MicroProfile/Implementation
Quarkus
12
MicroProfile 1.0 (Fall 2016)
JAX-RS 2.0
CDI 1.2
JSON-P 1.0
MicroProfile 1.1 (August 2017)
microProfile-1.0
Config 1.0
MicroProfile 1.2 (Sept 2017)
MicroProfile-1.1
Config 1.1
Fault Tolerance 1.0
Health 1.0
Metrics 1.0
JWT 1.0
2017
201
8
MicroProfile 1.3 (Dec 2017)
MicroProfile 1.2
Config 1.2
Metrics 1.1
OpenApi 1.0
OpenTracing 1.0
RestClient 1.0
MicroProfile 1.4 (June 2018)
MicroProfile 1.3
Config 1.3
Fault Tolerance 1.1
JWT 1.1
Open Tracing-1.1
Rest Client-1.1
2019
MicroProfile 2.0.1 (July 2018)
MicroProfile 1.4
JAX-RS 2.1 // Java EE 8
CDI 2.0 // Java EE 8
JSON-P 1.1 // Java EE 8
JSON-B 1.0 // Java EE 8
MicroProfile 2.1 (Oct
2018)
MicroProfile 2.0
OpenTracing 1.2
MicroProfile 2.2 (Feb
2019)
Fault Tolerance 2.0
OpenAPI 1.1
OpenTracing 1.3
Rest Client 1.2
MicroProfile 3.0
(June 2019)
MicroProfile 2.1
Metrics 2.0
Health Check
2.0
Rest Client 1.3
MicroProfile 3.2 (Nov
2019)
MicroProfile 3.0
Metrics 2.2
Health Check 2.1
2020
MicroProfile 3.3 (Feb
2020)
MicroProfile 3.2
Config 1.4
Metrics 2.3
Fault Tolerance 2.1
Health 2.2
Rest Client 1.4
I. Codebase
• Dedicate smaller teams to individual applications or microservices.
• Following the discipline of single repository for an application forces
the teams to analyze the seams of their application, and identify
potential monoliths that should be split off into microservices.
“One codebase tracked in revision control, many deploys.”
ØUse a single source code repository for a single application (1:1
relation). Deployment stages are different tags/branches
Øi.e. use a central git repo (external Github/GitHub Enterprise
also suitable)
II. Dependencies
A cloud-native application does not rely on the pre-existence of dependencies in
a deployment target.
Developer Tools declare and isolate dependencies
• Maven and Gradle for Java
“Explicitly declare and isolate dependencies”
ØEach microservice has its own dependencies declared (e.g.
pom.xml)
III. Config
“Store config in the environment”
Ø Changing config should not need to repackage your application
Ø Use Kubernetes configmaps and secrets for container services
Ø Use MicroProfile Config to inject the config properties into the microservices
App Password=blah
MicroProfile Config
Why?
– Configure Microservice without
repacking the application
How?
– Specify the configuration in
configure sources
– Access configuration via
• Programmatically lookup
Config config =ConfigProvider.getConfig();
config.getValue(“myProp”, String.class);
• Via CDI Injection
@Inject
@ConfigProperty(name="my.string.property")
String myPropV;
IV. Backing services
“Treat backing services as attached resources”
Application
My SQL Amazon S3 Twitter
MicroProfile REST Client
BA
@Inject
@RestClient
private SystemClient
defaultRestClient;
@Dependent
@RegisterRestClient
@RegisterProvider(UnknownUrlExceptionMapper.class)
@Path("/properties")
public interface SystemClient {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Properties getProperties() throws
UnknownUrlException, ProcessingException;
}
io.openliberty.guides.inventory.client.SystemClient/mp-rest/url=http://localhost:9080/system
V. Build, release, run
“Strictly separate build and run stages”
Ø Source code is used in the build stage. Configuration data is added to define a
release stage that can be deployed. Any changes in code or config will result in a
new build/release
Ø Needs to be considered in CI pipeline (e.g. Tekton)
VI. Processes
“Execute the app as one or more stateless processes”
Stateless and share-nothing
Restful API
VII. Port binding
“Export services via port binding”
Ø Applications are fully self-contained and expose services only through ports.
Port assignment is done by the execution environment
Ø Ingress/service definition of k8s manages mapping of ports
Ø Use MP Config to inject ports to microservices for chain-up invocations
Port=80
@Inject @ConfigProperty(name=”port”, defaultValue=“9080”)
VIII. Concurrency
“Scale out via the process model”
Ø Applications use processes independent from each other to scale out (allowing
for load balancing)
Ø To be considered in application design
Ø Cloud autoscaling services: [auto]scaling built into k8s
Ø Build micorservices
IX. Disposability
“Maximize robustness with fast startup and graceful shutdown”
Ø Processes start up fast.
Ø Processes shut down gracefully when requested.
Ø Processes are robust against sudden death
Ø Use MicroProfile Fault Tolerance to make it resilient
From “CERN Data Centre Evolution”
MicroProfile Fault Tolerance
A solution to build a resilient microservice
v Retry - @Retry
v Circuit Breaker - @CircuitBreaker
v Bulkhead - @Bulkhead
v Time out - @Timeout
v Fallback - @Fallback
X. Dev/prod parity
“Keep development, staging, and production as similar as possible”
Ø Development and production are as close as possible (in terms of code, people,
and environments)
Ø Can use Operators to deploy in repeatable manner
XI. Logs
“Treat logs as event streams”
Ø App writes all logs to stdout
Ø Use a structured output for meaningful logs suitable for analysis. Execution
environment handles routing and analysis infrastructure
XII. Admin processes
“Run admin/management tasks as one-off processes”
Ø Tooling: standard k8s tooling like “kubectl exec” or Kubernetes Jobs
Ø Also to be considered in solution/application design
Ø For example, if an application needs to migrate data into a database, place this
task into a separate component instead of adding it to the main application code
at startup
THE FACTORS
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release, Run
6. Processes
7. Port binding
8. Concurrency
9. Disposability
10.Dev / Prod parity
11.Logs
12.Admin Processes
How to get started?
https://start.microprofile.io/
https://appsody.dev/
12 factor app
• Use MicroProfile and K8s to build a microservice => 12 factor app
microservice
Infrastructure
THE FACTORS
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release, Run
6. Processes
7. Port binding
8. Concurrency
9. Disposability
10.Dev / Prod parity
11.Logs
12.Admin Processes
References
• https://microprofile.io
• https://openliberty.io
• https://www.12factor.net/
• https://kubernetes.io/
• https://appsody.dev/
• https://quarkus.io
• https://github.com/Emily-Jiang/qcon-12factor-app-a
• https://github.com/Emily-Jiang/qcon-12factor-app-b
• https://github.com/Emily-Jiang/qcon-12factor-deployment
microservice
Infrastructure
K8s
@emilyfhjiang
Thank You
Thank You
@emilyfhjiang

More Related Content

What's hot (20)

PPTX
Monoliths to Microservices with Jave EE and Spring Boot
Tiera Fann, MBA
 
PPTX
Data-centric Application Analysis with Open-source Tool Tackle-DiVA
Konveyor Community
 
PPTX
Webinar: Operating Kubernetes at Scale
Mesosphere Inc.
 
PDF
Microservices Development Process at Predix.io
Constantine Grigel
 
PDF
OpenShift Taiwan Vol.1 Technology Overview
Jason Peng
 
PDF
Cloud-Native Fundamentals: Accelerating Development with Continuous Integration
VMware Tanzu
 
PPTX
Migrating from oracle soa suite to microservices on kubernetes
Konveyor Community
 
PDF
CNCF Live Webinar: Kubernetes 1.23
LibbySchulze
 
PDF
Cloud Native Security: New Approach for a New Reality
Carlos Andrés García
 
PPTX
OpenDaylight app development tutorial
SDN Hub
 
PDF
Making your app soar without a container manifest
LibbySchulze
 
PDF
Cncf checkov and bridgecrew
LibbySchulze
 
PPTX
Building 12 factor apps with ASP.NET Core, Сергій Калинець
Sigma Software
 
PPTX
Java EE Modernization with Mesosphere DCOS
Mesosphere Inc.
 
PDF
Why Your Digital Transformation Strategy Demands Middleware Modernization
VMware Tanzu
 
PDF
Addressing the 8 Key Pain Points of Kubernetes Cluster Management
Enterprise Management Associates
 
PPTX
Enable DevSecOps using JIRA Software
AUGNYC
 
PPTX
Operating Kubernetes at Scale (Australia Presentation)
Mesosphere Inc.
 
PDF
Observability, Distributed Tracing, and Open Source: The Missing Primer
VMware Tanzu
 
PDF
KrakenD API Gateway
Albert Lombarte
 
Monoliths to Microservices with Jave EE and Spring Boot
Tiera Fann, MBA
 
Data-centric Application Analysis with Open-source Tool Tackle-DiVA
Konveyor Community
 
Webinar: Operating Kubernetes at Scale
Mesosphere Inc.
 
Microservices Development Process at Predix.io
Constantine Grigel
 
OpenShift Taiwan Vol.1 Technology Overview
Jason Peng
 
Cloud-Native Fundamentals: Accelerating Development with Continuous Integration
VMware Tanzu
 
Migrating from oracle soa suite to microservices on kubernetes
Konveyor Community
 
CNCF Live Webinar: Kubernetes 1.23
LibbySchulze
 
Cloud Native Security: New Approach for a New Reality
Carlos Andrés García
 
OpenDaylight app development tutorial
SDN Hub
 
Making your app soar without a container manifest
LibbySchulze
 
Cncf checkov and bridgecrew
LibbySchulze
 
Building 12 factor apps with ASP.NET Core, Сергій Калинець
Sigma Software
 
Java EE Modernization with Mesosphere DCOS
Mesosphere Inc.
 
Why Your Digital Transformation Strategy Demands Middleware Modernization
VMware Tanzu
 
Addressing the 8 Key Pain Points of Kubernetes Cluster Management
Enterprise Management Associates
 
Enable DevSecOps using JIRA Software
AUGNYC
 
Operating Kubernetes at Scale (Australia Presentation)
Mesosphere Inc.
 
Observability, Distributed Tracing, and Open Source: The Missing Primer
VMware Tanzu
 
KrakenD API Gateway
Albert Lombarte
 

Similar to Live Coding 12 Factor App (20)

PPTX
Building 12-factor Cloud Native Microservices
Jakarta_EE
 
PPTX
Build12 factorappusingmp
Emily Jiang
 
PPTX
Microservices
Abdelrahman Badreldeen
 
PPTX
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
Emily Jiang
 
PPTX
Cloud nativemicroservices jax-london2020
Emily Jiang
 
PPTX
Cloud nativemicroservices jax-london2020
Emily Jiang
 
PPTX
Thriving in the cloud: Going beyond the 12 factors
Grace Jansen
 
PPTX
Cloud nativeworkshop
Emily Jiang
 
PPTX
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
David Currie
 
PPTX
The twelve factor app
Ravi Okade
 
PDF
Developing Enterprise Applications for the Cloud, from Monolith to Microservice
Jack-Junjie Cai
 
PDF
GIDS_15FactorWorkshop.pdf
RichHagarty
 
PPTX
Introduction to Microservices and Cloud Native Application Architecture
David Currie
 
PPTX
Devoxx Ukraine - Going beyond the 12 factors
Grace Jansen
 
PDF
Kubernetes & Co, beyond the hype
Alexandre Touret
 
PPTX
Breaking the Monolith
VMware Tanzu
 
PPTX
Introduction to microservices
Anil Allewar
 
PDF
Microservices: Notes From The Field
Apcera
 
PPTX
JCON_15FactorWorkshop.pptx
Grace Jansen
 
PPTX
The Twelve-Factor App
Yaroslav Novytskyy
 
Building 12-factor Cloud Native Microservices
Jakarta_EE
 
Build12 factorappusingmp
Emily Jiang
 
Microservices
Abdelrahman Badreldeen
 
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
Emily Jiang
 
Cloud nativemicroservices jax-london2020
Emily Jiang
 
Cloud nativemicroservices jax-london2020
Emily Jiang
 
Thriving in the cloud: Going beyond the 12 factors
Grace Jansen
 
Cloud nativeworkshop
Emily Jiang
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
David Currie
 
The twelve factor app
Ravi Okade
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservice
Jack-Junjie Cai
 
GIDS_15FactorWorkshop.pdf
RichHagarty
 
Introduction to Microservices and Cloud Native Application Architecture
David Currie
 
Devoxx Ukraine - Going beyond the 12 factors
Grace Jansen
 
Kubernetes & Co, beyond the hype
Alexandre Touret
 
Breaking the Monolith
VMware Tanzu
 
Introduction to microservices
Anil Allewar
 
Microservices: Notes From The Field
Apcera
 
JCON_15FactorWorkshop.pptx
Grace Jansen
 
The Twelve-Factor App
Yaroslav Novytskyy
 
Ad

More from Emily Jiang (9)

PDF
Java Developers - What Lies Ahead in the AI era
Emily Jiang
 
PPTX
Reactive microserviceinaction
Emily Jiang
 
PPTX
Reactive microserviceinaction@devnexus
Emily Jiang
 
PPTX
Cloud native programming model comparison
Emily Jiang
 
PPTX
Cloud native programming model comparison
Emily Jiang
 
PPTX
Micro profile and istio
Emily Jiang
 
PPTX
Building cloud native microservices
Emily Jiang
 
PPTX
The new and smart way to build microservices - Eclipse MicroProfile
Emily Jiang
 
PPTX
New and smart way to develop microservice for istio with micro profile
Emily Jiang
 
Java Developers - What Lies Ahead in the AI era
Emily Jiang
 
Reactive microserviceinaction
Emily Jiang
 
Reactive microserviceinaction@devnexus
Emily Jiang
 
Cloud native programming model comparison
Emily Jiang
 
Cloud native programming model comparison
Emily Jiang
 
Micro profile and istio
Emily Jiang
 
Building cloud native microservices
Emily Jiang
 
The new and smart way to build microservices - Eclipse MicroProfile
Emily Jiang
 
New and smart way to develop microservice for istio with micro profile
Emily Jiang
 
Ad

Recently uploaded (20)

PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 

Live Coding 12 Factor App

  • 1. Application Modernization Technical Conference 2019 Live Coding 12-Factor App Emily Jiang Java Champion STSM, IBM Liberty Microservice Architect, Advocate MicroProfile Guru @emilyfhjiang
  • 2. Contents Basic concept of 12 factor app On stage hacking of creating 12 factor microservices using MicroProfile
  • 3. 12 Factors in a nut shell – A Methodologie – Best Practices – Manifesto https://12factor.net/ by Heroku
  • 4. Why 12 factor? • Define the contract between applications and infrastructure Application Infrastructure
  • 5. What is a Twelve-Factor App? In the modern era, software is commonly delivered as a service: called web apps, or software-as-a-service. The twelve-factor app is a methodology for building software-as-a-service apps that: Use declarative formats for setup automation, to minimize time and cost for new developers joining the project; Have a clean contract with the underlying operating system, offering maximum portability between execution environments; Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; Minimize divergence between development and production, enabling continuous deployment for maximum agility; And can scale up without significant changes to tooling, architecture, or development practices. The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc). From https://12factor.net
  • 6. THE FACTORS 1. Codebase 2. Dependencies 3. Config 4. Backing Services 5. Build, Release, Run 6. Processes 7. Port binding 8. Concurrency 9. Disposability 10.Dev / Prod parity 11.Logs 12.Admin Processes
  • 7. How to build 12-Factor App?
  • 8. MicroProfile and Kubernetes come to rescue!
  • 10. MicroProfile Community ● Over a dozen vendors and Java user groups ● Around 169 individual contributors and growing ● Around a dozen independent implementations
  • 11. ✓ Open specifications ✓ Wide vendor support ✓ REST Client ✓ OpenAPI support ✓ Security ✓ Fault Tolerance ✓ Configuration ✓ Metrics ✓ Health ✓ Open Tracing https://wiki.eclipse.org/MicroProfile/Implementation Quarkus
  • 12. 12 MicroProfile 1.0 (Fall 2016) JAX-RS 2.0 CDI 1.2 JSON-P 1.0 MicroProfile 1.1 (August 2017) microProfile-1.0 Config 1.0 MicroProfile 1.2 (Sept 2017) MicroProfile-1.1 Config 1.1 Fault Tolerance 1.0 Health 1.0 Metrics 1.0 JWT 1.0 2017 201 8 MicroProfile 1.3 (Dec 2017) MicroProfile 1.2 Config 1.2 Metrics 1.1 OpenApi 1.0 OpenTracing 1.0 RestClient 1.0 MicroProfile 1.4 (June 2018) MicroProfile 1.3 Config 1.3 Fault Tolerance 1.1 JWT 1.1 Open Tracing-1.1 Rest Client-1.1 2019 MicroProfile 2.0.1 (July 2018) MicroProfile 1.4 JAX-RS 2.1 // Java EE 8 CDI 2.0 // Java EE 8 JSON-P 1.1 // Java EE 8 JSON-B 1.0 // Java EE 8 MicroProfile 2.1 (Oct 2018) MicroProfile 2.0 OpenTracing 1.2 MicroProfile 2.2 (Feb 2019) Fault Tolerance 2.0 OpenAPI 1.1 OpenTracing 1.3 Rest Client 1.2 MicroProfile 3.0 (June 2019) MicroProfile 2.1 Metrics 2.0 Health Check 2.0 Rest Client 1.3 MicroProfile 3.2 (Nov 2019) MicroProfile 3.0 Metrics 2.2 Health Check 2.1 2020 MicroProfile 3.3 (Feb 2020) MicroProfile 3.2 Config 1.4 Metrics 2.3 Fault Tolerance 2.1 Health 2.2 Rest Client 1.4
  • 13. I. Codebase • Dedicate smaller teams to individual applications or microservices. • Following the discipline of single repository for an application forces the teams to analyze the seams of their application, and identify potential monoliths that should be split off into microservices. “One codebase tracked in revision control, many deploys.” ØUse a single source code repository for a single application (1:1 relation). Deployment stages are different tags/branches Øi.e. use a central git repo (external Github/GitHub Enterprise also suitable)
  • 14. II. Dependencies A cloud-native application does not rely on the pre-existence of dependencies in a deployment target. Developer Tools declare and isolate dependencies • Maven and Gradle for Java “Explicitly declare and isolate dependencies” ØEach microservice has its own dependencies declared (e.g. pom.xml)
  • 15. III. Config “Store config in the environment” Ø Changing config should not need to repackage your application Ø Use Kubernetes configmaps and secrets for container services Ø Use MicroProfile Config to inject the config properties into the microservices App Password=blah
  • 16. MicroProfile Config Why? – Configure Microservice without repacking the application How? – Specify the configuration in configure sources – Access configuration via • Programmatically lookup Config config =ConfigProvider.getConfig(); config.getValue(“myProp”, String.class); • Via CDI Injection @Inject @ConfigProperty(name="my.string.property") String myPropV;
  • 17. IV. Backing services “Treat backing services as attached resources” Application My SQL Amazon S3 Twitter
  • 18. MicroProfile REST Client BA @Inject @RestClient private SystemClient defaultRestClient; @Dependent @RegisterRestClient @RegisterProvider(UnknownUrlExceptionMapper.class) @Path("/properties") public interface SystemClient { @GET @Produces(MediaType.APPLICATION_JSON) public Properties getProperties() throws UnknownUrlException, ProcessingException; } io.openliberty.guides.inventory.client.SystemClient/mp-rest/url=http://localhost:9080/system
  • 19. V. Build, release, run “Strictly separate build and run stages” Ø Source code is used in the build stage. Configuration data is added to define a release stage that can be deployed. Any changes in code or config will result in a new build/release Ø Needs to be considered in CI pipeline (e.g. Tekton)
  • 20. VI. Processes “Execute the app as one or more stateless processes” Stateless and share-nothing Restful API
  • 21. VII. Port binding “Export services via port binding” Ø Applications are fully self-contained and expose services only through ports. Port assignment is done by the execution environment Ø Ingress/service definition of k8s manages mapping of ports Ø Use MP Config to inject ports to microservices for chain-up invocations Port=80 @Inject @ConfigProperty(name=”port”, defaultValue=“9080”)
  • 22. VIII. Concurrency “Scale out via the process model” Ø Applications use processes independent from each other to scale out (allowing for load balancing) Ø To be considered in application design Ø Cloud autoscaling services: [auto]scaling built into k8s Ø Build micorservices
  • 23. IX. Disposability “Maximize robustness with fast startup and graceful shutdown” Ø Processes start up fast. Ø Processes shut down gracefully when requested. Ø Processes are robust against sudden death Ø Use MicroProfile Fault Tolerance to make it resilient From “CERN Data Centre Evolution”
  • 24. MicroProfile Fault Tolerance A solution to build a resilient microservice v Retry - @Retry v Circuit Breaker - @CircuitBreaker v Bulkhead - @Bulkhead v Time out - @Timeout v Fallback - @Fallback
  • 25. X. Dev/prod parity “Keep development, staging, and production as similar as possible” Ø Development and production are as close as possible (in terms of code, people, and environments) Ø Can use Operators to deploy in repeatable manner
  • 26. XI. Logs “Treat logs as event streams” Ø App writes all logs to stdout Ø Use a structured output for meaningful logs suitable for analysis. Execution environment handles routing and analysis infrastructure
  • 27. XII. Admin processes “Run admin/management tasks as one-off processes” Ø Tooling: standard k8s tooling like “kubectl exec” or Kubernetes Jobs Ø Also to be considered in solution/application design Ø For example, if an application needs to migrate data into a database, place this task into a separate component instead of adding it to the main application code at startup
  • 28. THE FACTORS 1. Codebase 2. Dependencies 3. Config 4. Backing Services 5. Build, Release, Run 6. Processes 7. Port binding 8. Concurrency 9. Disposability 10.Dev / Prod parity 11.Logs 12.Admin Processes
  • 29. How to get started? https://start.microprofile.io/ https://appsody.dev/
  • 30. 12 factor app • Use MicroProfile and K8s to build a microservice => 12 factor app microservice Infrastructure
  • 31. THE FACTORS 1. Codebase 2. Dependencies 3. Config 4. Backing Services 5. Build, Release, Run 6. Processes 7. Port binding 8. Concurrency 9. Disposability 10.Dev / Prod parity 11.Logs 12.Admin Processes
  • 32. References • https://microprofile.io • https://openliberty.io • https://www.12factor.net/ • https://kubernetes.io/ • https://appsody.dev/ • https://quarkus.io • https://github.com/Emily-Jiang/qcon-12factor-app-a • https://github.com/Emily-Jiang/qcon-12factor-app-b • https://github.com/Emily-Jiang/qcon-12factor-deployment microservice Infrastructure K8s @emilyfhjiang