SlideShare a Scribd company logo
Kubernetes & the 12 factors
cloud applications
Ana Maria Mihalceanu
#JBCNConf2019
@ammbra1508#vJUG
HELLO!
I am Ana
Technical Lead @ IBM
Co-founder of Bucharest Software Craftsmanship Community
Why 12 factors & Kubernetes?
@ammbra1508#vJUG
Why 12 factors & Kubernetes?
@ammbra1508#vJUG
Evolution
Declarative
formats
Why 12 factors & Kubernetes?
@ammbra1508#vJUG
Run at push
of a button
Evolution
Declarative
formats
Scale up
with
minimal
changes
Declarative
formats
Scale up
with
minimal
changes
Why 12 factors & Kubernetes?
@ammbra1508#vJUG
Portability
Run at push
of a button
Evolution
Declarative
formats
Scale up
with
minimal
changes
Clean
Contract
Why 12 factors & Kubernetes?
@ammbra1508#vJUG
PortabilityLocal vs
production
Run at push
of a button
Evolution
Declarative
formats
Scale up
with
minimal
changes
Clean
Contract
Continuous
deployment
Scenario
@ammbra1508#vJUG
FACTOR 1 - CODEBASE
@ammbra1508#vJUG
One codebase tracked in
revision control,
with multiple deployments.
Kubernetes and the 12 factor cloud apps
FACTOR 1 - CODEBASE
@ammbra1508#vJUG
HELM
v2.x.y
Kubernetes and the 12 factor cloud apps
FACTOR 2 - DEPENDENCIES
@ammbra1508#vJUG
Explicitly declare and
isolate dependencies.
FACTOR 2 - DEPENDENCIES
@ammbra1508#vJUG
{
"name": "fed",
"version": "1.0.0",
"dependencies": {
"ejs": "^2.6.1",
"express": "^4.16.3",
"req-flash": "0.0.3",
"request": "2.81.0"
}
}
FACTOR 2 - DEPENDENCIES
@ammbra1508#vJUG
apiVersion: apps/v1
kind: Deployment
metadata:
name: dreamhome-web
labels:
app: dreamhome-web
tier: frontend
FACTOR 2 - DEPENDENCIES
@ammbra1508#vJUG
apiVersion: apps/v1
kind: Deployment
metadata:
name: dreamhome-web
labels:
app: dreamhome-web
tier: frontend
spec:
replicas: 2
selector:
matchLabels:
app: dreamhome-web
FACTOR 2 - DEPENDENCIES
@ammbra1508#vJUG
apiVersion: apps/v1
kind: Deployment
metadata:
name: dreamhome-web
labels:
app: dreamhome-web
tier: frontend
spec:
replicas: 2
selector:
matchLabels:
app: dreamhome-web
template:
metadata:
labels:
app: dreamhome-web
tier: frontend
implementation: nodejs
FACTOR 3 - CONFIGURATION
@ammbra1508#vJUG
FACTOR 3 - CONFIGURATION
@ammbra1508#vJUG
Store configuration in the environment.
kubectl create secret docker-registry ${SECRET_NAME}
--namespace ${CLUSTER_NAMESPACE}
--docker-server=${REGISTRY} --docker-username=iamapikey
--docker-password=${TOKEN} --docker-email=a@b.com
FACTOR 3 - CONFIGURATION
@ammbra1508#vJUG
Store configuration in the environment.
kubectl create secret docker-registry ${SECRET_NAME}
--namespace ${CLUSTER_NAMESPACE}
--docker-server=${REGISTRY} --docker-username=iamapikey
--docker-password=${TOKEN} --docker-email=a@b.com
FACTOR 4 – BACKING SERVICE
@ammbra1508#vJUG
Treat backing services as attached resources.
FACTOR 4 – BACKING SERVICE
@ammbra1508#vJUG
apiVersion: v1
kind: Secret
metadata:
name: cloudant
type: Opaque
data:
binding: {}
FACTOR 4 – BACKING SERVICE
@ammbra1508#vJUG
Treat backing services as attached resources.
apiVersion: v1
kind: Secret
metadata:
name: cloudant
type: Opaque
data:
binding: {}
FACTOR 4 – BACKING SERVICE
@ammbra1508#vJUG
Treat backing services as attached resources.
apiVersion: v1
kind: Secret
metadata:
name: cloudant
type: Opaque
data:
binding: {}
FACTOR 5 – BUILD, RELEASE, RUN
@ammbra1508#vJUG
FACTOR 5 – BUILD, RELEASE, RUN
@ammbra1508#vJUG
Strictly separate build
and run stages.
FACTOR 5 – BUILD, RELEASE, RUN
@ammbra1508#vJUG
Kubernetes and the 12 factor cloud apps
FACTOR 6 – PROCESSES
@ammbra1508#vJUG
Execute the app as one or
more stateless processes.
Container
Filesystem
Persistent
VolumeVolume
FACTOR 6 – PROCESSES
@ammbra1508#vJUG
kubectl apply –f ${CREATE_VOLUME}.yaml
kubectl apply –f ${COPY_SCRIPTS_POLLER}.yaml
kubectl cp ./scripts ${POD}:/${LOCATION}
kubectl apply –f ${USE_SCRIPTS}.yaml
FACTOR 7 – PORT BINDING
@ammbra1508#vJUG
kubectl apply –f ${FILE}
FACTOR 7 – PORT BINDING
@ammbra1508#vJUG
Export services via port binding.
FACTOR 7 – PORT BINDING
@ammbra1508#vJUG
Export services via port binding.
kubectl expose deployment/${NAME}
--type=”${SERVICE_TYPE}”
--name=${SERVICE_NAME}
FACTOR 8 – CONCURRENCY
@ammbra1508#vJUG
Scale out via the process model.
FACTOR 8 – CONCURRENCY
@ammbra1508#vJUG
Scale out via the process model.
FACTOR 8 – CONCURRENCY
@ammbra1508#vJUG
kubectl autoscale deployment {$DEPLOYMENT}
--min=${MIN_PODS} --max=${MAX_PODS}
--cpu-percent=${CPU}
--namespace=${NAMESPACE}
FACTOR 8 – CONCURRENCY
@ammbra1508#vJUG
kubectl autoscale deployment {$DEPLOYMENT}
--min=${MIN_PODS} --max=${MAX_PODS}
--cpu-percent=${CPU}
--namespace=${NAMESPACE}
𝐝𝐞𝐬𝐢𝐫𝐞𝐝𝐑𝐞𝐩𝐥𝐢𝐜𝐚𝐬 = ceil(currentReplicas ×
currentMetricValue
𝐝𝐞𝐬𝐢𝐫𝐞𝐝𝐌𝐞𝐭𝐫𝐢𝐜𝐕𝐚𝐥𝐮𝐞
)
FACTOR 9 – DISPOSABILITY
@ammbra1508#vJUG
Fast startup Graceful shutdown
Maximize robustness with
FACTOR 9 – DISPOSABILITY
@ammbra1508#vJUG
Application boot time
FACTOR 9 – DISPOSABILITY
@ammbra1508#vJUG
Rolling update one after another
Kubernetes and the 12 factor cloud apps
FACTOR 10 – DEV PROD PARITY
@ammbra1508#vJUG
Time People
Tools
FACTOR 10 – DEV PROD PARITY
@ammbra1508#vJUG
Keep development, staging and production
as similar as possible.
kubectl create namespace ${NAMESPACE}
FACTOR 11 – LOGS
@ammbra1508#vJUG
FACTOR 11 – LOGS
@ammbra1508#vJUG
Treat logs as event streams.
kubectl create secret generic logdna-agent-key
--from-literal=logdna-agent-key=<ingestion_key>
kubectl create -f
https://repo.logdna.com/ibm/prod/logdna-agent-ds-
us-south.yaml
FACTOR 12 – ADMIN PROCESSES
@ammbra1508#vJUG
Run admin/management tasks as one-off processes.
kubectl create configmap ${CONFIG}
--from-file=scripts/ -o yaml
kubectl apply –f ${ONE_TIME_JOB_CONFIGURATION}
Kubernetes and the 12 factor cloud apps
@ammbra1508#vJUG
TAKEAWAYS
Decouple
Decouple
infrastructure
complexity from your
application code.
Managed Services
Prefer managed
services in matters
involving
persistency.
Environment Parity
Keep your
environments as
similar as possible.
@ammbra1508#vJUG
TAKEAWAYS
Stateless
Design your
application as
stateless.
Scale
Your application
should be able to
process diverse
workloads.
Monitor
Use appropriate
logging in application
code and implement
cluster-level logging.
@ammbra1508#vJUG
The strongest factor for success is self-esteem.
Believing you can do it, believing you deserve it,
believing you will get it.
Anonymous
“ “
@ammbra1508#vJUG
THANKS!
Useful links
https://gist.github.com/ammbra/e951f8192592bc175a971a31df904c2
2
@ammbra1508#vJUG

