Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 15, 2026·3 min de lectura

CloudNativePG — Production-Grade PostgreSQL Operator for Kubernetes

CloudNativePG is a Level V Kubernetes operator that manages PostgreSQL clusters with streaming replication, online backups, point-in-time recovery and rolling upgrades — without any external pgBouncer-like layer.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
CloudNativePG
Comando de instalación directa
npx -y tokrepo@latest install e1ff9c2c-38e6-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

TL;DR
CloudNativePG is a Kubernetes operator managing PostgreSQL clusters with replication, backups, PITR, and rolling upgrades.
§01

What it is

CloudNativePG is a Kubernetes operator for managing PostgreSQL database clusters. It handles the full lifecycle: provisioning, streaming replication, automated failover, online backups, point-in-time recovery (PITR), and rolling upgrades. It is a Level V operator, meaning it manages the entire database lifecycle natively in Kubernetes.

CloudNativePG targets platform teams running PostgreSQL on Kubernetes who want automated database operations without external tools like pgBouncer or Patroni.

§02

How it saves time or tokens

CloudNativePG eliminates manual PostgreSQL administration on Kubernetes. Without an operator, you manage StatefulSets, configure replication manually, write backup scripts, and handle failover with custom logic. CloudNativePG encodes PostgreSQL operational expertise into a Kubernetes-native workflow.

Declarative configuration means your database topology is version-controlled YAML, reviewed in pull requests, and applied with kubectl.

§03

How to use

  1. Install the CloudNativePG operator:
kubectl apply --server-side -f \
  https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.24/releases/cnpg-1.24.0.yaml
  1. Create a PostgreSQL cluster:
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: my-postgres
spec:
  instances: 3
  storage:
    size: 10Gi
  postgresql:
    parameters:
      max_connections: '200'
      shared_buffers: '256MB'
  1. Apply and verify:
kubectl apply -f cluster.yaml
kubectl get cluster my-postgres
§04

Example

Configuring automated backups to S3:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: production-db
spec:
  instances: 3
  storage:
    size: 50Gi
  backup:
    barmanObjectStore:
      destinationPath: 's3://my-backups/postgres/'
      s3Credentials:
        accessKeyId:
          name: aws-creds
          key: ACCESS_KEY_ID
        secretAccessKey:
          name: aws-creds
          key: SECRET_ACCESS_KEY
    retentionPolicy: '30d'
  bootstrap:
    recovery:
      source: production-db
§05

Related on TokRepo

§06

Common pitfalls

  • Under-sizing storage. PostgreSQL WAL files and backups consume significant disk. Size storage at 3-5x your expected data size to accommodate WAL retention and temporary files.
  • Ignoring connection pooling. CloudNativePG includes a built-in PgBouncer pooler. Enable it for applications with many short-lived connections to avoid exhausting PostgreSQL connections.
  • Not testing recovery procedures. Backups are useless if you cannot restore from them. Regularly test point-in-time recovery in a staging environment.

Preguntas frecuentes

Does CloudNativePG handle automatic failover?+

Yes. When the primary PostgreSQL instance fails, CloudNativePG automatically promotes a replica to primary and reconfigures the remaining replicas. This happens without manual intervention and typically completes in seconds.

What backup methods does CloudNativePG support?+

CloudNativePG supports continuous archiving of WAL files to object storage (S3, GCS, Azure Blob) using Barman. It supports full backups, incremental backups, and point-in-time recovery to any moment within the retention window.

Can CloudNativePG manage PostgreSQL upgrades?+

Yes. CloudNativePG supports rolling upgrades for minor versions. For major version upgrades, it supports in-place upgrades with pg_upgrade or migration to a new cluster with logical replication.

How many PostgreSQL instances can a cluster have?+

A CloudNativePG cluster has one primary and zero or more replicas. Three instances (one primary, two replicas) is the recommended minimum for production. The operator manages replication topology automatically.

Is CloudNativePG free?+

Yes. CloudNativePG is open source under Apache-2.0. It is a CNCF Sandbox project with active community and corporate contributors. There is no paid version.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados