PostgreSQL on Kubernetes with the Zalando Postgres Operator

Running PostgreSQL on Kubernetes with the Zalando Postgres Operator means Patroni-managed clusters, in-place major upgrades and cloning from object storage. This page covers the setup sequence, prerequisites, mapping, security and failure points.

On this page

What the Zalando Postgres Operator does for PostgreSQL on Kubernetes

A platform team that must run PostgreSQL on Kubernetes in infrastructure it controls needs three things to work without heroics: failover when a primary fails, backups it can restore, and upgrades it can schedule. The Zalando Postgres Operator manages Patroni-based PostgreSQL clusters and covers rolling updates, live volume resize, PgBouncer connection pooling, fast in-place major version upgrades, restore and cloning on AWS, GCS and Azure, logical backups to S3 or GCS, and standby clusters fed from a WAL archive or a remote host. Those features are the operator's job, so the platform team's job is to decide how each one is configured and who gets paged when it fails.

The division of labor matters because PostgreSQL does not detect a primary failure or promote a standby by itself. Its documentation states that automatic failover needs external tools. In this design, Patroni handles leader election and promotion inside the cluster, and the operator wires Patroni, the pods, the volumes and the services together from a declarative postgresql custom resource. Replication mode, synchronous settings, backup schedules and pooler settings are fields you set and review in version control. Confirm with the operator's current documentation which parameters are exposed as fields and which must be set through Patroni's own configuration, because that boundary decides where a change is made and how it is audited.

Before you adopt the operator, check three boundaries against your own environment. First, confirm which object store options your cloud and data residency rules allow, since the supported features list names AWS, GCS and Azure but your buckets, credentials and retention settings are yours to define. Second, confirm the Kubernetes version your platform runs is one the operator release supports, because the operator and the cluster upgrade on separate schedules. Third, decide who owns the Kubernetes layer that the operator depends on for storage classes, network policy and secrets, since a failover test that passes on a healthy cluster can still fail if the storage or DNS layer is unstable. Written answers to these questions shape the rest of the build.

What you need before installing the operator

The operator runs inside a Kubernetes cluster, so the cluster version, control plane layout, storage and identity choices come first. Each card below is a decision or check to settle before the first postgresql resource is applied.

Kubernetes version and support window

Choose a Kubernetes minor version that is still inside its support window. As of September 2026, the project maintains 1.37, 1.36 and 1.35, with end-of-life dates of October 28, 2027, June 28, 2027 and February 28, 2027 respectively. Plan your cluster upgrade cadence so you move off a minor version before it reaches end of life, since operator upgrades assume a supported API surface. Confirm the version support dates on kubernetes.io before you commit.

Kubernetes releases

Control plane and etcd layout

Decide between a stacked control plane and an external etcd cluster. The kubeadm high availability guide describes both, with at least three control plane nodes and a TCP load balancer in front of kube-apiserver on port 6443. Kubernetes recommends an odd number of etcd members, with five members for production, and a tested etcd backup plan. The Postgres cluster depends on these, so ask whether your platform team has restored etcd from a snapshot in the last year.

Recommended etcd members
5
kubeadm HA guide

Storage class for database volumes

Each PostgreSQL instance needs a persistent volume. Confirm that a StorageClass exists with the performance, expansion and reclaim behavior you need, and that it supports the live volume resize the operator offers. Check whether the storage backend replicates data on its own, because that interacts with PostgreSQL replication and can double the copies you pay for. Ask the storage team for write latency numbers under load before sizing instances.

Object storage bucket for backups

Logical backups and WAL archiving need a bucket the operator can write to. The Zalando operator supports S3 and GCS for logical backups, and restore, cloning and standby clusters work on AWS, GCS and Azure. Create a dedicated bucket with versioning or retention controls, separate credentials from the database, and a lifecycle policy that matches your recovery targets. Confirm which provider and region your data residency rules permit.

Zalando operator repository

Certificates and operator identity

Decide how people and tools authenticate to the Kubernetes API. Kubernetes uses X.509 client certificates, bearer tokens including OpenID Connect and JWT, webhook token authentication or an authenticating proxy, and does not store normal users as API objects. Map operator administrators to RBAC roles with least privilege. Also plan TLS for PostgreSQL connections, and make sure the Secrets holding database credentials are encrypted at rest, since they are stored unencrypted in etcd by default.

Secrets good practices

PostgreSQL major version choice