More Related Content

PDF
Serverless with Google Cloud Functions
Jerry Jalava
 
PDF
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
devCAT Studio, NEXON
 
PDF
Kubermatic CNCF Webinar - start.kubermatic.pdf
LibbySchulze
 
PPT
NVIDIA OpenGL and Vulkan Support for 2017
Mark Kilgard
 
PDF
Cloud Native Java:GraalVM
Taewan alvin Kim
 
PPTX
Building CI/CD Pipelines with Jenkins and Kubernetes
Janakiram MSV
 
PPTX
Ssao
Minsu Park
 
PDF
A Beginner's Guide to Monocular Depth Estimation
Ryo Takahashi
 
Serverless with Google Cloud Functions
Jerry Jalava
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
devCAT Studio, NEXON
 
Kubermatic CNCF Webinar - start.kubermatic.pdf
LibbySchulze
 
NVIDIA OpenGL and Vulkan Support for 2017
Mark Kilgard
 
Cloud Native Java:GraalVM
Taewan alvin Kim
 
Building CI/CD Pipelines with Jenkins and Kubernetes
Janakiram MSV
 
A Beginner's Guide to Monocular Depth Estimation
Ryo Takahashi
 

What's hot (20)

PDF
Docker Architecture (v1.3)
rajdeep
 
