Skip to content

Commit c987a0f

Browse files
fcanovaijsilvelaNiccoloFei
authored
docs: documentation overhaul (#22)
Define the scope of the project in the README and explain how the users can run the plugin. Merge the details of the implementation in a single, separate markdown file. Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com> Signed-off-by: Jaime Silvela <jaime.silvela@enterprisedb.com> Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Co-authored-by: Jaime Silvela <jaime.silvela@enterprisedb.com> Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent f28578c commit c987a0f

File tree

8 files changed

+265
-190
lines changed

8 files changed

+265
-190
lines changed

.spellcheck.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ matrix:
1010
lang: en
1111
d: en_US
1212
pipeline:
13+
- pyspelling.filters.context:
14+
context_visible_first: true
15+
delimiters:
16+
# Ignore multiline content between fences (fences can have 3 or more back ticks)
17+
# ```
18+
# content
19+
# ```
20+
- open: '(?s)^(?P<open> *`{3,})'
21+
close: '^(?P=open)$'
1322
- pyspelling.filters.markdown:
1423
- pyspelling.filters.html:
1524
comments: false

.wordlist.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
ClusterLifecycle
22
CloudNativePG
3+
cloudnative
4+
cnpg
35
CNPG
6+
CNPG's
47
finalizers
8+
github
59
GRPC
10+
https
11+
kubectl
612
kubernetes
713
Kubernetes
814
lifecycle
@@ -14,12 +20,15 @@ OperatorValidateClusterChangeResult
1420
OperatorValidateClusterCreateRequest
1521
OperatorValidateClusterCreateResult
1622
pluginhelper
23+
proto
1724
Postgres
1825
reconcilers
1926
rpc
2027
struct
28+
TLS
2129
ValidateClusterChange
2230
ValidateClusterCreate
2331
ValidateCreate
2432
webhook
2533
webhooks
34+
yaml

README.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
1-
# CNPG-I-EXAMPLE
1+
# CNPG-I Hello World Plugin
22

3-
A "hello world" example implementation of the
4-
[CloudNativePG](https://github.com/cloudnative-pg/cloudnative-pg/)
5-
plugin interface [CNPG-I](https://github.com/cloudnative-pg/cnpg-i).
3+
A [CNPG-I](https://github.com/cloudnative-pg/cnpg-i) plugin to add labels and
4+
annotations
5+
to [CloudNativePG](https://github.com/cloudnative-pg/cloudnative-pg/) clusters.
66

7-
- [Concepts](doc/concepts.md)
8-
- [Workflow](doc/workflow.md)
7+
This project serves as an introductory guide to bootstrapping
8+
a [CNPG-I](https://github.com/cloudnative-pg/cnpg-i) plugin and leveraging
9+
lifecycle hooks within a development environment. While similar results can be
10+
achieved through simpler methods such as mutating webhooks or CNPG's built-in
11+
features, this project is specifically designed to familiarize developers with
12+
the plugin workflow. By understanding how lifecycle hooks interact with other
13+
interfaces, developers can gain a deeper insight into implementing complex
14+
resource changes in real-world applications.
915

10-
This plugin uses the [pluginhelper](https://github.com/cloudnative-pg/cnpg-i-machinery/tree/main/pkg/pluginhelper) from [`cnpg-i-machinery`](https://github.com/cloudnative-pg/cnpg-i-machinery) to simplify the plugin's implementation.
16+
This plugin uses
17+
the [pluginhelper](https://github.com/cloudnative-pg/cnpg-i-machinery/tree/main/pkg/pluginhelper)
18+
from [`cnpg-i-machinery`](https://github.com/cloudnative-pg/cnpg-i-machinery) to
19+
simplify the plugin's implementation.
20+
21+
## Running the plugin
22+
23+
To see the plugin in execution, you need to have a Kubernetes cluster running
24+
(we'll use [Kind](https://kind.sigs.k8s.io)) and the
25+
[CloudNativePG](https://github.com/cloudnative-pg/cloudnative-pg/) operator
26+
installed. The plugin also requires certificates to communicate with the
27+
operator, hence we are also installing [cert-manager](https://cert-manager.io/)
28+
to manage them.
29+
30+
``` shell
31+
kind create cluster --name cnpg-i-hello-world
32+
# Choose the latest version of CloudNativePG (at least 1.24)
33+
kubectl apply --server-side -f \
34+
https://github.com/cloudnative-pg/cloudnative-pg/releases/download/vX.Y.Z/cnpg-X.Y.Z.yaml
35+
# Choose the latest version of cert-manager
36+
kubectl apply -f \
37+
https://github.com/cert-manager/cert-manager/releases/download/vX.Y.Z/cert-manager.yaml
38+
```
39+
40+
Then install the plugin by applying the manifest:
41+
42+
<!-- TODO: reevaluate on release and set release-please to automatically update it-->
43+
44+
``` shell
45+
kubectl apply -f https://github.com/cloudnative-pg/cnpg-i-hello-world/releases/download/v0.1.0/manifest.yaml
46+
```
47+
48+
Finally, create a cluster resource to see the plugin in action. There are three
49+
examples in the `doc/examples` directory:
50+
51+
1. [Cluster with labels and annotations](doc/examples/cluster-example.yaml):
52+
adds the defined labels and annotations to the pods. Showcases the plugin
53+
capability of altering the lifecycle of the CloudNativePG resources.
54+
2. [Cluster with no parameters](doc/examples/cluster-example-no-parameters.yaml):
55+
defaults the plugin settings of the cluster. Showcases the plugin capability
56+
of altering the defaulting webhook behavior.
57+
3. [Cluster with wrong parameters](doc/examples/cluster-example-with-mistake.yaml):
58+
includes an error in the configuration. Showcases the plugin capability of
59+
validating its own configuration.
60+
61+
## Plugin development
62+
63+
For additional details on the plugin implementation refer to
64+
the [development documentation](doc/development.md).

Taskfile.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ tasks:
181181
desc: Build a container image for the plugin locally
182182
vars:
183183
IMAGE_VERSION: '{{.IMAGE_VERSION | default "latest"}}'
184-
IMAGE_NAME: ghcr.io/cloudnative-pg/cnpg-i-hello-world:{{.IMAGE_VERSION}}
184+
IMAGE_NAME: cnpg-i-hello-world:{{.IMAGE_VERSION}}
185185
cmds:
186-
- docker build -t ${IMAGE_NAME} .
186+
- docker build -t {{.IMAGE_NAME}} .
187187
sources:
188188
- ./**
189189

@@ -192,5 +192,7 @@ tasks:
192192
desc: Apply the plugin to a local kind cluster
193193
deps:
194194
- local-dev-image
195+
env:
196+
VERSION: '{{.IMAGE_VERSION | default "latest"}}'
195197
cmds:
196198
- ./scripts/run.sh

doc/concepts.md

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)