Pick the major version before the first cluster, because moving to a newer one later is a planned upgrade. PostgreSQL 18 is the newest, first released September 25, 2025, with support to November 14, 2030. Versions 17, 16, 15 and 14 are supported until November 8, 2029, November 9, 2028, November 11, 2027 and November 12, 2026 respectively. Versions 13 and earlier are unsupported, so do not start new clusters on them. Choose the oldest version still inside your support plan to reduce upgrade work later.

PostgreSQL versioning policy

How to install and configure the operator in sequence

This sequence takes a Kubernetes cluster you control from an empty namespace to a Patroni-managed PostgreSQL cluster with pooling, WAL archiving, logical backups and a tested standby or clone. Each step ends with a check so the next step starts from a known state.

  1. Confirm the platform prerequisites

    Before installing anything, confirm that the Kubernetes cluster meets the operator's requirements, that a storage class supports the volume behavior you need, and that the namespace layout and RBAC are agreed with your platform team. Your Kubernetes team owns the cluster itself, while the database team owns the PostgreSQL namespace. Check the operator's repository for the Kubernetes versions it is tested against, and confirm them against the supported Kubernetes releases in your environment. The step is done when a written checklist is signed off and the storage class is confirmed to provision volumes in your data center or cloud account.

  2. Install the operator from Helm or manifests

    Install the Zalando Postgres Operator into its own namespace using the Helm chart or the manifests in the official repository, pinning the chart or manifest version your team has reviewed. Keep the operator's service account permissions limited to the namespaces it manages. The operator team and the platform team both need access to the install artifacts, so store them in your GitOps repository. The step is done when the operator pod is running and its logs show it has started without errors against your API server.

  3. Configure the operator settings and storage

    Set the operator's configuration, either through its ConfigMap or its operator configuration CRD depending on the version you installed. Define the default storage class, the default volume size for new clusters, and the resource defaults for Postgres pods. Enable live volume resize only after confirming your storage class supports expansion. The step is done when a test manifest in a sandbox namespace receives a persistent volume of the expected class and size, and the operator reports the configuration it loaded.

  4. Define the postgresql custom resource

    Create a postgresql custom resource that names the team that owns the cluster, the number of instances, CPU and memory requests and limits, and the PostgreSQL major version. Keep the manifest in version control so that changes go through review. Start with a small number of instances in a non-production namespace and confirm the sizing with your own load tests. The step is done when the operator creates the StatefulSet and pods, and the cluster reports ready.

  5. Verify roles, Patroni status and a test write

    Check the pod role labels to confirm one pod is the primary and the others are replicas. Query Patroni's status through its REST interface or the cluster view in the operator tooling, and confirm all members are streaming and show a healthy lag. Then write a test row through the primary service, read it from a replica, and record the timestamp. The step is done when the replication state is healthy and the test row is visible on every member.

  6. Configure PgBouncer pooling

    Enable the operator's PgBouncer pooler in the cluster configuration, set pool mode and size to match the connection limits your applications need, and point application connection strings at the pooler service rather than the database service. Confirm that the pooler credentials are sourced from a secret your team controls and that its TLS settings match your policy. Check the PgBouncer version the operator deploys against the PgBouncer releases listed on the project site. The step is done when applications connect through the pooler and a connection count query on the primary shows the pool is limiting server connections.

  7. Configure WAL archiving and logical backup targets

    Set the WAL archive destination for point-in-time recovery and the logical backup target for scheduled dumps, using S3, GCS or Azure storage that your team controls. Grant the database pods write access through workload identity or a scoped credential, and enable encryption and retention rules at the bucket level. Schedule the logical backup job and confirm that the first base backup and WAL segments reach the bucket. The step is done when the bucket shows a base backup, archived WAL files and a logical backup object, and the archive command reports no recent failures.

  8. Create a standby or clone cluster and run a restore drill

    Create a second postgresql resource that either clones from the archived backup or runs as a standby cluster fed from the WAL archive, depending on whether you need a recovery copy or a disaster recovery standby. Run a restore drill to a point in time after the test write, then compare the restored data with the source. Record the restore duration and the data check results in your runbook. The step is done when the cloned or standby cluster reaches the expected recovery point and your team has signed off the drill results.

How rolling updates, in-place major upgrades and cloning fit together

Three operations look similar in the operator manifest but carry very different risk, and the section should be read with that in mind. A minor update replaces PostgreSQL executables and restarts the server, because minor releases never change the on-disk storage format. A major upgrade changes the storage format, so the data has to be converted. The Zalando operator's rolling updates and in-place major upgrades are separate code paths, and cloning is a third path that builds a new cluster from backups. Each one should be tested on its own before it is trusted in production.