PPTX
리얼타임 렌더링에 대해
필성 권
 
PDF
언리얼 서밋 2016 프로젝트 A1의 구형 월드 라이팅 기술
Ki Hyunwoo
 
PDF
Spinnaker at DevOpsDays Montreal
CloudOps2005
 
PDF
Application of deep leaning to computer vision
Djamal Abide, MSc
 
PDF
Mask-RCNN for Instance Segmentation
Dat Nguyen
 
PPT
Cnn method
AmirSajedi1
 
PDF
[GitOps] Argo CD on GKE (v0.9.2).pdf
Jo Hoon
 
PDF
Introduction to Docker
Luong Vo
 
PDF
07_PhysX 강체물리 입문
noerror
 
PPTX
[Ndc11 박민근] deferred shading
MinGeun Park
 
PDF
Cascade Shadow Mapping
Sukwoo Lee
 
PDF
Unreal Engine Basics 05 - User Interface
Nick Pruehs
 
PPTX
GDC2019 - SEED - Towards Deep Generative Models in Game Development
Electronic Arts / DICE
 
PPTX
Massive Point Light Soft Shadows
Wolfgang Engel
 
PPTX
Google net
Brian Kim
 
PDF
Red Hat OpenShift Container Platform Overview
James Falkner
 
PDF
Compute shader
QooJuice
 
PDF
Python3 (boto3) for aws
Sanjeev Kumar Jaiswal
 
PPT
Star Ocean 4 - Flexible Shader Managment and Post-processing
umsl snfrzb
 
Docker Architecture (v1.3)
rajdeep
 
리얼타임 렌더링에 대해
필성 권
 
언리얼 서밋 2016 프로젝트 A1의 구형 월드 라이팅 기술
Ki Hyunwoo
 
Spinnaker at DevOpsDays Montreal
CloudOps2005
 
Application of deep leaning to computer vision
Djamal Abide, MSc
 
Mask-RCNN for Instance Segmentation
Dat Nguyen
 
Cnn method
AmirSajedi1
 
[GitOps] Argo CD on GKE (v0.9.2).pdf
Jo Hoon
 
Introduction to Docker
Luong Vo
 
07_PhysX 강체물리 입문
noerror
 
[Ndc11 박민근] deferred shading
MinGeun Park
 
Cascade Shadow Mapping
Sukwoo Lee
 
Unreal Engine Basics 05 - User Interface
Nick Pruehs
 
GDC2019 - SEED - Towards Deep Generative Models in Game Development
Electronic Arts / DICE
 
Massive Point Light Soft Shadows
Wolfgang Engel
 
Google net
Brian Kim
 
Red Hat OpenShift Container Platform Overview
James Falkner
 
Compute shader
QooJuice
 
Python3 (boto3) for aws
Sanjeev Kumar Jaiswal
 
Star Ocean 4 - Flexible Shader Managment and Post-processing
umsl snfrzb
 
Ad

Similar to Kubernetes and the 12 factor cloud apps (20)

PDF
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
PDF
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
PDF
Zero downtime deployment of micro-services with Kubernetes
Wojciech Barczyński
 
