|
| 1 | +--- |
| 2 | +sidebar_position: 6 |
| 3 | +--- |
| 4 | + |
| 5 | +# Contribute |
| 6 | + |
| 7 | +## Deploy CloudNativePG on kind |
| 8 | + |
| 9 | +To contribute and test the pgBackRest plugin, a dedicated Kubernetes |
| 10 | +cluster with the CloudNativePG operator is required. Contributors can use the `dev` |
| 11 | +version of the CloudNativePG operator and follow those steps to prepare the |
| 12 | +required environment. |
| 13 | + |
| 14 | +1. Clone the main CloudNativePG operator repository : |
| 15 | +```console |
| 16 | +git clone https://github.com/cloudnative-pg/cloudnative-pg |
| 17 | +``` |
| 18 | + |
| 19 | +2. Move to the newly created directory : |
| 20 | + |
| 21 | +```console |
| 22 | +cd cloudenative-pg |
| 23 | +``` |
| 24 | + |
| 25 | +3. Install the required dependencies (please follow the instruction |
| 26 | + within the README.md file, at least you will need |
| 27 | + [**kind**](https://kind.sigs.k8s.io/)). |
| 28 | + |
| 29 | +4. Run a Kubernetes cluster with the development version of CloudNativePG : |
| 30 | + |
| 31 | +```console |
| 32 | +./hack/setup-cluster.sh create load deploy |
| 33 | +``` |
| 34 | + |
| 35 | +:::info |
| 36 | +Contributors and users can also refer to the CloudNativePG documentation for more |
| 37 | +details on how it works and how to run the operator on |
| 38 | +[**kind**](https://kind.sigs.k8s.io/). |
| 39 | +::: |
| 40 | + |
| 41 | +## Deploy pgBackRest plugin |
| 42 | + |
| 43 | +The pgBackRest plugin can now be deployed on the newly created Kubernetes cluster. |
| 44 | + |
| 45 | +1. Clone the pgBackRest plugin repository : |
| 46 | + |
| 47 | +```console |
| 48 | +git clone https://github.com/dalibo/cnpg-plugin-pgbackrest |
| 49 | +``` |
| 50 | +2. Move to the newly created directory : |
| 51 | + |
| 52 | +```console |
| 53 | +cd cd cnpg-plugin-pgbackrest |
| 54 | +``` |
| 55 | + |
| 56 | +3. Build the container images used for the plugin (one for the controller and |
| 57 | + another one for the sidecar container) : |
| 58 | + |
| 59 | +```console |
| 60 | +make build-images |
| 61 | +``` |
| 62 | + |
| 63 | +4. The images must now be loaded into the registry dedicated the |
| 64 | + development environment. This is feasible with the `kind load` command : |
| 65 | + |
| 66 | +```console |
| 67 | +kind load docker-image pgbackrest-{controller,sidecar}:latest --name <KUBERNETES-CLUSTER-NAME> |
| 68 | +``` |
| 69 | + |
| 70 | +It's possible to retrieve the name of the Kubernetes cluster by running : |
| 71 | +```console |
| 72 | +kind get clusters |
| 73 | +``` |
| 74 | + |
| 75 | +5. The plugin controller can now be deployed within the `cnpg-system` |
| 76 | + namespace. For that the manifests on the `kubernetes` should be |
| 77 | + applied: |
| 78 | + |
| 79 | + ```console |
| 80 | + kubectl apply -k ./kubernetes/dev |
| 81 | + ``` |
| 82 | + |
| 83 | +6. A `pgbackrest-controller` deployment must be present (e.g., in `cnpg-system` namespace). The plugin |
| 84 | + controller should run on a dedicated `Pod` alongside the CloudNativePG operator `Pod`. |
| 85 | + |
| 86 | +7. Your are ready to contribute ! |
| 87 | + |
| 88 | +## Executing E2E tests |
| 89 | + |
| 90 | +E2E Tests can be run automatically. To do that, the easiest approach is to |
| 91 | +use [**kind**](https://kind.sigs.k8s.io/) and the appropriate make |
| 92 | +target : |
| 93 | + |
| 94 | +```console |
| 95 | +make test-e2e |
| 96 | +``` |
| 97 | + |
| 98 | +That command will: |
| 99 | + |
| 100 | +1. Create a dedicated Kubernetes cluster (managed by **kind** and named |
| 101 | + `e2e-cnpg-pgbackrest`) |
| 102 | +2. Build the container images for the pgbackrest plugin |
| 103 | +3. Load them on the Kubernetes Cluster |
| 104 | +4 Run the tests defined on `test/e2e/e2e_test.go`, which also install |
| 105 | + the dependencies and our plugin. |
| 106 | + |
| 107 | +To only run the tests (`test/e2e/e2e_test.go`), the `test-e2e-run-tests` |
| 108 | +target can be used : |
| 109 | + |
| 110 | +```console |
| 111 | +make test-e2e-run-tests |
| 112 | +``` |
0 commit comments