SlideShare a Scribd company logo
Databases in K8s world
16. CNCF - Kubernetes Slovensko Meetup
Dávid Kőszeghy, MAKERS
Agenda
● K8s stateful fundamentals
● Hands on: Simple setup to get up and running
● Helm with DB setup
● HA and why it gets complicated really fast
● Operators - CRD for the workloads
● Hands on: PostgreSQL as first class citizen
● Why to run DBs at K8s in the first place
Fundamentals
K8s stateful fundamentals
● Stateful applications usually need one or more from:
○ Stable, persistent storage so they can save the state and reload after downtime
○ Stable, persistent identifiers on network so they can be resolved for connections (i.e DNS)
○ Ordered, graceful deployment and scaling, i.e master <> slave relations can be established, replicas,
voted
○ Ordered rolling updates - once triggered you need to follow-up on all instances to finish
For this, Kubernetes has a specific Workload API resource: Statefulsets
Volumes in K8s - intro
● Uncommitted files to a container layer are in the essence ephemeral, any kill and
start of new container will wipe them
● Docker popularized the concept of volumes - bind mount a hostPath or use named
volume created before
● K8s provides a lot of volume types with specific types, for starters you should know
about
○ PersistentVolumeClaims & their lifecycle
○ EmptyDir, HostPath
○ ConfigMap, Secret
Persistent Volumes & Lifecycle
Persistent
Volume
Block
Storage
K8s API
ICT
● Azure/AWS/GCP
Disk
● Ceph/GlusterFS
● hostPath
● Local
● NFS
● CSI
...
Container
Pod
ContainerSpec
VolumeMount v1 core
Persistent
Volume
Claim
PodSpec
Volume v1 core
PersistentVolumeClaimSpec v1 core
LabelSelector
Statefulset Workload API
● Naming convention which leads to expectable DNS names via headless service
● VolumeClaimTemplate definition inside Statefulset results in PV creation per Pod
(scaling creates more PVs for Pods)
● Simple rules for Deployment and Scaling (configurable)
pod-0
pod-1
pod-2
StatefulSet
pvc-pod-0
pvc-pod-1
pvc-pod-2
pv-pod-0
pv-pod-1
pv-pod-2
headless-svc
Simple setup to get up and running
A wrong approach
● Deployment
(Stateless)
● PVC
● PV
● Service (JDBC
expose)
A slightly better solution
● StatefulSet
● PVC
● PV
● Service (JDBC
expose)
● Headless Service
A simple stateful workload
● StatefulSet
● PVC
● StorageClass
● Service (JDBC expose)
● Headless Service
Advanced Topics
Deployment with Helm Chart
● Direct DB workload deployment to the K8s can be considered just test (not even
PoC)
● Relation DBs and usual NoSQL databases were not designed with K8s/containers in
mind
● A lot of configs/envs/secrets - separate files, even maybe some binary commands
● To manually address this is not a time spent wisely
● One approach would be to use Helm Charts that are maintained as open-source
charts
○ For example from Bitnami: https://github.com/bitnami/charts/tree/master/bitnami
HA DBs and why it gets complicated really fast
● As advanced topics, I’ll showcase it on PostgreSQL as one of the most popular
relation DBs out there
● Disclaimer: HA has become almost buzz word nowadays, but the CAP theorem is
real, and with DBs and cluster of nodes it becomes a distributed data store
● Usually applications are not prepared to handle HA, when problems with a
network occur, and they presume ACID is present as a baseline..
● Bottom line, to save the pain, be sure that you really, really need the HA.
HA DBs and why it gets complicated really fast
● Deploy statefulset of PostgreSQL nodes
● Use pg-pool II to LB the connections and have a fail-over setup from pgpool
● Use repmgr to replicate the state and the ability to ensure standby-node will
assume the primary role in case of a problem
As you can see above, the case of statefulset deployment got complicated by adding
more domain specific parts. These parts are different for each technology and as such
that’s why it’s important to have DBA (preferably with cloud & k8s knowledge).
Operators - CRD for the workloads
● Ensuring in multiple component deployments for workloads (such as HA DBs) that
everything is configured properly and you are able to react to system events is one
of the main aspects that the operators were created for
● More on the topic of operators is in Attila’s presentation from the 5th Kubernetes
Slovensko Meetup
● I’ll showcase a Operator setup for PostgreSQL
Why to run DBs at K8s in the first place
Benefits:
● Cloud Ecosystem usable on DB workloads
● Portability across environments
● Services are isolated for better security
● Easy replication of the setup for yet another
application that requires DB
● Upgrade of the DBs via operator is
semi-managed
● More streamlined ConOps after learning curve
results in less Ops time
Problems:
● Running DBs reliably is already a task of it self,
combining it with K8s creates a complex task
with new case of problems that you need to be
prepared for
● Kelsey Hightower told you not to but it was in
2016
● Distributed systems are hard
Why to run DBs at K8s in the first place
● It boils down to Ops budget, required functionality & number of nodes
To run or not to run a database on Kubernetes: What to consider
Dávid Kőszeghy
david.koszeghy@makers.sk
+421 901 744 988
19. Cloud Native Computing - Kubernetes - Bratislava - Databases in K8s world

