SlideShare a Scribd company logo
1 of 34
Download to read offline
Deploying PostgreSQL
on Kubernetes
Jimmy Angelakos FOSDEM
Platform Architect 03/02/2019
SolarWinds MSP
Motivation
●
Service Oriented Architecture (SOA), including
Micro– , exemplified perfectly by Kubernetes
●
Kubernetes is here to stay
●
Fewer phonecalls at 4 am?
●
Play around at home for free
●
Or get commercial support
●
Cloud Compute, Storage → Commodity
●
(Industrial-strength) Postgres is hard
●
You want Postgres → Commodity to your users
●
By no means an exhaustive list of solutions or
in-depth analysis but an attempt to demystify
What this is not
I. A demo of me fiddling with terminals and window tiling
techniques on the screen
II. Me typing in Kubernetes commands so you can see how
they are typed in
III. And… press ENTER. Ok, there, it worked. See?
IV. No wait. It didn’t. Let me fiddle some more.
What this is
Contents:
I. Kubernetes basics
II. Small scale
III. Helm Charts
IV. Crunchy Data Operator
V. Observations
I.
Kubernetes (k8s) basics
K8s basics – 1: K8s & Containers
●
Container: Lightweight, standalone, executable package
– Containerized software will run on any environment with no differences
– Resource efficient vs. VMs
– Platform independent vs. “It works on my machine ¯_( ツ )_/¯ ”
●
K8s is a container orchestrator
– Written in Go (Golang)
– Cloud Native Computing Foundation (CNCF)
– Scaling, load balancing, safely rolling out updates
– Abstracting infrastructure via API: Can use any cloud provider (or none)
– Resources: k8s API objects
– “Pets vs Cattle” debate
K8s basics – 2: Terms
●
Cluster
– Master node runs API server (our interface to the Cluster)
– Worker nodes run Kubelet and Pods
– Namespaces: Virtual clusters (resource quotas)
●
Kubelet
– Talks to Master node, monitors Pods
●
Pod
– A container or group of containers sharing the same execution environment
– Container coupling: sharing a volume or IPC
●
Volume
– Storage abstraction, many types
K8s basics – 3: Moar terms
●
Minikube
– Single-node k8s cluster in a VM – install VirtualBox and you’re good to go.
●
Prometheus
– Monitoring solution for k8s (also by CNCF, so described as “best fit”…)
●
Custom Resource Definitions
– Write them to extend k8s API at will
●
Operator pattern
– Custom domain-specific controllers that work with CRDs
– Configure & manage stateful applications for you
– No need for out-of-band automation
K8s basics – 4: YAML files
●
Definitions
– YAML!
– kind of resource e.g. Pod
– metadata e.g. name, labels
– spec i.e. the desired state for the
resource
●
Kubectl
– CLI tool for interacting with Cluster
kubectl create -f my-pod.yaml
kubectl get pods
K8s basics – 5: Services
●
Service
– Exposes Pods externally via URL
– Entry point for a set of Pods performing the same function
– Targets Pods using a selector for the labels applied to Pods
– Can have Type: ClusterIP, NodePort, LoadBalancer, ExternalName
– Needs a way to route traffic from outside the Cluster
●
NodePort will assign the same Port from each Node
●
LoadBalancer will provision an external LB from cloud provider
K8s basics – 6: Deployments
●
Deployment
– Automates upgrades of applications with zero downtime
– Enables fast rollbacks to previous state
kubectl rollout undo deployment my-app --to-revision=5
– Defines number of replicated Pods in spec
●
Manages ReplicaSets for you
– Can have Strategy: RollingUpdate, Recreate
K8s basics – 7: State
●
Stateless Applications
– Usually as a Deployment of Pod Replicas accessed via a Service
●
Stateful Applications
– StatefulSets
●
Stable storage
●
Stable network identifiers
●
Ordered deployment & scaling
●
Ordered RollingUpdates
K8s basics – 8: StatefulSets
●
spec
– Defines replicas in unique Pods (with stable network identity & storage)
– Defines storage in PersistentVolumes
●
Headless Service
– No load balancing, no cluster IP: self-registration or discovery possible
– Governs DNS subdomain of Pods: e.g. mypod-1.myservice.mynamespace
●
PersistentVolumes: Provisioned storage as a resource
●
PersistentVolumeClaim: A request for storage, consumes PV resources
●
Deletion
– Does not remove PersistentVolumes (for safety)
– Does not guarantee Pod termination (scale to zero before)
II.
Small scale
Small scale – 1: The image
●
You need a PostgreSQL container image
– Roll your own
– Use an existing image
●
PostgreSQL Docker Community “Official image”
– https://github.com/docker-library/postgres
docker pull postgres
●
Bitnami PostgreSQL Docker image
– https://github.com/bitnami/bitnami-docker-postgresql
●
Crunchy Data containers
– https://github.com/CrunchyData/crunchy-containers
Small scale – 2: Deployment
●
Create a ConfigMap for the
configuration values →
●
Create a PersistentVolume and a
PersistentVolumeClaim
●
Create a Deployment for your
Container image & PV
●
Create a Service to expose the above.
Simple: NodePort
●
Connect to your database via exposed
port or kubectl port forwarding
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
POSTGRES_DB: mydatabase
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
III.
Helm Charts
Helm Charts – 1: Introduction
●
Helm
– A “package manager” for k8s. Helm is the client.
– Tiller is the server-side component installed in k8s
●
Charts
– Directories of (you guessed it) YAML files
– Describe a set of related k8s resources
– values.yaml lets you customise options and configuration
●
PostgreSQL use case
– One-stop installation for a set of replicated databases
– It makes sense!
Helm Charts – 2: PostgreSQL Chart
●
Contributed by Bitnami, upstreamed:
– https://github.com/helm/charts/tree/master/stable/postgresql
●
Default Docker image repo is Bitnami
●
Installation is as simple as:
helm install --name my-release -f values.yaml stable/postgresql
– A Release in this context is an installation, a deployment
●
Output will include some magic commands for getting the DB password and
connecting to the running instance
●
postgresql.conf or pg_hba.conf can be provided in files/ folder and will
be mounted as a ConfigMap (special Volume type for abstracting configuration)
NAME: my-release
LAST DEPLOYED: Fri Jan 25 15:20:58 2019
NAMESPACE: my-namespace
STATUS: DEPLOYED
RESOURCES:
==> v1/Secret
NAME TYPE DATA AGE
my-release-postgresql Opaque 1 3s
==> v1/ConfigMap
NAME DATA AGE
my-release-postgresql-init-scripts 1 3s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-release-postgresql-headless ClusterIP None <none> 5432/TCP 3s
my-release-postgresql ClusterIP 10.101.211.6 <none> 5432/TCP 3s
==> v1beta2/StatefulSet
NAME DESIRED CURRENT AGE
my-release-postgresql 1 1 3s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
my-release-postgresql-0 0/1 Init:0/1 0 3s
NOTES:
** Please be patient while the chart is being deployed **
PostgreSQL can be accessed via port 5432 on the following DNS name from within your
cluster:
my-release-postgresql.my-namespace.svc.cluster.local
To get the password for "postgres" run:
export POSTGRESQL_PASSWORD=$(kubectl get secret --namespace my-namespace my-release-
postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
To connect to your database run the following command:
kubectl run my-release-postgresql-client --rm --tty -i --restart='Never' --namespace
my-namespace --image bitnami/postgresql --env="PGPASSWORD=$POSTGRESQL_PASSWORD" --command
-- psql --host my-release-postgresql -U postgres
To connect to your database from outside the cluster execute the following commands:
kubectl port-forward --namespace my-namespace svc/my-release-postgresql 5432:5432 &
psql --host 127.0.0.1 -U postgres
Helm Charts – 3: Internals
●
Defaults create:
– A StatefulSet with 1 Replica (1 Pod) running Postgres from the Docker image
– A Headless Service and a Service
– A PersistentVolumeClaim from the configured storage provisioner
●
Can be configured to:
– Load custom Postgres initialisation scripts as ConfigMaps from files/
– Start a metrics exporter to Prometheus:
●
https://github.com/wrouesnel/postgres_exporter
●
Export e.g. pg_stat_activity, pg_stat_replication or custom metrics
queries
Helm Charts – 4: Patroni Chart
●
For HA you can use the Helm Incubator Patroni Chart:
– https://github.com/helm/charts/tree/master/incubator/patroni
●
This, too, uses StatefulSets
●
Default installation deploys a 5 node Spilo cluster
– Zalando’s Spilo is Postgres & Patroni bundled image
●
Installation
helm repo add incubator https://kubernetes-charts-
incubator.storage.googleapis.com/
helm dependency update
helm install --name my-release incubator/patroni
IV.
Crunchy Operator
Crunchy Operator – 1
●
Crunchy Data PostgreSQL Operator
– https://github.com/CrunchyData/postgres-operator
●
Deploy Postgres with streaming replication & scaling
●
Add pgpool, pgbouncer, and metrics sidecars
●
Administer SQL policies, users, passwords
●
Assign labels to resources
●
Minor version upgrades
●
Perform backups and restores (or schedule them)
Crunchy Operator – 2
Quickstart:
●
git clone the GitHub repo, git checkout <tag>
●
source examples/envs.sh
●
make setupnamespace creates a “demo” namespace
●
conf/postgres-operator/pgo.yaml holds the configuration
●
make installrbac Creates RBAC resources and keys
●
make deployoperator
Crunchy Operator – 3: pgo
●
pgo is the CLI to interact with the operator
pgo create cluster my-cluster (--metrics if you want)
pgo show cluster my-cluster
pgo scale my-cluster --replica-count=2
pgo create pgbouncer my-cluster or
pgo create pgpool my-cluster to add
●
Backups
pgo create cluster my-cluster --pgbackrest
pgo backup my-cluster --backup-type=pgbackrest (or pgbasebackup)
pgo restore my-cluster
●
Manual failovers
pgo failover my-cluster –query (to get failover targets)
pgo failover my-cluster --target=my-failover-target-1
V.
Observations
Observations – 1: Deploying by hand
●
Good for rapid development
●
Offers equivalent isolation as VMs
●
Resource saving compared to VMs
●
Doesn’t offer many Cloud Native advantages
●
Production usage?
– Hard to maintain at scale unless you have an army of DBAs
Observations – 2: Helm Charts
●
Good for one-time deployments
●
Very clean and transparent
●
Major version upgrades?
●
Slave replicas – no failover unless you set it up explicitly
●
Flexibility to carry on using your existing solutions
●
Can be used by namespace-admin or plain user with
permissions
Observations – 3: Crunchy Operator
●
All-in-one solution, Postgres as an application
●
Makes many tasks easy via CLI and automates others
●
You need RBAC and cluster-admin permissions for creation of
CRDs
– Kubernetes does not support namespaced CRDs :(
– https://github.com/kubernetes/kubernetes/issues/65551
●
Under heavy development – perhaps not ideal for production?
– But so is Kubernetes :/
Observations – 4
●
Hard problem
– (Plain) Postgres cluster with multiple write nodes
– Multi-master is not always the solution
– Can leverage aforementioned solutions with 2ndQuadrant’s
pglogical for granularity
●
https://www.2ndquadrant.com/en/resources/pglogical/
●
Doesn’t even need a custom image, can be added as post-install hook
Alternatives?
●
DBaaS/PaaS like Heroku ($$$)
●
Managed cloudy DBs like EnterpriseDB’s (AWS) Postgres
●
Evil ;)
– Amazon RDS (/Aurora?) PostgreSQL
– Google Cloud SQL PostgreSQL
– Azure Database for PostgreSQL
●
Define as Services, connect to Endpoints
Thank you =)
Twitter: @vyruss
Photo: Forth Bridge, Firth of Forth, Edinburgh

