cnpg-database

Provision CNPG PostgreSQL clusters and replicate app credentials in Kubernetes.

1|Updated Apr 6, 2025
One-click install
npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill cnpg-database-david-driscoll
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cnpg-database
Source: https://github.com/david-driscoll/stargate-command-cluster/tree/main/.agents/skills/cnpg-database
Command: npx skills add https://github.com/david-driscoll/stargate-command-cluster --skill cnpg-database-david-driscoll

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Provisioning PostgreSQL for Kubernetes apps becomes slow and error-prone when you must coordinate CNPG cluster configuration, per-role credentials, cross-namespace secret replication, and safe connectivity checks.

Core Features & Use Cases

  • Choose the right CNPG topology: shared platform cluster for standard workloads and dedicated CNPG clusters when you need custom extensions or isolation.
  • Provision databases and roles: define managed roles, create Database CRDs, and generate or replicate the correct credential secrets.
  • Enable app access reliably: ensure network policy access labels and register credential replicas in each app’s namespace kustomization.
  • Debug connectivity and health: run the structured scripts/check-connection.sh workflow to quickly identify CNPG health, pooler status, secret replication, and network-policy issues.

Quick Start

Use the cnpg-database skill to add a new database for an application by updating kubernetes/platform/config/database/ (role, secret, Database CRD), then creating the app-namespace credential replica and registering it for kustomization.

Frequently Asked Questions about cnpg-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I provision a CloudNative-PG PostgreSQL database in a Kubernetes homelab?

To provision a CloudNative-PG database, you update the platform configuration directory with the required role, secret, and Database CRD manifests, then create the credential replica in the application namespace. This ensures the CNPG cluster provisions the database and replicates app credentials correctly.

Why does my application fail to connect to the CNPG PgBouncer pooler?

Application connectivity to the CNPG PgBouncer pooler fails when network policy access labels are missing, credential secret replication is misconfigured, or the pooler itself is unhealthy. Running a structured connection check script helps identify the specific issue blocking app access.

When should I use a dedicated CNPG cluster instead of a shared platform database?

You should use a dedicated CNPG cluster instead of a shared platform database when your workload requires custom PostgreSQL extensions or strict isolation. The shared platform cluster handles standard workloads, while dedicated clusters allow you to specify custom extension images.

How do I replicate CNPG credentials across namespaces in Kubernetes?

To replicate CNPG credentials across namespaces, you must ensure the correct secret-generator or CNPG auto-generated secret replication annotations are applied. You then register the credential replica in the application namespace kustomization to make the secrets available.

Does CNPG database provisioning work with Talos and Flux Kubernetes setups?

Yes, CNPG database provisioning is designed for Talos and Flux homelab Kubernetes setups. It coordinates CNPG cluster configuration, per-role credentials, and cross-namespace secret replication within this specific GitOps and OS environment.

What is the best way to debug CNPG PostgreSQL connectivity issues?

The best way to debug CNPG PostgreSQL connectivity issues is to run a structured connection check script. This workflow quickly identifies CNPG health, PgBouncer pooler status, secret replication errors, and network-policy issues blocking the application.