More Related Content

What's hot (19)

PPTX
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
MayaData Inc
 
PPTX
Big Data on Cloud Native Platform
Sunil Govindan
 
PDF
Meshing OpenStack and Bare Metal Networks with EVPN - David Iles, Mellanox Te...
OpenStack
 
PDF
DUG'20: 10 - Storage Orchestration for Composable Storage Architectures
Andrey Kudryavtsev
 
PDF
[OpenStack Day in Korea 2015] Keynote 2 - Leveraging OpenStack to Realize the...
OpenStack Korea Community
 
PDF
Big data and Kubernetes
Anirudh Ramanathan
 
PPTX
K8S in prod
Mageshwaran Rajendran
 
PPTX
DalmatinerDB and cockroachDB monitoring plataform
Leandro Totino Pereira
 
PDF
Kubernetes Multitenancy - KubeSec Enterprise Security Summit
Sanjeev Rampal
 
PDF
Introduction to kubernetes
Gabriel Carro
 
PDF
Architectural patterns for high performance microservices in kubernetes
Rafał Leszko
 
PPTX
Paul Dix [InfluxData] | InfluxDays Opening Keynote | InfluxDays Virtual Exper...
InfluxData
 
PDF
The Future of Cloud Software Defined Storage with Ceph: Andrew Hatfield, Red Hat
OpenStack
 
PDF
12.07.2017 Docker Meetup - POSTGRE SQL ON KUBERNETES
Zalando adtech lab
 
PDF
Kafka on Kubernetes—From Evaluation to Production at Intuit
confluent
 
PDF
Automate Your Kafka Cluster with Kubernetes Custom Resources
confluent
 
PDF
Building a GPU-enabled OpenStack Cloud for HPC - Blair Bethwaite, Monash Univ...
OpenStack
 
PDF
Docker Workshop
Alex Baretto
 
PDF
Deploying Kafka Streams Applications with Docker and Kubernetes
confluent
 
Webinar: OpenEBS - Still Free and now FASTEST Kubernetes storage
MayaData Inc
 
Big Data on Cloud Native Platform
Sunil Govindan
 
Meshing OpenStack and Bare Metal Networks with EVPN - David Iles, Mellanox Te...
OpenStack
 
DUG'20: 10 - Storage Orchestration for Composable Storage Architectures
Andrey Kudryavtsev
 
[OpenStack Day in Korea 2015] Keynote 2 - Leveraging OpenStack to Realize the...
OpenStack Korea Community
 
Big data and Kubernetes
Anirudh Ramanathan
 
DalmatinerDB and cockroachDB monitoring plataform
Leandro Totino Pereira
 
Kubernetes Multitenancy - KubeSec Enterprise Security Summit
Sanjeev Rampal
 
Introduction to kubernetes
Gabriel Carro
 
Architectural patterns for high performance microservices in kubernetes
Rafał Leszko
 
Paul Dix [InfluxData] | InfluxDays Opening Keynote | InfluxDays Virtual Exper...
InfluxData
 
The Future of Cloud Software Defined Storage with Ceph: Andrew Hatfield, Red Hat
OpenStack
 
12.07.2017 Docker Meetup - POSTGRE SQL ON KUBERNETES
Zalando adtech lab
 
Kafka on Kubernetes—From Evaluation to Production at Intuit
confluent
 
