SlideShare a Scribd company logo
An Introduction to Using
PostgreSQL with
Docker & Kubernetes
Jonathan S. Katz

DC PostgreSQL User Group

April 2, 2018
1
About Crunchy Data
• Leading provider of trusted
open source PostgreSQL and
PostgreSQL related
technologies, support and
training to enterprises.

• We're Hiring!

• crunchydata.com
2
About Me
• Director of Communications &
Customer Success, Crunchy Data

• Longtime PostgreSQL community
contributor

• Director, PgUS

• Co-Organizer, NYCPUG

• @postgresql + .org content

• Conference organization +
speaking galore!

• @jkatz05
!3
Outline
• Containers: A Brief History

• Containers + PostgreSQL

• Setting up PostgreSQL with Containers

• Deploying! - Container Orchestration

• Look Ahead: Trends in the Container World
!4
What are Containers?
• Containers are processes that
contain all the requirements to
execute an application

• Similar to virtual machines,
Sandbox for applications
similar to a virtual machine but
with increased density on a
single host
5
Source: Docker
Container Glossary
• Image

• The base filesystem that defines what to load in a
container runtime. This is static.

• Container

• The runtime loads an image and instructions on how to
set up the run time environment. File changes can be
persisted to external mounts
https://docs.docker.com/glossary/
!6
Why Containers?
• Lightweight

• Compared to VMs, use less disk, RAM, CPU

• Ability to sandbox

• Runtime is in an isolated environment

• Portability

• Can run containers on different platforms
!7
Container Runtimes
• Open Containers Initiative (OCI)

• Developing standards for how containers should run
and interface with platforms

• containerd, Docker, runC, rkt
!8
Container Example:
Web Application
Create Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /path/to/app/code/
WORKDIR /path/to/app/code/
ADD requirements.txt /path/to/app/code/
RUN pip install -r requirements.txt
ADD . /path/to/app/code/
!9
1.11.11
7.4
Container Example:
Web Application
Define and Execute the Container Runtime
!10
/path/to/app/code/
8000
1.11.11
8000
7.4
Container Example:
Web Application
Create multiple runtimes
!11
/path/to/app/code/
8001
1.11.11
8000
7.4
8000
1.11.11
8000
7.4
8002
1.11.11
8000
7.4
Container Example:
Web Application
Update Django Versions
!12
Containers & PostgreSQL
• Containers provide several advantages to running
PostgreSQL:

• Setup & distribution for developer environments

• Ease of packaging extensions & minor upgrades

• Separate out secondary applications (monitoring,
administration)

• Automation and scale for provisioning and creating
replicas, backups
Images sourced: docker.com & postgresql.org!13
Containers & PostgreSQL
• Containers also introduce several challenges:

• Administrator needs to understand and select appropriate
storage options

• Configuration for individual database specifications and
user access

• Managing 100s - 1000s of containers requires appropriate
orchestration (more on that later)

• However, these are challenges you will find in most database
environments
Images sourced: docker.com & postgresql.org!14
• We will use the Crunchy Container Suite

• PostgreSQL (+ PostGIS): our favorite database; option to add our favorite geospatial extension

• pgpool + pgbouncer: connection pooling, load balancing

• pgbackrest: terabyte-scale backup management

• Monitoring: Prometheus + export

• Failover: "crunchy-watch"

• pgadmin4: UX-driven management

• Open source!

• Apache 2.0 license

• Support for Docker 1.12+, Kubernetes 1.5+

• Actively maintained and updated
Getting Started With
Containers + PostgreSQL
https://github.com/CrunchyData/crunchy-containers!15
Getting Started With
Containers + PostgreSQL
https://github.com/CrunchyData/crunchy-containers
!16
Getting Started with
Containers & PostgreSQL
mkdir postgres
cd postgres
docker volume create --driver local --name=pgvolume
docker network create --driver bridge pgnetwork
cat << EOF > pg-env.list
PG_MODE=primary
PG_PRIMARY_USER=postgres
PG_PRIMARY_PASSWORD=password
PG_DATABASE=whales
PG_USER=jkatz
PG_PASSWORD=password
PG_ROOT_PASSWORD=password
PG_PRIMARY_PORT=5432
EOF
docker run --publish 5432:5432 
--volume=pgvolume:/pgdata 
--env-file=pg-env.list 
--name="postgres" 
--hostname="postgres" 
--network="pgnetwork" 
--detach 
crunchydata/crunchy-postgres:centos7-10.3-1.8.2
Load the crunchy-postgres image
!17
Demo
!18
Adding pgadmin4
• pgadmin4 is an open source
user interface for working with
PostgreSQL