More Related Content

What's hot

PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PGConf APAC
 
PostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSPostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSTomas Vondra
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep InternalEXEM
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOAltinity Ltd
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
Altinity Cluster Manager: ClickHouse Management for Kubernetes and Cloud
Altinity Cluster Manager: ClickHouse Management for Kubernetes and CloudAltinity Cluster Manager: ClickHouse Management for Kubernetes and Cloud
Altinity Cluster Manager: ClickHouse Management for Kubernetes and CloudAltinity Ltd
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldJignesh Shah
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsMydbops
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Anastasia Lubennikova
 
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)Lee Myring
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringSveta Smirnova
 
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...PostgreSQL-Consulting
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuningelliando dias
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howAltinity Ltd
 
Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Dieter Adriaenssens
 
Patroni: Kubernetes-native PostgreSQL companion
Patroni: Kubernetes-native PostgreSQL companionPatroni: Kubernetes-native PostgreSQL companion
Patroni: Kubernetes-native PostgreSQL companionAlexander Kukushkin
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)Roman Kharkovski
 

What's hot (20)

PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
PostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSPostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFS
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Altinity Cluster Manager: ClickHouse Management for Kubernetes and Cloud
Altinity Cluster Manager: ClickHouse Management for Kubernetes and CloudAltinity Cluster Manager: ClickHouse Management for Kubernetes and Cloud
Altinity Cluster Manager: ClickHouse Management for Kubernetes and Cloud
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
 
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)
Log aggregation: using Elasticsearch, Fluentd/Fluentbit and Kibana (EFK)
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
 
Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019Errant GTIDs breaking replication @ Percona Live 2019
Errant GTIDs breaking replication @ Percona Live 2019
 