Automate Your Kafka Cluster with Kubernetes Custom Resources
confluent
 
Building a GPU-enabled OpenStack Cloud for HPC - Blair Bethwaite, Monash Univ...
OpenStack
 
Docker Workshop
Alex Baretto
 
Deploying Kafka Streams Applications with Docker and Kubernetes
confluent
 

Similar to 19. Cloud Native Computing - Kubernetes - Bratislava - Databases in K8s world (20)

PDF
A guide of PostgreSQL on Kubernetes
t8kobayashi
 
PDF
Deploying PostgreSQL on Kubernetes
Jimmy Angelakos
 
PDF
Postgres on Kubernetes - Dos and Donts.pdf
Christoph Engelbert
 
PDF
YugabyteDB - Distributed SQL Database on Kubernetes
DoKC
 
PDF
Think like a storage architect, in four questions
Cheryl Hung
 
PDF
SREDAY London 2024 | Cloud Native Technologies: The Building Blocks of Modern...
Severalnines
 
PDF
Container Attached Storage with OpenEBS - CNCF Paris Meetup
MayaData Inc
 
PDF
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
PDF
MayaData Datastax webinar - Operating Cassandra on Kubernetes with the help ...
MayaData Inc
 
PDF
Using PostgreSQL With Docker & Kubernetes - July 2018
Jonathan Katz
 
PDF
The Highs and Lows of Stateful Containers
C4Media
 
PDF
Solving k8s persistent workloads using k8s DevOps style
MayaData
 
PDF
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC
 
PDF
Zero-to-Hero: Running Postgres in Kubernetes
EDB
 
PDF
stupid-simple-kubernetes-final.pdf
DaniloQueirozMota
 
PDF
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
PDF
Running a database on local NVMes on Kubernetes
DoKC
 
PDF
Running a database on local NVMes on Kubernetes
DoKC
 
PDF
Managing Stateful Applications in Kubernetes
All Things Open
 
PDF
Kubernetes: My BFF
Jonathan Yu
 
A guide of PostgreSQL on Kubernetes
t8kobayashi
 
Deploying PostgreSQL on Kubernetes
Jimmy Angelakos
 
Postgres on Kubernetes - Dos and Donts.pdf
Christoph Engelbert
 
YugabyteDB - Distributed SQL Database on Kubernetes
DoKC
 
Think like a storage architect, in four questions
Cheryl Hung
 
SREDAY London 2024 | Cloud Native Technologies: The Building Blocks of Modern...
Severalnines
 
Container Attached Storage with OpenEBS - CNCF Paris Meetup
MayaData Inc
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
MayaData Datastax webinar - Operating Cassandra on Kubernetes with the help ...
MayaData Inc
 
Using PostgreSQL With Docker & Kubernetes - July 2018
Jonathan Katz
 
The Highs and Lows of Stateful Containers
C4Media
 
Solving k8s persistent workloads using k8s DevOps style
MayaData
 
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC
 
Zero-to-Hero: Running Postgres in Kubernetes
EDB
 
stupid-simple-kubernetes-final.pdf
DaniloQueirozMota
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
Running a database on local NVMes on Kubernetes
DoKC
 
Running a database on local NVMes on Kubernetes
DoKC
 
Managing Stateful Applications in Kubernetes
All Things Open
 
Kubernetes: My BFF
Jonathan Yu
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Python basic programing language for automation
DanialHabibi2
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Ad