• Desktop + Web support
19
Adding pgadmin4
Load the crunchy-pgadmin4 image
docker volume create --driver local --name=pga4volume
cat << EOF > pgadmin4-env.list
PGADMIN_SETUP_EMAIL=jonathan.katz@crunchydata.com
PGADMIN_SETUP_PASSWORD=securepassword
SERVER_PORT=5050
EOF
docker run --publish 5050:5050 
--volume=pga4volume:/var/lib/pgadmin 
--env-file=pgadmin4-env.list 
--name="pgadmin4" 
--hostname="pgadmin4" 
--network="pgnetwork" 
--detach 
crunchydata/crunchy-pgadmin4:centos7-10.3-1.8.2
!20
Demo
!21
Recap So Far
• Explored what / why / how of containers

• Set up a PostgreSQL 10 instance that can be managed
with pgadmin4 in a development environment
!22
How do I manage
these things at scale?
!23
Kubernetes:
Container Orchestration
• "Open-source system for
automating deployment,
scaling, and management of
containerized applications."

• Manage the full lifecycle of a
container

• Pods => Services

• Nodes => Cluster

• Volumes
24
Source: https://kubernetes.io
Kubernetes is
incredibly powerful
!25
Kubernetes is
*not* easy to set up
!26
When to Use Kubernetes
	•	 Managing a few
containers is very different
than managing 100s, if
not 1000s

	•	 Advanced “orchestration”
required to manage this
many containers
27
PostgreSQL in a
Kubernetes World
• Advantages for using Kubernetes with PostgreSQL

• Your own "database-as-a-service"

• Mass apply databases commands:

• Updates

• Backups / Restores

• ACL rule changes

• Scale up / down replicas, though...
!28
PostgreSQL in a
Kubernetes World
• Kubernetes is "turnkey" for stateless applications

• e.g. web servers

• Databases do maintain state: permanent storage

• Persistent Volumes (PV)

• Persistent Volume Claims (PVC)
!29
The "postgres operator"
• (aka "Crunchy PostgreSQL for Kubernetes")

• Allows an administrator to run PostgreSQL-specific
commands to manage database clusters, including:

• Creating / Deleting a cluster (your own DBaaS)

• Scaling up / down replicas

• Apply user policies to PostgreSQL instances

• REST API
!30
https://github.com/CrunchyData/postgres-operator
How The Operator Works
!31
Example Architecture
!32
Looking Ahead
• Containers are no longer "new" - orchestration technologies have
matured

• Big debate with containers + databases: storage & management

• No different than virtual machines + databases

• Databases are still databases: need expertise to manage

• Database deployment automation flexibility

• Deploy your architecture to any number of clouds

• "Monitoring at scale"
!33
Conclusions
• Containers + PostgreSQL gives you:

• Easy-to-setup development environments

• Your own production database-as-a-service

• Tools to automate management of over 1000s of
instances in short-order
!34
Questions?
!35
jonathan.katz@crunchydata.com

@jkatz05
Ad

Recommended

High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!
Jonathan Katz
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with Kubernetes
Jonathan Katz
 
Using PostgreSQL With Docker & Kubernetes - July 2018
Using PostgreSQL With Docker & Kubernetes - July 2018
Jonathan Katz
 
Building a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management Application
Jonathan Katz
 
A guide of PostgreSQL on Kubernetes
A guide of PostgreSQL on Kubernetes
t8kobayashi
 
Realtime Analytics with Druid
Realtime Analytics with Druid
SeungWoo Han
 
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
John Constable
 
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
Joe Stein
 