For major upgrades, the PostgreSQL documentation describes three options: pg_upgrade, dump and restore with pg_dumpall, and logical replication, which works across major versions and can keep downtime to several seconds. The operator's in-place upgrade uses the pg_upgrade approach, so the reader should check how the operator's major_version setting, its upgrade script and its rollback path behave for the chosen source and target versions. Plan the target version against the support window: PostgreSQL releases a major version about once a year and supports each for five years, so the current cluster's end-of-life date sets the deadline for the upgrade project.

Cloning and standby clusters reuse the same backup archive, which is why they belong in the same plan. The operator can restore or clone from S3, GCS or Azure storage, and a standby cluster can follow a WAL archive or a remote host. Confirm the exact configuration keys and storage options in the Zalando Postgres Operator repository for your operator version. Run a restore drill into a separate namespace, check row counts and a point-in-time target, and time it before you rely on a clone for recovery or a standby for disaster recovery. A standby that has never been promoted or restored is an assumption, not a recovery plan.

How the operator, Patroni, PgBouncer and backups connect

The diagram starts at the Kubernetes API, where a PostgreSQL custom resource is applied, and the operator turns that declaration into a Patroni-managed primary, replicas and a PgBouncer pool in front of them. Applications connect to the pooler, not to the database pods directly. WAL and logical backups leave the cluster for object storage, which sits across a trust boundary from the cluster, and a standby cluster reads from that archive. Check who holds the object storage credentials, where the boundary's network and access controls sit, and whether the standby can reach the archive.

Operator, database pods, pooler and backup flows, with the object store across a trust boundary.

How database roles, secrets and backup targets map to Kubernetes objects

This table maps each PostgreSQL concept to the Kubernetes object or external location that holds it under the Zalando operator, and shows who controls each one. Read it when deciding how teams, namespaces and backup buckets line up before the first cluster is created. The main takeaway is that database roles, Kubernetes users and cluster secrets are three separate identity layers, and the Secret store needs its own protection.

ConceptWhere it livesWho controls itWhat to confirm
Database login rolesPostgres roles inside each cluster, with passwords held in Secrets the operator createsDatabase administrators and the operatorConfirm which role names the operator generates for your manifests and which ones your applications use directly
Application database rolesRoles and grants defined in the cluster manifest or created by your team after bootstrapPlatform team with application ownersConfirm least-privilege grants per schema and that no application uses the superuser role
Connection SecretsKubernetes Secrets in the namespace of the cluster, one per database userOperator writes them; namespace RBAC controls who can read themConfirm which namespaces and service accounts can list or read these Secrets
Team and cluster ownershipCluster name and namespace, often with team labels or annotationsPlatform team sets naming and namespace boundariesConfirm the naming convention and that each team has a namespace with its own RBAC bindings
Kubernetes user identityOutside the cluster: X.509 client certificates, bearer tokens, OIDC or webhook authenticationCluster administrators and your identity providerConfirm that Kubernetes user identities are separate from database roles and that human access is granted through your identity provider
PgBouncer pool usersPooler deployment in the same namespace, with its own auth configuration for application connectionsPlatform team configures pooling; application owners request accessConfirm which database roles each pool user maps to and that pool users do not bypass the grants applied to application roles
Backup bucket pathsObject storage prefix per cluster, set in operator configuration for S3, GCS or AzureStorage administrators and platform teamConfirm that each cluster writes to its own prefix and that bucket access is limited to the operator's service identity
Secret protection at restSecrets are stored unencrypted in etcd by defaultCluster administratorsConfirm that encryption at rest is enabled for Secrets in etcd, and that RBAC restricts list and watch access to Secrets

Hardening the cluster, secrets and backup access

A Zalando-operated PostgreSQL cluster inherits the security posture of the Kubernetes cluster, its Secrets, and the bucket credentials used for backups. The cards below cover the controls to decide and verify before the database holds production data, and the CIS Kubernetes Benchmark is a useful checklist to work through alongside them.

Encrypt Secrets at rest

The operator stores generated database credentials and bucket keys as Kubernetes Secrets. By default Secrets sit unencrypted in etcd, so anyone who can read an etcd snapshot can read those passwords. Confirm that the cluster has encryption at rest configured for Secrets, that etcd snapshots are protected as carefully as the Secrets themselves, and that the team knows which credentials the operator creates for each cluster.

Secrets good practices