PDF
Zero-downtime deployment of Micro-services with Kubernetes
Wojciech Barczyński
 
PDF
Monitoring kubernetes with prometheus
Brice Fernandes
 
PDF
Kubernetes &amp; the 12 factor cloud apps
Ana-Maria Mihalceanu
 
PDF
Kong Mesh入門編
WenhanShi1
 
PDF
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Codemotion
 
PDF
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 
PDF
Kafka summit apac session
Christina Lin
 
PPTX
London Adapt or Die: Kubernetes, Containers and Cloud - The MoD Story
Apigee | Google Cloud
 
PDF
Effective Building your Platform with Kubernetes == Keep it Simple
Wojciech Barczyński
 
PDF
Effective Platform Building with Kubernetes. Is K8S new Linux?
Wojciech Barczyński
 
PPTX
Kubernetes and Istio
Ketan Gote
 
PPTX
Tech huddle paas_session
Rob Edwards
 
PDF
Camel on Cloud by Christina Lin
Tadayoshi Sato
 
PDF
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
NETWAYS
 
PPTX
Demystifying Application Connectivity with Kubernetes in the Docker Platform
Nicola Kabar
 
PPTX
Building Developer Pipelines with PKS, Harbor, Clair, and Concourse
VMware Tanzu
 
PDF
Functest in Depth
OPNFV
 
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
Kubernetes and the 12 factor cloud apps
Ana-Maria Mihalceanu
 
Zero downtime deployment of micro-services with Kubernetes
Wojciech Barczyński
 
Zero-downtime deployment of Micro-services with Kubernetes
Wojciech Barczyński
 
Monitoring kubernetes with prometheus
Brice Fernandes
 
Kubernetes &amp; the 12 factor cloud apps
Ana-Maria Mihalceanu
 
Kong Mesh入門編
WenhanShi1
 
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Codemotion
 
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 
Kafka summit apac session
Christina Lin
 
London Adapt or Die: Kubernetes, Containers and Cloud - The MoD Story
Apigee | Google Cloud
 
Effective Building your Platform with Kubernetes == Keep it Simple
Wojciech Barczyński
 
Effective Platform Building with Kubernetes. Is K8S new Linux?
Wojciech Barczyński
 
Kubernetes and Istio
Ketan Gote
 
Tech huddle paas_session
Rob Edwards
 
Camel on Cloud by Christina Lin
Tadayoshi Sato
 
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
NETWAYS
 
Demystifying Application Connectivity with Kubernetes in the Docker Platform
Nicola Kabar
 
Building Developer Pipelines with PKS, Harbor, Clair, and Concourse
VMware Tanzu
 
Functest in Depth
OPNFV
 
Ad

More from Ana-Maria Mihalceanu (20)

PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
Sécuriser les Applications Java Contre les Menaces Quantiques
Ana-Maria Mihalceanu
 
PDF
Des joyaux de code natif aux trésors Java avec jextract
Ana-Maria Mihalceanu
 
PDF
From native code gems to Java treasures with jextract
Ana-Maria Mihalceanu
 
PDF
Exciting Features and Enhancements in Java 23 and 24
Ana-Maria Mihalceanu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
PDF
From native code gems to Java treasures with jextract
Ana-Maria Mihalceanu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
Java 23 and Beyond - A Roadmap Of Innovations
Ana-Maria Mihalceanu
 
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
Java 22 and Beyond- A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
Surveillance de la sécurité des applications Java avec les outils du JDK e...
Ana-Maria Mihalceanu
 
PDF
A Glance At The Java Performance Toolbox
Ana-Maria Mihalceanu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Ana-Maria Mihalceanu
 
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
PDF
Java 21 Language Features and Beyond
Ana-Maria Mihalceanu
 
PDF
From Java 17 to 21- A Showcase of JDK Security Enhancements
Ana-Maria Mihalceanu
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Sécuriser les Applications Java Contre les Menaces Quantiques
Ana-Maria Mihalceanu
 
Des joyaux de code natif aux trésors Java avec jextract
Ana-Maria Mihalceanu
 
From native code gems to Java treasures with jextract
Ana-Maria Mihalceanu
 
Exciting Features and Enhancements in Java 23 and 24
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
From native code gems to Java treasures with jextract
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Java 23 and Beyond - A Roadmap Of Innovations
Ana-Maria Mihalceanu
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Java 22 and Beyond- A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Surveillance de la sécurité des applications Java avec les outils du JDK e...
Ana-Maria Mihalceanu
 
A Glance At The Java Performance Toolbox
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Ana-Maria Mihalceanu
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Ana-Maria Mihalceanu
 
Java 21 Language Features and Beyond
Ana-Maria Mihalceanu
 
From Java 17 to 21- A Showcase of JDK Security Enhancements
Ana-Maria Mihalceanu
 

Recently uploaded (20)

PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Doc9.....................................
SofiaCollazos
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 

Kubernetes and the 12 factor cloud apps

  • 1. Kubernetes & the 12 factors cloud applications Ana Maria Mihalceanu #JBCNConf2019
  • 2. @ammbra1508#vJUG HELLO! I am Ana Technical Lead @ IBM Co-founder of Bucharest Software Craftsmanship Community
  • 3. Why 12 factors & Kubernetes? @ammbra1508#vJUG
  • 4. Why 12 factors & Kubernetes? @ammbra1508#vJUG Evolution Declarative formats
  • 5. Why 12 factors & Kubernetes? @ammbra1508#vJUG Run at push of a button Evolution Declarative formats Scale up with minimal changes Declarative formats Scale up with minimal changes
  • 6. Why 12 factors & Kubernetes? @ammbra1508#vJUG Portability Run at push of a button Evolution Declarative formats Scale up with minimal changes Clean Contract
  • 7. Why 12 factors & Kubernetes? @ammbra1508#vJUG PortabilityLocal vs production Run at push of a button Evolution Declarative formats Scale up with minimal changes Clean Contract Continuous deployment
  • 9. FACTOR 1 - CODEBASE @ammbra1508#vJUG One codebase tracked in revision control, with multiple deployments.
  • 11. FACTOR 1 - CODEBASE @ammbra1508#vJUG HELM v2.x.y
  • 13. FACTOR 2 - DEPENDENCIES @ammbra1508#vJUG Explicitly declare and isolate dependencies.
  • 14. FACTOR 2 - DEPENDENCIES @ammbra1508#vJUG { "name": "fed", "version": "1.0.0", "dependencies": { "ejs": "^2.6.1", "express": "^4.16.3", "req-flash": "0.0.3", "request": "2.81.0" } }
  • 15. FACTOR 2 - DEPENDENCIES @ammbra1508#vJUG apiVersion: apps/v1 kind: Deployment metadata: name: dreamhome-web labels: app: dreamhome-web tier: frontend
  • 16. FACTOR 2 - DEPENDENCIES @ammbra1508#vJUG apiVersion: apps/v1 kind: Deployment metadata: name: dreamhome-web labels: app: dreamhome-web tier: frontend spec: replicas: 2 selector: matchLabels: app: dreamhome-web
  • 17. FACTOR 2 - DEPENDENCIES @ammbra1508#vJUG apiVersion: apps/v1 kind: Deployment metadata: name: dreamhome-web labels: app: dreamhome-web tier: frontend spec: replicas: 2 selector: matchLabels: app: dreamhome-web template: metadata: labels: app: dreamhome-web tier: frontend implementation: nodejs
  • 18. FACTOR 3 - CONFIGURATION @ammbra1508#vJUG
  • 19. FACTOR 3 - CONFIGURATION @ammbra1508#vJUG Store configuration in the environment. kubectl create secret docker-registry ${SECRET_NAME} --namespace ${CLUSTER_NAMESPACE} --docker-server=${REGISTRY} --docker-username=iamapikey --docker-password=${TOKEN} [email protected]
  • 20. FACTOR 3 - CONFIGURATION @ammbra1508#vJUG Store configuration in the environment. kubectl create secret docker-registry ${SECRET_NAME} --namespace ${CLUSTER_NAMESPACE} --docker-server=${REGISTRY} --docker-username=iamapikey --docker-password=${TOKEN} [email protected]
  • 21. FACTOR 4 – BACKING SERVICE @ammbra1508#vJUG
  • 22. Treat backing services as attached resources. FACTOR 4 – BACKING SERVICE @ammbra1508#vJUG apiVersion: v1 kind: Secret metadata: name: cloudant type: Opaque data: binding: {}
  • 23. FACTOR 4 – BACKING SERVICE @ammbra1508#vJUG Treat backing services as attached resources. apiVersion: v1 kind: Secret metadata: name: cloudant type: Opaque data: binding: {}
  • 24. FACTOR 4 – BACKING SERVICE @ammbra1508#vJUG Treat backing services as attached resources. apiVersion: v1 kind: Secret metadata: name: cloudant type: Opaque data: binding: {}
  • 25. FACTOR 5 – BUILD, RELEASE, RUN @ammbra1508#vJUG
  • 26. FACTOR 5 – BUILD, RELEASE, RUN @ammbra1508#vJUG Strictly separate build and run stages.
  • 27. FACTOR 5 – BUILD, RELEASE, RUN @ammbra1508#vJUG
  • 29. FACTOR 6 – PROCESSES @ammbra1508#vJUG Execute the app as one or more stateless processes. Container Filesystem Persistent VolumeVolume
  • 30. FACTOR 6 – PROCESSES @ammbra1508#vJUG kubectl apply –f ${CREATE_VOLUME}.yaml kubectl apply –f ${COPY_SCRIPTS_POLLER}.yaml kubectl cp ./scripts ${POD}:/${LOCATION} kubectl apply –f ${USE_SCRIPTS}.yaml
  • 31. FACTOR 7 – PORT BINDING @ammbra1508#vJUG kubectl apply –f ${FILE}
  • 32. FACTOR 7 – PORT BINDING @ammbra1508#vJUG Export services via port binding.
  • 33. FACTOR 7 – PORT BINDING @ammbra1508#vJUG Export services via port binding. kubectl expose deployment/${NAME} --type=”${SERVICE_TYPE}” --name=${SERVICE_NAME}
  • 34. FACTOR 8 – CONCURRENCY @ammbra1508#vJUG Scale out via the process model.
  • 35. FACTOR 8 – CONCURRENCY @ammbra1508#vJUG Scale out via the process model.
  • 36. FACTOR 8 – CONCURRENCY @ammbra1508#vJUG kubectl autoscale deployment {$DEPLOYMENT} --min=${MIN_PODS} --max=${MAX_PODS} --cpu-percent=${CPU} --namespace=${NAMESPACE}
  • 37. FACTOR 8 – CONCURRENCY @ammbra1508#vJUG kubectl autoscale deployment {$DEPLOYMENT} --min=${MIN_PODS} --max=${MAX_PODS} --cpu-percent=${CPU} --namespace=${NAMESPACE} 𝐝𝐞𝐬𝐢𝐫𝐞𝐝𝐑𝐞𝐩𝐥𝐢𝐜𝐚𝐬 = ceil(currentReplicas × currentMetricValue 𝐝𝐞𝐬𝐢𝐫𝐞𝐝𝐌𝐞𝐭𝐫𝐢𝐜𝐕𝐚𝐥𝐮𝐞 )
  • 38. FACTOR 9 – DISPOSABILITY @ammbra1508#vJUG Fast startup Graceful shutdown Maximize robustness with
  • 39. FACTOR 9 – DISPOSABILITY @ammbra1508#vJUG Application boot time
  • 40. FACTOR 9 – DISPOSABILITY @ammbra1508#vJUG Rolling update one after another
  • 42. FACTOR 10 – DEV PROD PARITY @ammbra1508#vJUG Time People Tools
  • 43. FACTOR 10 – DEV PROD PARITY @ammbra1508#vJUG Keep development, staging and production as similar as possible. kubectl create namespace ${NAMESPACE}
  • 44. FACTOR 11 – LOGS @ammbra1508#vJUG
  • 45. FACTOR 11 – LOGS @ammbra1508#vJUG Treat logs as event streams. kubectl create secret generic logdna-agent-key --from-literal=logdna-agent-key=<ingestion_key> kubectl create -f https://repo.logdna.com/ibm/prod/logdna-agent-ds- us-south.yaml
  • 46. FACTOR 12 – ADMIN PROCESSES @ammbra1508#vJUG Run admin/management tasks as one-off processes. kubectl create configmap ${CONFIG} --from-file=scripts/ -o yaml kubectl apply –f ${ONE_TIME_JOB_CONFIGURATION}
  • 48. @ammbra1508#vJUG TAKEAWAYS Decouple Decouple infrastructure complexity from your application code. Managed Services Prefer managed services in matters involving persistency. Environment Parity Keep your environments as similar as possible.
  • 49. @ammbra1508#vJUG TAKEAWAYS Stateless Design your application as stateless. Scale Your application should be able to process diverse workloads. Monitor Use appropriate logging in application code and implement cluster-level logging.
  • 50. @ammbra1508#vJUG The strongest factor for success is self-esteem. Believing you can do it, believing you deserve it, believing you will get it. Anonymous “ “