Flexible compute
Flexible compute
Peter Clapham
 
Presto At Treasure Data
Presto At Treasure Data
Taro L. Saito
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
MySQL Shell for Database Engineers
MySQL Shell for Database Engineers
Mydbops
 
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Spark Summit
 
Cassandra Introduction & Features
Cassandra Introduction & Features
Phil Peace
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
Joe Stein
 
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Altinity Ltd
 
Druid at naver.com - part 1
Druid at naver.com - part 1
Jungsu Heo
 
User Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDB
Kai Sasaki
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
DataStax
 
Introducing SciaaS @ Sanger
Introducing SciaaS @ Sanger
Peter Clapham
 
Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Mesosphere and Contentteam: A New Way to Run Cassandra
Mesosphere and Contentteam: A New Way to Run Cassandra
DataStax Academy
 
Multi Master PostgreSQL Cluster on Kubernetes
Multi Master PostgreSQL Cluster on Kubernetes
Ohyama Masanori
 
Terraform Modules Restructured
Terraform Modules Restructured
DoiT International
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
Sadayuki Furuhashi
 
Hbase Nosql
Hbase Nosql
elliando dias
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
Carlos Andrés García
 
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
VMware Tanzu
 

More Related Content

What's hot (20)

Flexible compute
Flexible compute
Peter Clapham
 
Presto At Treasure Data
Presto At Treasure Data
Taro L. Saito
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
MySQL Shell for Database Engineers
MySQL Shell for Database Engineers
Mydbops
 
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Spark Summit
 
Cassandra Introduction & Features
Cassandra Introduction & Features
Phil Peace
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
Joe Stein
 
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Altinity Ltd
 
Druid at naver.com - part 1
Druid at naver.com - part 1
Jungsu Heo
 
User Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDB
Kai Sasaki
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
DataStax
 
Introducing SciaaS @ Sanger
Introducing SciaaS @ Sanger
Peter Clapham
 
Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Mesosphere and Contentteam: A New Way to Run Cassandra
Mesosphere and Contentteam: A New Way to Run Cassandra
DataStax Academy
 
Multi Master PostgreSQL Cluster on Kubernetes
Multi Master PostgreSQL Cluster on Kubernetes
Ohyama Masanori
 
Terraform Modules Restructured
Terraform Modules Restructured
DoiT International
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
Sadayuki Furuhashi
 
Hbase Nosql
Hbase Nosql
elliando dias
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Presto At Treasure Data
Presto At Treasure Data
Taro L. Saito
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
MySQL Shell for Database Engineers
MySQL Shell for Database Engineers
Mydbops
 
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Spark Summit
 
Cassandra Introduction & Features
Cassandra Introduction & Features
Phil Peace
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
Joe Stein
 
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Data warehouse on Kubernetes - gentle intro to Clickhouse Operator, by Robert...
Altinity Ltd
 
Druid at naver.com - part 1
Druid at naver.com - part 1
Jungsu Heo
 
User Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDB
Kai Sasaki
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
DataStax
 
Introducing SciaaS @ Sanger
Introducing SciaaS @ Sanger
Peter Clapham
 
Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Mesosphere and Contentteam: A New Way to Run Cassandra
Mesosphere and Contentteam: A New Way to Run Cassandra
DataStax Academy
 
Multi Master PostgreSQL Cluster on Kubernetes
Multi Master PostgreSQL Cluster on Kubernetes
Ohyama Masanori
 
Terraform Modules Restructured
Terraform Modules Restructured
DoiT International
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
Sadayuki Furuhashi
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 

Similar to An Introduction to Using PostgreSQL with Docker & Kubernetes (20)

PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
Carlos Andrés García
 
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
VMware Tanzu
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
Jimmy Angelakos
 
Crunchy containers
Crunchy containers
Renato Lucena
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Cloud Native PostgreSQL
Cloud Native PostgreSQL
EDB
 
