惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
I
InfoQ
Jina AI
Jina AI
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
量子位
月光博客
月光博客
罗磊的独立博客
雷峰网
雷峰网
The Cloudflare Blog
V
V2EX
小众软件
小众软件
人人都是产品经理
人人都是产品经理
博客园 - Franky
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
PostgreSQL on Kubernetes — Complete Setup Guide with Clou...
Amaresh Pelleti · 2026-06-16 · via DEV Community

Amaresh Pelleti

Originally published on DevToolHub, where I keep this guide updated as CloudNativePG evolves.

Running PostgreSQL in Kubernetes used to be a bad idea. StatefulSets were tricky, persistent volumes were unreliable, and failover meant data loss. Most teams defaulted to managed cloud databases and called it done.

That calculus has changed. CloudNativePG — the CNCF-listed PostgreSQL operator — handles high availability, automated failover, Point-in-Time Recovery, connection pooling, and streaming replication out of the box. In 2026 it's the production-grade way to run PostgreSQL on Kubernetes, and the gap between "self-hosted on K8s" and "managed cloud database" has narrowed significantly.

This guide walks through a complete CloudNativePG setup — from operator install to production-ready cluster.

What the full guide covers

  • Why CloudNativePG over a plain StatefulSet — what the operator actually does that raw StatefulSets can't
  • Installing the operator — kubectl and the kubectl-cnpg plugin
  • Deploying a 3-instance HA cluster — 1 primary + 2 standbys, with PostgreSQL tuning parameters
  • Connecting your app — read-write vs read-only services, port-forwarding for debugging
  • Backup and WAL archiving to S3 — ScheduledBackup, retention policies, verifying archiving works
  • PgBouncer connection pooling — the Pooler resource, transaction vs session mode
  • RBAC and Network Policies — locking down who can reach the database at the Kubernetes layer
  • Testing failover — how to simulate a primary failure and what to expect
  • Point-in-Time Recovery — restoring to an exact timestamp from WAL archives
  • Common mistakes and best practices — storage sizing, pool mode, pg_hba.conf defaults, synchronous replication

The one thing most guides skip

WAL archiving must be configured before you put data in the database — you can't retroactively enable PITR. Configure backups before your first application write.

So which setup should you use?

CloudNativePG on K8s — right for teams with Kubernetes expertise who want full operational control, PITR, and custom PostgreSQL configuration without paying managed database prices.

Managed PostgreSQL (RDS, Cloud SQL, DigitalOcean Managed Databases) — still wins on operational simplicity. Zero operator to maintain, automatic failover handled for you.

CloudNativePG narrows the gap significantly — but the right call depends on your team's tolerance for database operations.


I keep the full step-by-step guide on DevToolHub, including all YAML manifests and kubectl commands: PostgreSQL on Kubernetes — Complete Setup Guide with CloudNativePG

I write hands-on DevOps and Kubernetes guides at devtoolhub.com. Questions about your setup? Drop a comment.