Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Why you should be deploying Postgres primarily on Kubernetes

Why you should be deploying Postgres primarily on Kubernetes

Running a Postgres installation, with or without containers, is trivial. However, setting up a production environment is a whole different matter.

Postgres is not by itself a production-ready software: it requires a set of side tools to complement its functionality: connection pooling, monitoring, backup tools, high availability software, you name it. This is called the “Stack Problem”.
Join this brief talk to discuss the Stack Problem, understand how Kubernetes is the platform that best solves it, and what are the main advantages (and disadvantages!) of running Postgres on Kubernetes.

OnGres

May 03, 2021
Tweet

More Decks by OnGres

Other Decks in Technology

Transcript

  1. DoKC Day Kubecon EU 2021 OK, we need to tune

    the database https://postgresqlco.nf 2-8h Postgres DBA
  2. DoKC Day Kubecon EU 2021 We need to add connection

    pooling pg_bench, scale 2000, m4.large (2 vCPU, 8GB RAM, 1k IOPS) 4-16h DevOps / pgDBA
  3. DoKC Day Kubecon EU 2021 And High Availability! 8-24h DevOps

    / pgDBA • HA software (e.g. Patroni) • Distributed configuration • Entrypoint: ◦ DNS? ◦ Virtual IP? ◦ External discovery service (e.g. Consul)?
  4. DoKC Day Kubecon EU 2021 Do you backup your data?

    4-16h DevOps • Backup software (e.g. WAL-G, pgBackRest) • Backup Storage • Backups lifecycle management • Backup testing / restoration
  5. DoKC Day Kubecon EU 2021 You wouldn’t deploy Postgres without

    monitoring, would you? 8-24h DevOps / pgDBA
  6. DoKC Day Kubecon EU 2021 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 service
  7. DoKC Day Kubecon EU 2021 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/
  8. DoKC Day Kubecon EU 2021 Deploy a simple cluster with

    Kubernetes (w/ StackGres) 1h CKA apiVersion: stackgres.io/v1 kind: SGCluster metadata: name: simple spec: instances: 2 postgresVersion: 'latest' pods: persistentVolume: size: '100Gi'
  9. DoKC Day Kubecon EU 2021 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
  10. Total time to deploy whole Postgres Stack Non 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
  11. DoKC Day Kubecon EU 2021 • 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
  12. DoKC Day Kubecon EU 2021 • 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