Patroni: Kubernetes-native PostgreSQL companion
Patroni: Kubernetes-native PostgreSQL companionPatroni: Kubernetes-native PostgreSQL companion
Patroni: Kubernetes-native PostgreSQL companion
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
 

Similar to Deploying PostgreSQL on Kubernetes

CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinDataArt
 
Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Idan Atias
 
SCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scalingSCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scalingStanislav Osipov
 
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes][BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]Wong Hoi Sing Edison
 
Deploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayDeploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayAltoros
 
PaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpPaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpNathan Handler
 
CERN OpenStack Cloud Control Plane - From VMs to K8s
CERN OpenStack Cloud Control Plane - From VMs to K8sCERN OpenStack Cloud Control Plane - From VMs to K8s
CERN OpenStack Cloud Control Plane - From VMs to K8sBelmiro Moreira
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinEqunix Business Solutions
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...javier ramirez
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and HerokuTapio Rautonen
 
Google Cloud Platform for DeVops, by Javier Ramirez @ teowaki
Google Cloud Platform for DeVops, by Javier Ramirez @ teowakiGoogle Cloud Platform for DeVops, by Javier Ramirez @ teowaki
Google Cloud Platform for DeVops, by Javier Ramirez @ teowakijavier ramirez
 
Infrastructure Management in GCP
Infrastructure Management in GCPInfrastructure Management in GCP
Infrastructure Management in GCPDana Hoffman
 
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...NETWAYS
 
