Skip to content

Commit 83d7a4f

Browse files
pchovelonJulian Vanden Broeck
authored andcommitted
Add basic documentation built with Docusaurus
We also: - Add a new menu and rewrite the contribute page; - Add readthedoc configuration file; - Move page markdown page on specific folder Signed-off-by: Pierrick Chovelon <pierrick.chovelon@dalibo.com>
1 parent 5e60418 commit 83d7a4f

26 files changed

+18963
-0
lines changed

REUSE.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ path = [
1212
"PROJECT",
1313
"manifest.yaml",
1414
"config/**",
15+
"docs/**",
1516
"examples/**",
1617
"kubernetes/**",
1718
".github/workflows/**",

docs/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

docs/.readthedocs.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Required
2+
version: 2
3+
4+
# Set the OS, Python version, and other tools you might need
5+
build:
6+
os: ubuntu-24.04
7+
tools:
8+
nodejs: "22"
9+
10+
commands:
11+
# Install Docusaurus dependencies
12+
- cd docs/ && npm install
13+
# Build the site
14+
- cd docs/ && npm run build
15+
# Copy generated files into Read the Docs directory
16+
- mkdir --parents $READTHEDOCS_OUTPUT/html/
17+
- cp --recursive docs/build/* $READTHEDOCS_OUTPUT/html/
18+
19+
20+

docs/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
## Installation
6+
7+
```bash
8+
yarn
9+
```
10+
11+
## Local Development
12+
13+
```bash
14+
yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
## Build
20+
21+
```bash
22+
yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
## Deployment
28+
29+
Using SSH:
30+
31+
```bash
32+
USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```bash
38+
GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

docs/docs/backup.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Backuping an instance
6+
7+
There are two ways to backup a PostgreSQL Cluster with this plugin through the CloudNativePG operator :
8+
9+
* One shot backup, equivalent to running it by hand but through a `Backup`
10+
object definition ;
11+
* With `Scheduled Backup` object, equivalent to defining a crontab entry to run a
12+
backup periodically.
13+
14+
Whatever the kind of backup, users can list and see them with the
15+
appropriate `kubectl` command :
16+
17+
```console
18+
kubectl get backups.postgresql.cnpg.io
19+
```
20+
21+
## One shot backup
22+
23+
Backup can be requested through a `Backup` object, using the default
24+
CloudNativePG CRD `Backup` definition. The pgbackrest plugin can be specified
25+
when declaring the `Backup` object. The `method` should be set to
26+
`plugin` and the `pluginConfiguration.name` field to
27+
`pgbackrest.dalibo.com`.
28+
29+
Here is a full example of a backup definition using the pgBackRest
30+
plugin :
31+
32+
```yaml title="backup.yaml"
33+
---
34+
apiVersion: postgresql.cnpg.io/v1
35+
kind: Backup
36+
metadata:
37+
name: backup-example
38+
spec:
39+
method: plugin
40+
cluster:
41+
name: cluster-demo
42+
pluginConfiguration:
43+
name: pgbackrest.dalibo.com
44+
```
45+
46+
It's also possible to use the `cnpg` plugin for `kubectl` to perform
47+
your backup :
48+
49+
```console
50+
kubectl cnpg backup cluster-demo -m plugin --plugin-name pgbackrest.dalibo.com
51+
```
52+
53+
When performing a backup, you can choose the repository to which to push
54+
it. To do this, you need to define the `selectedRepository` key using
55+
the number of the repository, according to its position in the list of
56+
configured repositories. For example, to use the first repository:
57+
58+
```yaml title="backup.yaml"
59+
[...]
60+
pluginConfiguration:
61+
name: pgbackrest.dalibo.com
62+
parameters:
63+
selectedRepository: "1"
64+
```
65+
66+
Or with the `cnpg` plugin:
67+
68+
```console
69+
kubectl cnpg backup cluster-demo -m plugin --plugin-name pgbackrest.dalibo.com \
70+
--plugin-parameters selectedRepository=1
71+
```
72+
73+
## Scheduled backup
74+
75+
A scheduled backup uses almost the same definition as a one-shot backup. Only the kind should be changed to `ScheduledBackup`. When using this object, the schedule field (with a `crontab`-like annotation) should
76+
also be defined under the specification (`spec`).
77+
78+
Here is a full example of a scheduled backup definition using the
79+
pgbackrest plugin :
80+
81+
```yaml title="scheduled-backup.yaml"
82+
---
83+
apiVersion: postgresql.cnpg.io/v1
84+
kind: ScheduledBackup
85+
metadata:
86+
name: backup-example
87+
spec:
88+
schedule: "0 30 * * * *"
89+
method: plugin
90+
cluster:
91+
name: cluster-demo
92+
pluginConfiguration:
93+
name: pgbackrest.dalibo.com
94+
```

docs/docs/contribute.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
```

docs/docs/howitworks.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# How it works
6+
## How it works
7+
8+
Here are some basic informations about how this plugin should work:
9+
10+
- When installing the plugin, a new deployment is created to run a Pod
11+
for the controller (`pgbackrest-controller`) of our plugin in the same
12+
namespace as the CNPG operator.
13+
14+
- The CNPG operator detects the plugin when a dedicated Kubernetes
15+
Service (with some specific annotations) is created.
16+
17+
- Our specialized controller exposes the supported capabilities (at
18+
least those required to manage the
19+
[lifecycle](https://pkg.go.dev/github.com/cloudnative-pg/cnpg-i@v0.1.0/pkg/lifecycle)
20+
of our CNPG instances) to the CNPG operator.
21+
22+
- When initializing a new Cluster configured with our plugin, the
23+
pgBackRest controller will be called by the CloudNativePG operator.
24+
25+
- The plugin controller modifies the resources (Deployment / Pods /
26+
Jobs) requested by the CNPG operator (this is done before requesting
27+
the Kubernetes API), and inject some configuration if needed.
28+
29+
For our pgbackrest plugin, the controller inject a sidecar container
30+
for `pgBackRest` within the PostgreSQL Pods. This sidecar container
31+
executes a manager dedicated to `pgBackRest` (which expose the
32+
required capabilities archive the WAL and backup the PostgreSQL
33+
instance).
34+
35+
- Our newly created PostgreSQL instance will call the dedicated
36+
`pgBackRest` manager (on the side container) when the archive command
37+
is triggered.
38+
39+
https://github.com/cloudnative-pg/cnpg-i/blob/main/docs/protocol.md#cnpgi-wal-v1-WALCapability-RPC

0 commit comments

Comments
 (0)