19. Cloud Native Computing - Kubernetes - Bratislava - Databases in K8s world

  • 1. Databases in K8s world 16. CNCF - Kubernetes Slovensko Meetup Dávid Kőszeghy, MAKERS
  • 2. Agenda ● K8s stateful fundamentals ● Hands on: Simple setup to get up and running ● Helm with DB setup ● HA and why it gets complicated really fast ● Operators - CRD for the workloads ● Hands on: PostgreSQL as first class citizen ● Why to run DBs at K8s in the first place
  • 4. K8s stateful fundamentals ● Stateful applications usually need one or more from: ○ Stable, persistent storage so they can save the state and reload after downtime ○ Stable, persistent identifiers on network so they can be resolved for connections (i.e DNS) ○ Ordered, graceful deployment and scaling, i.e master <> slave relations can be established, replicas, voted ○ Ordered rolling updates - once triggered you need to follow-up on all instances to finish For this, Kubernetes has a specific Workload API resource: Statefulsets
  • 5. Volumes in K8s - intro ● Uncommitted files to a container layer are in the essence ephemeral, any kill and start of new container will wipe them ● Docker popularized the concept of volumes - bind mount a hostPath or use named volume created before ● K8s provides a lot of volume types with specific types, for starters you should know about ○ PersistentVolumeClaims & their lifecycle ○ EmptyDir, HostPath ○ ConfigMap, Secret
  • 6. Persistent Volumes & Lifecycle Persistent Volume Block Storage K8s API ICT ● Azure/AWS/GCP Disk ● Ceph/GlusterFS ● hostPath ● Local ● NFS ● CSI ... Container Pod ContainerSpec VolumeMount v1 core Persistent Volume Claim PodSpec Volume v1 core PersistentVolumeClaimSpec v1 core LabelSelector
  • 7. Statefulset Workload API ● Naming convention which leads to expectable DNS names via headless service ● VolumeClaimTemplate definition inside Statefulset results in PV creation per Pod (scaling creates more PVs for Pods) ● Simple rules for Deployment and Scaling (configurable) pod-0 pod-1 pod-2 StatefulSet pvc-pod-0 pvc-pod-1 pvc-pod-2 pv-pod-0 pv-pod-1 pv-pod-2 headless-svc
  • 8. Simple setup to get up and running A wrong approach ● Deployment (Stateless) ● PVC ● PV ● Service (JDBC expose) A slightly better solution ● StatefulSet ● PVC ● PV ● Service (JDBC expose) ● Headless Service A simple stateful workload ● StatefulSet ● PVC ● StorageClass ● Service (JDBC expose) ● Headless Service
  • 10. Deployment with Helm Chart ● Direct DB workload deployment to the K8s can be considered just test (not even PoC) ● Relation DBs and usual NoSQL databases were not designed with K8s/containers in mind ● A lot of configs/envs/secrets - separate files, even maybe some binary commands ● To manually address this is not a time spent wisely ● One approach would be to use Helm Charts that are maintained as open-source charts ○ For example from Bitnami: https://github.com/bitnami/charts/tree/master/bitnami
  • 11. HA DBs and why it gets complicated really fast ● As advanced topics, I’ll showcase it on PostgreSQL as one of the most popular relation DBs out there ● Disclaimer: HA has become almost buzz word nowadays, but the CAP theorem is real, and with DBs and cluster of nodes it becomes a distributed data store ● Usually applications are not prepared to handle HA, when problems with a network occur, and they presume ACID is present as a baseline.. ● Bottom line, to save the pain, be sure that you really, really need the HA.
  • 12. HA DBs and why it gets complicated really fast ● Deploy statefulset of PostgreSQL nodes ● Use pg-pool II to LB the connections and have a fail-over setup from pgpool ● Use repmgr to replicate the state and the ability to ensure standby-node will assume the primary role in case of a problem As you can see above, the case of statefulset deployment got complicated by adding more domain specific parts. These parts are different for each technology and as such that’s why it’s important to have DBA (preferably with cloud & k8s knowledge).
  • 13. Operators - CRD for the workloads ● Ensuring in multiple component deployments for workloads (such as HA DBs) that everything is configured properly and you are able to react to system events is one of the main aspects that the operators were created for ● More on the topic of operators is in Attila’s presentation from the 5th Kubernetes Slovensko Meetup ● I’ll showcase a Operator setup for PostgreSQL
  • 14. Why to run DBs at K8s in the first place Benefits: ● Cloud Ecosystem usable on DB workloads ● Portability across environments ● Services are isolated for better security ● Easy replication of the setup for yet another application that requires DB ● Upgrade of the DBs via operator is semi-managed ● More streamlined ConOps after learning curve results in less Ops time Problems: ● Running DBs reliably is already a task of it self, combining it with K8s creates a complex task with new case of problems that you need to be prepared for ● Kelsey Hightower told you not to but it was in 2016 ● Distributed systems are hard
  • 15. Why to run DBs at K8s in the first place ● It boils down to Ops budget, required functionality & number of nodes To run or not to run a database on Kubernetes: What to consider