Deployment of PostgreSQL inside of Kubernetes with High Availability
Deployment of PostgreSQL inside of Kubernetes with High Availability
EDB
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
EDB
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Postgres on Kubernetes - Dos and Donts.pdf
Postgres on Kubernetes - Dos and Donts.pdf
Christoph Engelbert
 
Containers Roadshow: How to Develop Containers for the Enterprise
Containers Roadshow: How to Develop Containers for the Enterprise
Honza Horák
 
EDB Postgres with Containers
EDB Postgres with Containers
EDB
 
PostgreSQL and Linux Containers
PostgreSQL and Linux Containers
Jignesh Shah
 
Postgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh Shah
PivotalOpenSourceHub
 
Introduction to SQL Server in Containers
Introduction to SQL Server in Containers
Grant Fritchey
 
Docker Containers- Data Engineers' Arsenal.pdf
Docker Containers- Data Engineers' Arsenal.pdf
gr6336192
 
Cont0519
Cont0519
Samuel Dratwa
 
YugabyteDB - Distributed SQL Database on Kubernetes
YugabyteDB - Distributed SQL Database on Kubernetes
DoKC
 
A Primer on Kubernetes and Google Container Engine
A Primer on Kubernetes and Google Container Engine
RightScale
 
Docker for Ruby Developers
Docker for Ruby Developers
Aptible
 
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
Carlos Andrés García
 
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
PostgreSQL-as-a-Service with Crunchy PostgreSQL for PKS
VMware Tanzu
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
Jimmy Angelakos
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Cloud Native PostgreSQL
Cloud Native PostgreSQL
EDB
 
Deployment of PostgreSQL inside of Kubernetes with High Availability
Deployment of PostgreSQL inside of Kubernetes with High Availability
EDB
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
EDB
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Postgres on Kubernetes - Dos and Donts.pdf
Postgres on Kubernetes - Dos and Donts.pdf
Christoph Engelbert
 
Containers Roadshow: How to Develop Containers for the Enterprise
Containers Roadshow: How to Develop Containers for the Enterprise
Honza Horák
 
EDB Postgres with Containers
EDB Postgres with Containers
EDB
 
PostgreSQL and Linux Containers
PostgreSQL and Linux Containers
Jignesh Shah
 
Postgre sql linuxcontainers by Jignesh Shah
Postgre sql linuxcontainers by Jignesh Shah
PivotalOpenSourceHub
 
Introduction to SQL Server in Containers
Introduction to SQL Server in Containers
Grant Fritchey
 
Docker Containers- Data Engineers' Arsenal.pdf
Docker Containers- Data Engineers' Arsenal.pdf
gr6336192
 
YugabyteDB - Distributed SQL Database on Kubernetes
YugabyteDB - Distributed SQL Database on Kubernetes
DoKC
 
A Primer on Kubernetes and Google Container Engine
A Primer on Kubernetes and Google Container Engine
RightScale
 
Docker for Ruby Developers
Docker for Ruby Developers
Aptible
 
Ad

More from Jonathan Katz (11)

Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Jonathan Katz
 
Vectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQL
Jonathan Katz
 
Looking ahead at PostgreSQL 15
Looking ahead at PostgreSQL 15
Jonathan Katz
 
Build a Complex, Realtime Data Management App with Postgres 14!
Build a Complex, Realtime Data Management App with Postgres 14!
Jonathan Katz
 
Get Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAM
Jonathan Katz
 
Safely Protect PostgreSQL Passwords - Tell Others to SCRAM
Safely Protect PostgreSQL Passwords - Tell Others to SCRAM
Jonathan Katz
 
Developing and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDW
Jonathan Katz
 
On Beyond (PostgreSQL) Data Types
On Beyond (PostgreSQL) Data Types
Jonathan Katz
 
Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)
Jonathan Katz
 
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Jonathan Katz
 
Indexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data Types
Jonathan Katz
 
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Jonathan Katz
 
Vectors are the new JSON in PostgreSQL
Vectors are the new JSON in PostgreSQL
Jonathan Katz
 
Looking ahead at PostgreSQL 15
Looking ahead at PostgreSQL 15
Jonathan Katz
 