Rook - cloud-native storage
Rook - cloud-native storageRook - cloud-native storage
Rook - cloud-native storageKarol Chrapek
 
Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Joshua Harlow
 
Troubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentTroubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentSadique Puthen
 
Red Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShiftRed Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShiftJeremy Eder
 

Similar to Deploying PostgreSQL on Kubernetes (20)

CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas Kolenkin
 
Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)Introduction to Container Storage Interface (CSI)
Introduction to Container Storage Interface (CSI)
 
SCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scalingSCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scaling
 
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes][BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]
[BarCamp2018][20180915][Tips for Virtual Hosting on Kubernetes]
 
Deploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayDeploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with Kubespray
 
PaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpPaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at Yelp
 
Kash Kubernetified
Kash KubernetifiedKash Kubernetified
Kash Kubernetified
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
CERN OpenStack Cloud Control Plane - From VMs to K8s
CERN OpenStack Cloud Control Plane - From VMs to K8sCERN OpenStack Cloud Control Plane - From VMs to K8s
CERN OpenStack Cloud Control Plane - From VMs to K8s
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
 
reBuy on Kubernetes
reBuy on KubernetesreBuy on Kubernetes
reBuy on Kubernetes
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and Heroku
 
Google Cloud Platform for DeVops, by Javier Ramirez @ teowaki
Google Cloud Platform for DeVops, by Javier Ramirez @ teowakiGoogle Cloud Platform for DeVops, by Javier Ramirez @ teowaki
Google Cloud Platform for DeVops, by Javier Ramirez @ teowaki
 