Restrict list and watch access

Anyone with list or watch permission on Secrets in a namespace can read every credential stored there, even without get permission on each one. Grant the operator and the database pods only the RBAC rights they need, keep application teams out of the database namespace, and review role bindings after each operator upgrade, since new versions can add resources to their cluster roles.

Apply Pod Security Standards

Database pods run as a privileged workload with access to persistent volumes and a writable data directory. Apply the restricted Pod Security Standard to the namespace where possible, and check whether the operator's pods, Patroni sidecars and PgBouncer pods need exceptions. Each exception should be written down with its reason and reviewed at upgrade time.

Pod Security Standards

Encrypt client connections with TLS

Connections from applications, PgBouncer and the operator to PostgreSQL carry passwords and query results. Plan TLS for client connections, decide how certificates are issued and rotated, and confirm that PgBouncer and the Patroni replication path use the same policy. Ask the operator project which certificate options the chosen release supports, because the setup differs between releases.

Choose PostgreSQL authentication methods

Set password_encryption to SCRAM rather than MD5, and make sure pg_hba rules and PgBouncer agree on the method. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM. Where the organization already runs a central identity or certificate authority, evaluate certificate or OAuth 2.0 authentication for human and service access, and confirm how the operator's own connections authenticate.

Authentication methods

Scope bucket credentials to one prefix

Backups, WAL archives and standby clusters read from or write to object storage, using credentials the operator must hold. Create a dedicated bucket identity per cluster or environment, limit it to one prefix, and deny deletion where retention allows. Confirm which credentials the operator reads and how they rotate, because a cloning or standby cluster in another account needs its own read permission.

Common failures when running the Zalando operator and what causes them

This table lists the failures teams most often hit when running Patroni-based PostgreSQL clusters with the Zalando operator, with the likely cause, the fix and what to confirm in logs and operator status. Read each row as a starting checklist, since the exact cause depends on your storage, node pools and bucket configuration.

FailureLikely causeFix and what to confirm
Cluster stays pending after applyNo storage class matches the volume claim, or the requested size or access mode cannot be provisionedConfirm the storage class name and default class in the cluster manifest, then check the pending pod and claim events. Fix the class or request a size and mode the class supports.
Failover or replica lag after a node drainDrain removed the primary or a replica before a replacement was ready, or the replicas lag under write loadCheck Patroni leader state and replication lag in the pod logs and cluster status. Set pod disruption budgets and drain one node at a time, then confirm replicas catch up before the next drain.
PgBouncer pool exhaustionPool size is too small for application concurrency, or clients hold connections open inside long transactionsLook for client wait errors and the PgBouncer admin console stats for waiting clients. Adjust pool size and pool mode for the workload, and fix application transactions that stay idle.
WAL archive stopsBucket credentials in the secret expired or were rotated, so archive uploads failCheck the archive command errors in the Postgres pod logs and the failed archive count in cluster monitoring. Update the secret used for S3, GCS or Azure access and confirm new WAL segments reach the bucket.
Clone fails at bootstrapThe source archive path, bucket prefix or cluster name in the clone section does not match the source backup layoutCompare the clone settings with the path written by the source cluster and read the restore job logs. Correct the path and confirm a base backup is listed before retrying.
Major upgrade blockedKubernetes version skew: the apiserver must be at or ahead of the components the operator runs against, and the cluster version is outside the supported rangeCheck the cluster and node versions against the Kubernetes version skew policy and the operator release notes. Upgrade the control plane first, then nodes, then retry the PostgreSQL upgrade.
Operator status shows errors without a clear causePermissions missing for the operator service account, or a stale configuration after an editRead the operator logs and the status fields on the postgresql resource. Confirm RBAC grants and reapply the manifest after correcting the configuration.

Questions buyers ask before running the Zalando operator

What drives the cost of building this in-house versus with a partner?

The main cost is the time of engineers who already know Kubernetes, PostgreSQL and object storage, and how much of that time the build consumes. An in-house build pays for that expertise during design, first deployment, failure testing and the first restore drill. A partner engagement is priced from a written scope, so the variables are the number of clusters, the cloud or data center targets, the backup and restore tests required, the identity integration, and whether pooling, logical backups and the operator UI are included. Ask any quote to separate one-time build work from recurring upgrade and support work, and to state what is excluded, such as your own Kubernetes platform or database schema changes.

How long does a first cluster and a tested restore usually take?

