cnpg
Create and operate CloudNativePG (CNPG) Postgres databases on Kubernetes the GitOps/Flux way - on managed cloud (GKE + GCS via Workload Identity) OR…
Skill by vanducng
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/vanducng-cnpg
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, devops, cloud, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/cnpg
What's inside
- Skill name
cnpg- Description
- Create and operate CloudNativePG (CNPG) Postgres databases on Kubernetes the GitOps/Flux way - on managed cloud (GKE + GCS via Workload Identity) OR self-hosted (K3s/bare-metal + any S3-compatible store via a credentials secret). Covers Cluster + ScheduledBackup manifests, barman WAL archiving, pgvector, PITR, prod→dev clones, and the NetworkPolicies a default-deny cluster needs. Use when provisioning a new app database, cloning prod into dev, enabling pgvector, wiring backups/PITR, writing CNPG NetworkPolicies, or debugging the silent "WAL archiving failed → PVC fills → Postgres CrashLoop → app can't read data" chain on CloudNativePG.
- License
- MIT
- Metadata
- author: vanducng · version: 0.1.0
- Instructions
- 388 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- self-hosted-and-networkpolicy.md · references/
SKILL.md (first lines)
# cnpg
Provision and run CloudNativePG (CNPG) Postgres on Kubernetes as GitOps. Every
concrete identifier below is a placeholder - substitute your own:
`<project>`, `<gcp-sa>`, `<backups-bucket>`, `<cluster>`, `<ns>`, `<svc>`,
`<db>`, `<owner>`, `<env>`, `<s3-endpoint>`, `<objstore-secret>`, `<app-ns>`.
**Two platforms, one operator.** The Cluster spec, bootstrap, pgvector, PITR,
clone, and most gotchas are identical everywhere; only **backup auth** and
**NetworkPolicy** differ. Managed cloud (GKE + GCS): Workload Identity, no keys -
steps below default to this. Self-hosted (K3s / bare-metal + S3-compatible store:
MinIO, Ceph, R2, B2): an access-key Secret, plus explicit NetworkPolicies on a
default-deny cluster. Read **`references/self-hosted-and-networkpolicy.md`**
whenever there's no cloud Workload Identity or the cluster enforces default-deny.
## Mental model - two halves that MUST share one string
A CNPG database is two halves agreeing on exactly one string, `<ns>/<cluster>`:
the **GitOps half** - a CNPG `Cluster` whose `serviceAccountTemplate` annotation
points the auto-created **pod KSA** (named after the **cluster**) at the GCP
backup SA - and the **GCP half** - an IAM `workloadIdentityUser` binding whose
member is `serviceAccount:<project>.svc.id.goog[<ns>/<cluster>]` plus the GCS
backups bucket. Any standalone `ServiceAccount` named `cnpg-backup-sa` is a
**decoy/legacy** resource; CNPG does not use it for backup auth.
Deploy is pure GitOps: commit YAML → a Flux `Kustomization` (`dependsOn:
database-operators`) reconciles → the CNPG operator builds the cluster.
**Terraform (WI binding + bucket) must already be applied**, or the cluster
bootstraps but backups fail silently.
## Step 0 - prerequisites
- CNPG operator reconciled (a `database-operators` Flux Kustomization).
- GKE Workload Identity enabled; a shared per-env backup SA
`<gcp-sa>@<project>.iam.gserviceaccount.com` exists.
- SOPS age key available to Flux (`decryption.secretRef`).
- (pgvector) the operand image ships the `vector` lib - it is **available, not
installed**; the non-superuser app role cannot install it (see gotchas).
- (affinity) a dedicated DB node pool with the expected taint + label, else drop
the `affinity` block.
- (cloud) ship Terraform via PR off `origin/main`. Terragrunt auth = personal ADC
or `GOOGLE_OAUTH_ACCESS_TOKEN` (no SA key needed; SA keys often can't read tfstate).
- (self-hosted) an S3-compatible object store reachable from the cluster + an
encrypted credentials Secret; a `storageClass` that exists (e.g. `local-path`,
`longhorn`); and if the cluster is default-deny, the NetworkPolicies from the
reference. Know your CNI (Cilium → `CiliumNetworkPolicy`; Calico → vanilla).
## Step 1 - backup auth
**Self-hosted (S3-compatible):** skip the Terraform/Workload-Identity below -
create an encrypted access-key Secret and use `s3Credentials` + `endpointURL` in
the barman config. Full manifests in `references/self-hosted-and-networkpolicy.md`.
**Managed cloud (GKE + GCS), Terraform BEFORE Flux:**
Append the new cluster's pod KSA to the shared backup SA
(`terraform/gcp/<env>/service-accounts/service-accounts.yaml`):
```yaml
service_accounts:
<gcp-sa>:
display_name: "<Env> CloudNativePG Backup Service Account"
project_roles:
- "roles/storage.admin" # objectAdmin LACKS storage.buckets.get → barman fails; use admin or a bucket-level binding
workload_identity_bindings:
- "cnpg-system/cnpg-backup"
- "<ns>/<cluster>" # ← ADD THIS. Member = <namespace>/<cluster>, NOT cnpg-backup-sa
```
Renders to member `serviceAccount:<project>.svc.id.goog[<ns>/<cluster>]`, role
`roles/iam.workloadIdentityUser`.
Backups bucket (`terraform/gcp/<env>/gcs/buckets.yaml`):
```yaml
backups:
name: <backups-bucket>
location: US
lifecycle_rules:
- action: { type: Delete }
condition: { age: 30 } # BACKSTOP only - MUST exceed barman retentionPolicy or PITR breaks
versioning: false # prod: true
uniform_bucket_level_access: true
force_destroy: true # dev only; prod: false
iam_bindings:
- { service_account: <gcp-sa>, role: roles/storage.admin }
```
One shared backups bucket per env; each cluster isolates under its own
`cnpg/<svc>` prefix. Apply the SA dir, then the GCS dir.
## Step 2 - the app DB folder `fluxcd/databases/<env>/<svc>/`
`kustomization.yaml` in dependency order (namespace + secret first, then
cluster, then extensions + backup):
```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml # <ns>; labels app.kubernetes.io/part-of: databases
- secrets.enc.yaml # SOPS-encrypted app credentials (username/password) - referenced by initdb.secret.name
- database.yaml # the Cluster CR
- database-vector.yaml # pgvector Database CR (only if needed)
- scheduled-backup.yaml # ScheduledBackup CR
```
## Step 3 - the Cluster + ScheduledBackup
`database.yaml`:
```yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: <cluster>
namespace: <ns>
labels:
app.kubernetes.io/name: <cluster>
app.kubernetes.io/component: databaseFrom vanducng/skills, MIT.
More from vanducng/skills
- 0.631score
code-review
vanducng
Review code with a sharp, encouraging voice - inline GitHub PR comments + a tight summary.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
astro-airflow
vanducng
Inspect and debug Airflow on Astronomer (Astro) deployments - DAG runs, task logs, container logs, env vars, and deployment state.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
auto-loop
vanducng
Drive a Claude Code session toward a verifiable goal until done or a hard cap fires - autonomous loop, no user intervention.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
codex-workflow
vanducng
Run deterministic multi-step agent workflows in Codex - fan-out, parallel, schema-validated structured output - via the codex-workflow MCP orchestrator…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
aws
vanducng
Operate AWS accounts and services with the AWS CLI using identity-first, read-before-write, evidence-backed workflows.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
better-ui
vanducng
Applies exact UI polish values: concentric border radius, optical alignment, layered surface shadows, neutral image outlines, a 0.96 press scale, icon…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
brainstorm
vanducng
Explore the solution space when the path isn't obvious - invent options, stress-test them, pick one.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
apidesign
vanducng
Design stable, hard-to-misuse interfaces - REST/GraphQL endpoints, module boundaries, type contracts, component props, anything where one piece of code talks…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
browser-profile
vanducng
Manage named persistent browser profiles (cookies, localStorage, IndexedDB, cache) that both you and Claude can use against the SAME Chrome window without…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
agent-readiness
vanducng
Scores how ready a repository is for AI coding agents to work in it effectively, then remediates the gaps - grades agent instruction files, verifiable…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
browser-trace
vanducng
Capture a full DevTools-protocol trace of a locally driven browser automation - CDP firehose, screenshots, and DOM dumps - then bisect the stream into…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
cli-ts
vanducng
Build and maintain production TypeScript CLIs as stable public APIs - command contracts, packed-artifact correctness, npm publishing, CI/CD, docs, providers…
SkillAFreshness: A★ 8Claude Code +9
Signals
- Stars
- 8
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 11, 2026 (1 month ago)
- Last release
- Oct 23, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 0.1.0
- License
- MIT
- Repository
- github.com/vanducng/skills
- Website
- skills.vanducng.dev
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from vanducng
- 0.631score
apidesign
vanducng
Design stable, hard-to-misuse interfaces - REST/GraphQL endpoints, module boundaries, type contracts, component props, anything where one piece of code talks…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
astro-airflow
vanducng
Inspect and debug Airflow on Astronomer (Astro) deployments - DAG runs, task logs, container logs, env vars, and deployment state.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
auto-loop
vanducng
Drive a Claude Code session toward a verifiable goal until done or a hard cap fires - autonomous loop, no user intervention.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
aws
vanducng
Operate AWS accounts and services with the AWS CLI using identity-first, read-before-write, evidence-backed workflows.
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
better-ui
vanducng
Applies exact UI polish values: concentric border radius, optical alignment, layered surface shadows, neutral image outlines, a 0.96 press scale, icon…
SkillAFreshness: A★ 8Claude Code +9 - 0.631score
agent-readiness
vanducng
Scores how ready a repository is for AI coding agents to work in it effectively, then remediates the gaps - grades agent instruction files, verifiable…
SkillAFreshness: A★ 8Claude Code +9
Cite this page
cnpg skill. Agent Mart. https://agentmart.dev/skills/vanducng-cnpg (last updated 2026-10-24)