Infrastructure Management in GCP
Infrastructure Management in GCPInfrastructure Management in GCP
Infrastructure Management in GCP
 
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
 
Rook - cloud-native storage
Rook - cloud-native storageRook - cloud-native storage
Rook - cloud-native storage
 
Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]Cloud init and cloud provisioning [openstack summit vancouver]
Cloud init and cloud provisioning [openstack summit vancouver]
 
Troubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentTroubleshooting containerized triple o deployment
Troubleshooting containerized triple o deployment
 
Red Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShiftRed Hat Summit 2018 5 New High Performance Features in OpenShift
Red Hat Summit 2018 5 New High Performance Features in OpenShift
 

More from Jimmy Angelakos

Don't Do This [FOSDEM 2023]
Don't Do This [FOSDEM 2023]Don't Do This [FOSDEM 2023]
Don't Do This [FOSDEM 2023]Jimmy Angelakos
 
Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Jimmy Angelakos
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresJimmy Angelakos
 
Changing your huge table's data types in production
Changing your huge table's data types in productionChanging your huge table's data types in production
Changing your huge table's data types in productionJimmy Angelakos
 
The State of (Full) Text Search in PostgreSQL 12
The State of (Full) Text Search in PostgreSQL 12The State of (Full) Text Search in PostgreSQL 12
The State of (Full) Text Search in PostgreSQL 12Jimmy Angelakos
 
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph Database
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph DatabaseBringing the Semantic Web closer to reality: PostgreSQL as RDF Graph Database
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph DatabaseJimmy Angelakos
 
Using PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic DataUsing PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic DataJimmy Angelakos
 
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλον
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλονEισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλον
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλονJimmy Angelakos
 
PostgreSQL: Mέθοδοι για Data Replication
PostgreSQL: Mέθοδοι για Data ReplicationPostgreSQL: Mέθοδοι για Data Replication
PostgreSQL: Mέθοδοι για Data ReplicationJimmy Angelakos
 

More from Jimmy Angelakos (9)

Don't Do This [FOSDEM 2023]
Don't Do This [FOSDEM 2023]Don't Do This [FOSDEM 2023]
Don't Do This [FOSDEM 2023]
 
Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
Changing your huge table's data types in production
Changing your huge table's data types in productionChanging your huge table's data types in production
Changing your huge table's data types in production
 
The State of (Full) Text Search in PostgreSQL 12
The State of (Full) Text Search in PostgreSQL 12The State of (Full) Text Search in PostgreSQL 12
The State of (Full) Text Search in PostgreSQL 12
 
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph Database
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph DatabaseBringing the Semantic Web closer to reality: PostgreSQL as RDF Graph Database
Bringing the Semantic Web closer to reality: PostgreSQL as RDF Graph Database
 
Using PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic DataUsing PostgreSQL with Bibliographic Data
Using PostgreSQL with Bibliographic Data
 
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλον
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλονEισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλον
Eισαγωγή στην PostgreSQL - Χρήση σε επιχειρησιακό περιβάλλον
 
