Contribute
Basic info on how a CNPG plugin works
Here are some basic informations about how this plugin should work:
-
When installing the plugin, a new deployment is created to run a Pod for the controller (
pgbackrest-controller) of our plugin in the same namespace as the CNPG operator. -
The CNPG operator detects the plugin when a dedicated Kubernetes Service (with some specific annotations) is created.
-
Our specialized controller exposes the supported capabilities (at least those required to manage the lifecycle of our CNPG instances) to the CNPG operator.
-
When initializing a new Cluster configured with our plugin, the pgBackRest controller will be called by the CloudNativePG operator.
-
The plugin controller modifies the resources (Deployment / Pods / Jobs) requested by the CNPG operator (this is done before requesting the Kubernetes API), and inject some configuration if needed.
For our pgbackrest plugin, the controller inject a sidecar container for
pgBackRestwithin the PostgreSQL Pods. This sidecar container executes a manager dedicated topgBackRest(which expose the required capabilities archive the WAL and backup the PostgreSQL instance). -
Our newly created PostgreSQL instance will call the dedicated
pgBackRestmanager (on the side container) when the archive command is triggered.
Prerequisites
The following tools must be installed before contributing:
Deploy CloudNativePG on kind
To contribute and test the pgBackRest plugin, a dedicated Kubernetes
cluster with the CloudNativePG operator is required. Contributors can
use the dev version of the CloudNativePG operator and follow those
steps to prepare the required environment.
-
Clone the main CloudNativePG operator repository:
git clone https://github.com/cloudnative-pg/cloudnative-pg -
Move to the newly created directory:
cd cloudnative-pg -
Install the required dependencies listed above (at least you will need kind).
-
Run a Kubernetes cluster with the development version of CloudNativePG:
./hack/setup-cluster.sh create load deploy
Contributors and users can also refer to the CloudNativePG documentation for more details on how it works and how to run the operator on kind.
Deploy pgBackRest plugin
The pgBackRest plugin can now be deployed on the newly created Kubernetes cluster.
-
Clone the pgBackRest plugin repository:
git clone https://github.com/dalibo/cnpg-plugin-pgbackrest -
Move to the newly created directory:
cd cnpg-plugin-pgbackrest -
Build the container images used for the plugin (one for the controller and another one for the sidecar container):
make build-images -
The images must now be loaded into the registry dedicated the development environment. This is feasible with the
kind loadcommand:kind load docker-image pgbackrest-{controller,sidecar}:latest --name <KUBERNETES-CLUSTER-NAME>It's possible to retrieve the name of the Kubernetes cluster by running:
kind get clusters -
The plugin controller can now be deployed within the
cnpg-systemnamespace. For that the manifests on thekubernetesshould be applied:kubectl apply -k ./kubernetes/dev -
A
pgbackrest-controllerdeployment must be present (e.g., incnpg-systemnamespace). The plugin controller should run on a dedicatedPodalongside the CloudNativePG operatorPod. -
Your are ready to contribute !
Executing E2E tests
E2E Tests can be run automatically. To do that, the easiest approach is to use kind and the appropriate make target:
make test-e2e
That command will:
- Create a dedicated Kubernetes cluster (managed by kind and named
e2e-cnpg-pgbackrest) - Build the container images for the pgbackrest plugin
- Load them on the Kubernetes Cluster 4 Run the tests defined on
test/e2e/e2e_test.go, which also install the dependencies and our plugin.
To only run the tests (test/e2e/e2e_test.go), the test-e2e-run-tests
target can be used:
make test-e2e-run-tests
Once done with the tests, the kind cluster can be deleted :
make cleanup-test-e2e
Linting and compliance
Before submitting a contribution, make sure the linter run without errors:
golangci-lint run
This project follows the REUSE specification for copyright and license tracking.
The reuse tool can be used to add it automatically ;
reuse annotate -copyright="Dalibo" --year=2026 --license="Apache-2.0" <PATH>