Slide 1

Slide 1 text

Why you should be running Postgres on Kubernetes Why you should be running Postgres on Kubernetes Alvaro Hernandez @ahachete

Slide 2

Slide 2 text

Why you should be running Postgres on Kubernetes ` whoami ` Alvaro Hernandez aht.es ● Founder & CEO, OnGres ● 20+ years Postgres user and DBA ● Mostly doing R&D to create new, innovative software on Postgres ● More than 100 tech talks, most about Postgres ● Founder and President of the NPO Fundación PostgreSQL ● AWS Data Hero

Slide 3

Slide 3 text

Why you should be running Postgres on Kubernetes Deploying Postgres without Kubernetes

Slide 4

Slide 4 text

Why you should be running Postgres on Kubernetes apt-get install postgresql # well... How to deploy Postgres

Slide 5

Slide 5 text

Why you should be running Postgres on Kubernetes OK, we need to tune the database 2-8h Postgres DBA

Slide 6

Slide 6 text

Why you should be running Postgres on Kubernetes We need to add connection pooling pg_bench, scale 2000, m4.large (2 vCPU, 8GB RAM, 1k IOPS) 4-16h DevOps / pgDBA

Slide 7

Slide 7 text

Why you should be running Postgres on Kubernetes And High Availability! 8-24h DevOps / pgDBA ● HA software (e.g. Patroni) ● Distributed configuration ● Entrypoint: ○ DNS? ○ Virtual IP? ○ External discovery service (e.g. Consul)?

Slide 8

Slide 8 text

Why you should be running Postgres on Kubernetes Do you backup your data? 4-16h DevOps ● Backup software (e.g. WAL-G, pgBackRest) ● Backup Storage ● Backups lifecycle management ● Backup testing / restoration

Slide 9

Slide 9 text

Why you should be running Postgres on Kubernetes You wouldn’t deploy Postgres without monitoring, would you? 8-24h DevOps / pgDBA

Slide 10

Slide 10 text

Why you should be running Postgres on Kubernetes Do you leave Postgres logs on each server? 4-48h DevOps ● Configure CSV logging ● Add a logging agent (e.g. FluentBit) to export logs ● Add a logging collector (e.g. Fluentd) to collect logs, write code to store it and manage lifecycle. ● Or use a paid logs-as-a-Service

Slide 11

Slide 11 text

Why you should be running Postgres on Kubernetes For advanced users: proxy Postgres traffic with Envoy 8-16h DevOps ● Exports additional network metrics to Prometheus ● Offloads Postgres SSL https://www.cncf.io/blog/2020/08/13/envoy-1-15-in troduces-a-new-postgres-extension-with-monitoring- support/

Slide 12

Slide 12 text

Why you should be running Postgres on Kubernetes Install cluster management software ?h DevOps ??????????????

Slide 13

Slide 13 text

Why you should be running Postgres on Kubernetes IaC: Infrastructure as Code 48-96h DevOps

Slide 14

Slide 14 text

Why you should be running Postgres on Kubernetes This is the whole stack you need to deploy Postgres

Slide 15

Slide 15 text

Why you should be running Postgres on Kubernetes Deploying Postgres with Kubernetes

Slide 16

Slide 16 text

Why you should be running Postgres on Kubernetes Deploy a simple cluster with Kubernetes (w/ StackGres) 1h CKA apiVersion: stackgres.io/v1 kind: SGCluster metadata: name: simple spec: instances: 2 postgres: version: 'latest' pods: persistentVolume: size: '100Gi'

Slide 17

Slide 17 text

Why you should be running Postgres on Kubernetes Deploy an advanced cluster with Kubernetes (w/ StackGres) 4-16h CKA ● Create YAMLs for several CRDs ● Create Ingress if needed ● Expose Web Console (Ingress/LB) ● Integrate with GitOps

Slide 18

Slide 18 text

Why you should be running Postgres on Kubernetes Total time to deploy whole Postgres Stack Without Kubernetes Kubernetes Postgres Configuration 2-8h (DBA) Connection pooling 4-16h (DevOps + DBA) High Availability 8-24h (DevOps + DBA) Backups 4-16h (DevOps) Monitoring 8-24h (DevOps + DBA) Distributed Logs 4-48h (DevOps) Envoy proxy 8-16h (DevOps) Cluster Management ???? IaC 48-96h (DevOps) Total: 86-248h (DevOps + DBA) 4-16h CKA

Slide 19

Slide 19 text

Why you should be running Postgres on Kubernetes Day 2 Operations

Slide 20

Slide 20 text

Why you should be running Postgres on Kubernetes ● Kubernetes also allows to automate Day 2 operations ● CKA is enough, mostly no Postgres expertise needed ● E.g. Day 2 operations implemented in StackGres: ○ Repack ○ Vacuum ○ Repack ○ Minor version upgrade ○ Major version upgrade ○ Controlled restart ○ Benchmark Automating Day 2 operations

Slide 21

Slide 21 text

Why you should be running Postgres on Kubernetes When not to deploy Postgres on Kubernetes

Slide 22

Slide 22 text

Why you should be running Postgres on Kubernetes ● You want to consume a fully managed service (e.g. RDS) and pay for it. ● You need specific OS-level software/tuning not available in your K8s (e.g. ZFS). ● If you still believe that the Earth is flat, vaccines are bad, Kubernetes is not a solid platform for running you database; and don’t want to get out of your comfort zone. When NOT TO deploy Postgres on Kubernetes

Slide 23

Slide 23 text

Why you should be running Postgres on Kubernetes Demo!!! Follow the tutorial: https://stackgres.io/doc/latest/tutorial/ Get help, share feedback: https://slack.stackgres.io

Slide 24

Slide 24 text

Why you should be running Postgres on Kubernetes Q & A Alvaro Hernandez @ahachete