PostgreSQL: Mέθοδοι για Data Replication
PostgreSQL: Mέθοδοι για Data ReplicationPostgreSQL: Mέθοδοι για Data Replication
PostgreSQL: Mέθοδοι για Data Replication
 

Recently uploaded

WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Deploying PostgreSQL on Kubernetes

  • 1. Deploying PostgreSQL on Kubernetes Jimmy Angelakos FOSDEM Platform Architect 03/02/2019 SolarWinds MSP
  • 2. Motivation ● Service Oriented Architecture (SOA), including Micro– , exemplified perfectly by Kubernetes ● Kubernetes is here to stay ● Fewer phonecalls at 4 am? ● Play around at home for free ● Or get commercial support ● Cloud Compute, Storage → Commodity ● (Industrial-strength) Postgres is hard ● You want Postgres → Commodity to your users ● By no means an exhaustive list of solutions or in-depth analysis but an attempt to demystify
  • 3. What this is not I. A demo of me fiddling with terminals and window tiling techniques on the screen II. Me typing in Kubernetes commands so you can see how they are typed in III. And… press ENTER. Ok, there, it worked. See? IV. No wait. It didn’t. Let me fiddle some more.
  • 4. What this is Contents: I. Kubernetes basics II. Small scale III. Helm Charts IV. Crunchy Data Operator V. Observations
  • 6. K8s basics – 1: K8s & Containers ● Container: Lightweight, standalone, executable package – Containerized software will run on any environment with no differences – Resource efficient vs. VMs – Platform independent vs. “It works on my machine ¯_( ツ )_/¯ ” ● K8s is a container orchestrator – Written in Go (Golang) – Cloud Native Computing Foundation (CNCF) – Scaling, load balancing, safely rolling out updates – Abstracting infrastructure via API: Can use any cloud provider (or none) – Resources: k8s API objects – “Pets vs Cattle” debate
  • 7. K8s basics – 2: Terms ● Cluster – Master node runs API server (our interface to the Cluster) – Worker nodes run Kubelet and Pods – Namespaces: Virtual clusters (resource quotas) ● Kubelet – Talks to Master node, monitors Pods ● Pod – A container or group of containers sharing the same execution environment – Container coupling: sharing a volume or IPC ● Volume – Storage abstraction, many types
  • 8. K8s basics – 3: Moar terms ● Minikube – Single-node k8s cluster in a VM – install VirtualBox and you’re good to go. ● Prometheus – Monitoring solution for k8s (also by CNCF, so described as “best fit”…) ● Custom Resource Definitions – Write them to extend k8s API at will ● Operator pattern – Custom domain-specific controllers that work with CRDs – Configure & manage stateful applications for you – No need for out-of-band automation
  • 9. K8s basics – 4: YAML files ● Definitions – YAML! – kind of resource e.g. Pod – metadata e.g. name, labels – spec i.e. the desired state for the resource ● Kubectl – CLI tool for interacting with Cluster kubectl create -f my-pod.yaml kubectl get pods
  • 10. K8s basics – 5: Services ● Service – Exposes Pods externally via URL – Entry point for a set of Pods performing the same function – Targets Pods using a selector for the labels applied to Pods – Can have Type: ClusterIP, NodePort, LoadBalancer, ExternalName – Needs a way to route traffic from outside the Cluster ● NodePort will assign the same Port from each Node ● LoadBalancer will provision an external LB from cloud provider
  • 11. K8s basics – 6: Deployments ● Deployment – Automates upgrades of applications with zero downtime – Enables fast rollbacks to previous state kubectl rollout undo deployment my-app --to-revision=5 – Defines number of replicated Pods in spec ● Manages ReplicaSets for you – Can have Strategy: RollingUpdate, Recreate
  • 12. K8s basics – 7: State ● Stateless Applications – Usually as a Deployment of Pod Replicas accessed via a Service ● Stateful Applications – StatefulSets ● Stable storage ● Stable network identifiers ● Ordered deployment & scaling ● Ordered RollingUpdates
  • 13. K8s basics – 8: StatefulSets ● spec – Defines replicas in unique Pods (with stable network identity & storage) – Defines storage in PersistentVolumes ● Headless Service – No load balancing, no cluster IP: self-registration or discovery possible – Governs DNS subdomain of Pods: e.g. mypod-1.myservice.mynamespace ● PersistentVolumes: Provisioned storage as a resource ● PersistentVolumeClaim: A request for storage, consumes PV resources ● Deletion – Does not remove PersistentVolumes (for safety) – Does not guarantee Pod termination (scale to zero before)
  • 15. Small scale – 1: The image ● You need a PostgreSQL container image – Roll your own – Use an existing image ● PostgreSQL Docker Community “Official image” – https://github.com/docker-library/postgres docker pull postgres ● Bitnami PostgreSQL Docker image – https://github.com/bitnami/bitnami-docker-postgresql ● Crunchy Data containers – https://github.com/CrunchyData/crunchy-containers
  • 16. Small scale – 2: Deployment ● Create a ConfigMap for the configuration values → ● Create a PersistentVolume and a PersistentVolumeClaim ● Create a Deployment for your Container image & PV ● Create a Service to expose the above. Simple: NodePort ● Connect to your database via exposed port or kubectl port forwarding apiVersion: v1 kind: ConfigMap metadata: name: postgres-config labels: app: postgres data: POSTGRES_DB: mydatabase POSTGRES_USER: myuser POSTGRES_PASSWORD: mypassword
  • 18. Helm Charts – 1: Introduction ● Helm – A “package manager” for k8s. Helm is the client. – Tiller is the server-side component installed in k8s ● Charts – Directories of (you guessed it) YAML files – Describe a set of related k8s resources – values.yaml lets you customise options and configuration ● PostgreSQL use case – One-stop installation for a set of replicated databases – It makes sense!
  • 19. Helm Charts – 2: PostgreSQL Chart ● Contributed by Bitnami, upstreamed: – https://github.com/helm/charts/tree/master/stable/postgresql ● Default Docker image repo is Bitnami ● Installation is as simple as: helm install --name my-release -f values.yaml stable/postgresql – A Release in this context is an installation, a deployment ● Output will include some magic commands for getting the DB password and connecting to the running instance ● postgresql.conf or pg_hba.conf can be provided in files/ folder and will be mounted as a ConfigMap (special Volume type for abstracting configuration)
  • 20. NAME: my-release LAST DEPLOYED: Fri Jan 25 15:20:58 2019 NAMESPACE: my-namespace STATUS: DEPLOYED RESOURCES: ==> v1/Secret NAME TYPE DATA AGE my-release-postgresql Opaque 1 3s ==> v1/ConfigMap NAME DATA AGE my-release-postgresql-init-scripts 1 3s ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-release-postgresql-headless ClusterIP None <none> 5432/TCP 3s my-release-postgresql ClusterIP 10.101.211.6 <none> 5432/TCP 3s ==> v1beta2/StatefulSet NAME DESIRED CURRENT AGE my-release-postgresql 1 1 3s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE my-release-postgresql-0 0/1 Init:0/1 0 3s
  • 21. NOTES: ** Please be patient while the chart is being deployed ** PostgreSQL can be accessed via port 5432 on the following DNS name from within your cluster: my-release-postgresql.my-namespace.svc.cluster.local To get the password for "postgres" run: export POSTGRESQL_PASSWORD=$(kubectl get secret --namespace my-namespace my-release- postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode) To connect to your database run the following command: kubectl run my-release-postgresql-client --rm --tty -i --restart='Never' --namespace my-namespace --image bitnami/postgresql --env="PGPASSWORD=$POSTGRESQL_PASSWORD" --command -- psql --host my-release-postgresql -U postgres To connect to your database from outside the cluster execute the following commands: kubectl port-forward --namespace my-namespace svc/my-release-postgresql 5432:5432 & psql --host 127.0.0.1 -U postgres
  • 22. Helm Charts – 3: Internals ● Defaults create: – A StatefulSet with 1 Replica (1 Pod) running Postgres from the Docker image – A Headless Service and a Service – A PersistentVolumeClaim from the configured storage provisioner ● Can be configured to: – Load custom Postgres initialisation scripts as ConfigMaps from files/ – Start a metrics exporter to Prometheus: ● https://github.com/wrouesnel/postgres_exporter ● Export e.g. pg_stat_activity, pg_stat_replication or custom metrics queries
  • 23. Helm Charts – 4: Patroni Chart ● For HA you can use the Helm Incubator Patroni Chart: – https://github.com/helm/charts/tree/master/incubator/patroni ● This, too, uses StatefulSets ● Default installation deploys a 5 node Spilo cluster – Zalando’s Spilo is Postgres & Patroni bundled image ● Installation helm repo add incubator https://kubernetes-charts- incubator.storage.googleapis.com/ helm dependency update helm install --name my-release incubator/patroni
  • 25. Crunchy Operator – 1 ● Crunchy Data PostgreSQL Operator – https://github.com/CrunchyData/postgres-operator ● Deploy Postgres with streaming replication & scaling ● Add pgpool, pgbouncer, and metrics sidecars ● Administer SQL policies, users, passwords ● Assign labels to resources ● Minor version upgrades ● Perform backups and restores (or schedule them)
  • 26. Crunchy Operator – 2 Quickstart: ● git clone the GitHub repo, git checkout <tag> ● source examples/envs.sh ● make setupnamespace creates a “demo” namespace ● conf/postgres-operator/pgo.yaml holds the configuration ● make installrbac Creates RBAC resources and keys ● make deployoperator
  • 27. Crunchy Operator – 3: pgo ● pgo is the CLI to interact with the operator pgo create cluster my-cluster (--metrics if you want) pgo show cluster my-cluster pgo scale my-cluster --replica-count=2 pgo create pgbouncer my-cluster or pgo create pgpool my-cluster to add ● Backups pgo create cluster my-cluster --pgbackrest pgo backup my-cluster --backup-type=pgbackrest (or pgbasebackup) pgo restore my-cluster ● Manual failovers pgo failover my-cluster –query (to get failover targets) pgo failover my-cluster --target=my-failover-target-1
  • 29. Observations – 1: Deploying by hand ● Good for rapid development ● Offers equivalent isolation as VMs ● Resource saving compared to VMs ● Doesn’t offer many Cloud Native advantages ● Production usage? – Hard to maintain at scale unless you have an army of DBAs
  • 30. Observations – 2: Helm Charts ● Good for one-time deployments ● Very clean and transparent ● Major version upgrades? ● Slave replicas – no failover unless you set it up explicitly ● Flexibility to carry on using your existing solutions ● Can be used by namespace-admin or plain user with permissions
  • 31. Observations – 3: Crunchy Operator ● All-in-one solution, Postgres as an application ● Makes many tasks easy via CLI and automates others ● You need RBAC and cluster-admin permissions for creation of CRDs – Kubernetes does not support namespaced CRDs :( – https://github.com/kubernetes/kubernetes/issues/65551 ● Under heavy development – perhaps not ideal for production? – But so is Kubernetes :/
  • 32. Observations – 4 ● Hard problem – (Plain) Postgres cluster with multiple write nodes – Multi-master is not always the solution – Can leverage aforementioned solutions with 2ndQuadrant’s pglogical for granularity ● https://www.2ndquadrant.com/en/resources/pglogical/ ● Doesn’t even need a custom image, can be added as post-install hook
  • 33. Alternatives? ● DBaaS/PaaS like Heroku ($$$) ● Managed cloudy DBs like EnterpriseDB’s (AWS) Postgres ● Evil ;) – Amazon RDS (/Aurora?) PostgreSQL – Google Cloud SQL PostgreSQL – Azure Database for PostgreSQL ● Define as Services, connect to Endpoints
  • 34. Thank you =) Twitter: @vyruss Photo: Forth Bridge, Firth of Forth, Edinburgh