Duration depends on scope more than on the operator itself. A single cluster with defaults is a different job from several clusters with standby replicas from object storage, PgBouncer pooling, SSO and monitoring. A restore is only proven once a clone or point-in-time recovery has been run into a separate environment and the data checked against an agreed test, so that step should appear as a named deliverable in any plan. No duration is given here because none was supplied for this operator. Ask for a timeline tied to the scope list, the environments you need, and the dates your Kubernetes platform is ready.

What must our internal team provide before the build starts?

The build needs four things from your side. First, Kubernetes access: a cluster with a supported version, namespaces, RBAC rights for the operator, and network policy that lets the database pods talk to each other and to clients. Second, storage: a storage class with volume expansion for live volume resize, sized for data and WAL. Third, an object store in S3, GCS or Azure for backups, WAL archiving and standby clusters, with credentials managed through your secrets process. Fourth, identity: the accounts and groups that will reach the operator UI and database roles, plus the certificate or password policy you require. Confirm each item with your platform team before the first sprint.

Can a small team run this operator without outside help?

A small team can run it if it already operates Kubernetes in production and has someone who understands PostgreSQL replication, WAL archiving and restores. The hard part is not the first install. It is the failure drill, the restore test, the minor updates and the major upgrade plan, each of which needs time that is scheduled every quarter, not only during an incident. If the team lacks PostgreSQL depth, a partner can cover the build and hand over runbooks, or stay on a retainer for upgrades and testing. Decide who owns pages at 2 a.m. before choosing the model.

How does the Zalando operator compare with other PostgreSQL operators?

At a high level, the Zalando operator is built around Patroni for high availability and offers PgBouncer pooling, rolling and in-place major upgrades, cloning and standby clusters from S3, GCS or Azure, logical backups, and an operator UI. Other operators make different choices on backup tooling, encryption, monitoring and GitOps fit. Compare them on the requirements your organization already has: the backup tool your recovery targets need, whether you need built-in encryption, how the operator fits your delivery pipeline, and which upgrade paths your team has tested. Check each project's current release and support status directly, because those details change.

What ongoing upgrade and support work recurs after go-live?

Recurring work falls into three groups. PostgreSQL minor releases come at least once every three months, and each one means replacing executables and restarting, so the operator's rolling update path needs a tested window. Major versions are supported for 5 years, and the supported list today runs from 14 to 18, so a major upgrade will come up on a schedule you must plan for. Kubernetes releases about three times a year and supports only the three most recent minor versions, so the operator, PostgreSQL images and cluster version must be checked against each platform upgrade. Add scheduled restore tests, certificate rotation and backup monitoring, and ask any retainer quote to list these explicitly.

Does the operator meet our audit and access control requirements by default?

The operator does not decide compliance on its own. It deploys PostgreSQL and its supporting pieces, and the evidence auditors ask for comes from how you configure authentication, TLS, Kubernetes secrets, RBAC and logging. PostgreSQL supports several authentication methods, and MD5 password authentication is deprecated in favor of SCRAM in PostgreSQL 18. Kubernetes stores Secrets unencrypted in etcd by default, so encryption at rest and least-privilege access to Secrets are required design items. DeployOpen prepares systems, controls and evidence for assessments, but it does not issue audit reports or certifications. Confirm the control scope with your assessor before the design is fixed.

How DeployOpen works on this

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure. For PostgreSQL on Kubernetes with the Zalando Postgres Operator, the work follows a written scope that covers the cluster, its backups, its upgrades and the people who will run it.

How we scope

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • The scope names the Kubernetes distribution, storage classes, cloud or data center target and the object storage used for backups and standby clusters.
  • Scope also records which PostgreSQL major version you run, the upgrade path you need and whether PgBouncer and the operator UI are in or out.

How we build

  • We deploy the operator and Patroni-based clusters into your Kubernetes environment with the settings agreed in the scope.
  • Backup and recovery are tested by restoring to a separate cluster, including a point-in-time recovery drill, before go-live.
  • Access controls, TLS, secret handling and pooling configuration are reviewed and documented as part of the build.

How we hand over

  • You receive runbooks for failover, rolling updates, in-place major upgrades, cloning and restore from S3, GCS or Azure.
  • Architecture notes record the trade-offs made, such as synchronous or asynchronous standbys and pooling mode choices.
  • Your team is walked through the restore test and the operational checks it should repeat on its own schedule.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Retainers can cover operator version updates, Kubernetes version skew planning and PostgreSQL minor release patching.
  • Ask for the support scope, response arrangements and upgrade responsibilities in writing alongside the quote.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.