Build a Complex, Realtime Data Management App with Postgres 14!
Build a Complex, Realtime Data Management App with Postgres 14!
Jonathan Katz
 
Get Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAM
Jonathan Katz
 
Safely Protect PostgreSQL Passwords - Tell Others to SCRAM
Safely Protect PostgreSQL Passwords - Tell Others to SCRAM
Jonathan Katz
 
Developing and Deploying Apps with the Postgres FDW
Developing and Deploying Apps with the Postgres FDW
Jonathan Katz
 
On Beyond (PostgreSQL) Data Types
On Beyond (PostgreSQL) Data Types
Jonathan Katz
 
Accelerating Local Search with PostgreSQL (KNN-Search)
Accelerating Local Search with PostgreSQL (KNN-Search)
Jonathan Katz
 
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Jonathan Katz
 
Indexing Complex PostgreSQL Data Types
Indexing Complex PostgreSQL Data Types
Jonathan Katz
 
Ad

Recently uploaded (20)

SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 

An Introduction to Using PostgreSQL with Docker & Kubernetes

  • 1. An Introduction to Using PostgreSQL with Docker & Kubernetes Jonathan S. Katz DC PostgreSQL User Group April 2, 2018 1
  • 2. About Crunchy Data • Leading provider of trusted open source PostgreSQL and PostgreSQL related technologies, support and training to enterprises. • We're Hiring! • crunchydata.com 2
  • 3. About Me • Director of Communications & Customer Success, Crunchy Data • Longtime PostgreSQL community contributor • Director, PgUS • Co-Organizer, NYCPUG • @postgresql + .org content • Conference organization + speaking galore! • @jkatz05 !3
  • 4. Outline • Containers: A Brief History • Containers + PostgreSQL • Setting up PostgreSQL with Containers • Deploying! - Container Orchestration • Look Ahead: Trends in the Container World !4
  • 5. What are Containers? • Containers are processes that contain all the requirements to execute an application • Similar to virtual machines, Sandbox for applications similar to a virtual machine but with increased density on a single host 5 Source: Docker
  • 6. Container Glossary • Image • The base filesystem that defines what to load in a container runtime. This is static. • Container • The runtime loads an image and instructions on how to set up the run time environment. File changes can be persisted to external mounts https://docs.docker.com/glossary/ !6
  • 7. Why Containers? • Lightweight • Compared to VMs, use less disk, RAM, CPU • Ability to sandbox • Runtime is in an isolated environment • Portability • Can run containers on different platforms !7
  • 8. Container Runtimes • Open Containers Initiative (OCI) • Developing standards for how containers should run and interface with platforms • containerd, Docker, runC, rkt !8
  • 9. Container Example: Web Application Create Dockerfile FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir -p /path/to/app/code/ WORKDIR /path/to/app/code/ ADD requirements.txt /path/to/app/code/ RUN pip install -r requirements.txt ADD . /path/to/app/code/ !9 1.11.11 7.4
  • 10. Container Example: Web Application Define and Execute the Container Runtime !10 /path/to/app/code/ 8000 1.11.11 8000 7.4
  • 11. Container Example: Web Application Create multiple runtimes !11 /path/to/app/code/ 8001 1.11.11 8000 7.4 8000 1.11.11 8000 7.4 8002 1.11.11 8000 7.4
  • 13. Containers & PostgreSQL • Containers provide several advantages to running PostgreSQL: • Setup & distribution for developer environments • Ease of packaging extensions & minor upgrades • Separate out secondary applications (monitoring, administration) • Automation and scale for provisioning and creating replicas, backups Images sourced: docker.com & postgresql.org!13
  • 14. Containers & PostgreSQL • Containers also introduce several challenges: • Administrator needs to understand and select appropriate storage options • Configuration for individual database specifications and user access • Managing 100s - 1000s of containers requires appropriate orchestration (more on that later) • However, these are challenges you will find in most database environments Images sourced: docker.com & postgresql.org!14
  • 15. • We will use the Crunchy Container Suite • PostgreSQL (+ PostGIS): our favorite database; option to add our favorite geospatial extension • pgpool + pgbouncer: connection pooling, load balancing • pgbackrest: terabyte-scale backup management • Monitoring: Prometheus + export • Failover: "crunchy-watch" • pgadmin4: UX-driven management • Open source! • Apache 2.0 license • Support for Docker 1.12+, Kubernetes 1.5+ • Actively maintained and updated Getting Started With Containers + PostgreSQL https://github.com/CrunchyData/crunchy-containers!15
  • 16. Getting Started With Containers + PostgreSQL https://github.com/CrunchyData/crunchy-containers !16
  • 17. Getting Started with Containers & PostgreSQL mkdir postgres cd postgres docker volume create --driver local --name=pgvolume docker network create --driver bridge pgnetwork cat << EOF > pg-env.list PG_MODE=primary PG_PRIMARY_USER=postgres PG_PRIMARY_PASSWORD=password PG_DATABASE=whales PG_USER=jkatz PG_PASSWORD=password PG_ROOT_PASSWORD=password PG_PRIMARY_PORT=5432 EOF docker run --publish 5432:5432 --volume=pgvolume:/pgdata --env-file=pg-env.list --name="postgres" --hostname="postgres" --network="pgnetwork" --detach crunchydata/crunchy-postgres:centos7-10.3-1.8.2 Load the crunchy-postgres image !17
  • 19. Adding pgadmin4 • pgadmin4 is an open source user interface for working with PostgreSQL • Desktop + Web support 19
  • 20. Adding pgadmin4 Load the crunchy-pgadmin4 image docker volume create --driver local --name=pga4volume cat << EOF > pgadmin4-env.list [email protected] PGADMIN_SETUP_PASSWORD=securepassword SERVER_PORT=5050 EOF docker run --publish 5050:5050 --volume=pga4volume:/var/lib/pgadmin --env-file=pgadmin4-env.list --name="pgadmin4" --hostname="pgadmin4" --network="pgnetwork" --detach crunchydata/crunchy-pgadmin4:centos7-10.3-1.8.2 !20
  • 22. Recap So Far • Explored what / why / how of containers • Set up a PostgreSQL 10 instance that can be managed with pgadmin4 in a development environment !22
  • 23. How do I manage these things at scale? !23
  • 24. Kubernetes: Container Orchestration • "Open-source system for automating deployment, scaling, and management of containerized applications." • Manage the full lifecycle of a container • Pods => Services • Nodes => Cluster • Volumes 24 Source: https://kubernetes.io
  • 26. Kubernetes is *not* easy to set up !26
  • 27. When to Use Kubernetes • Managing a few containers is very different than managing 100s, if not 1000s
 • Advanced “orchestration” required to manage this many containers 27
  • 28. PostgreSQL in a Kubernetes World • Advantages for using Kubernetes with PostgreSQL • Your own "database-as-a-service" • Mass apply databases commands: • Updates • Backups / Restores • ACL rule changes • Scale up / down replicas, though... !28
  • 29. PostgreSQL in a Kubernetes World • Kubernetes is "turnkey" for stateless applications • e.g. web servers • Databases do maintain state: permanent storage • Persistent Volumes (PV) • Persistent Volume Claims (PVC) !29
  • 30. The "postgres operator" • (aka "Crunchy PostgreSQL for Kubernetes") • Allows an administrator to run PostgreSQL-specific commands to manage database clusters, including: • Creating / Deleting a cluster (your own DBaaS) • Scaling up / down replicas • Apply user policies to PostgreSQL instances • REST API !30 https://github.com/CrunchyData/postgres-operator
  • 31. How The Operator Works !31
  • 33. Looking Ahead • Containers are no longer "new" - orchestration technologies have matured • Big debate with containers + databases: storage & management • No different than virtual machines + databases • Databases are still databases: need expertise to manage • Database deployment automation flexibility • Deploy your architecture to any number of clouds • "Monitoring at scale" !33
  • 34. Conclusions • Containers + PostgreSQL gives you: • Easy-to-setup development environments • Your own production database-as-a-service • Tools to automate management of over 1000s of instances in short-order !34