Skip to content

Commit f19255f

Browse files
committed
add paragraph on how to extend operator configuration in dev docs
1 parent 67b2fc4 commit f19255f

File tree

1 file changed

+57
-15
lines changed

1 file changed

+57
-15
lines changed

docs/developer.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ After the installation, issue
1010
$ minikube start
1111
```
1212

13-
Note: if you are running on a Mac, you may also use Docker for Mac Kubernetes instead of a docker-machine.
13+
Note: if you are running on a Mac, you may also use Docker for Mac Kubernetes
14+
instead of a docker-machine.
1415

1516
Once you have it started successfully, use [the quickstart
1617
guide](https://github.com/kubernetes/minikube#quickstart) in order to test your
@@ -79,7 +80,8 @@ cluster.
7980

8081
## Connect to PostgreSQL
8182

82-
We can use the generated secret of the `postgres` robot user to connect to our `acid-minimal-cluster` master running in Minikube:
83+
We can use the generated secret of the `postgres` robot user to connect to our
84+
`acid-minimal-cluster` master running in Minikube:
8385

8486
```bash
8587
$ export HOST_PORT=$(minikube service acid-minimal-cluster --url | sed 's,.*/,,')
@@ -166,8 +168,15 @@ minikube. The following steps will get you the docker image built and deployed.
166168

167169
# Code generation
168170

169-
The operator employs k8s-provided code generation to obtain deep copy methods and Kubernetes-like APIs for its custom resource definitons, namely the Postgres CRD and the operator CRD. The usage of the code generation follows conventions from the k8s community. Relevant scripts live in the `hack` directory: the `update-codegen.sh` triggers code generation for the APIs defined in `pkg/apis/acid.zalan.do/`,
170-
the `verify-codegen.sh` checks if the generated code is up-to-date (to be used within CI). The `/pkg/generated/` contains the resultant code. To make these scripts work, you may need to `export GOPATH=$(go env GOPATH)`
171+
The operator employs k8s-provided code generation to obtain deep copy methods
172+
and Kubernetes-like APIs for its custom resource definitons, namely the Postgres
173+
CRD and the operator CRD. The usage of the code generation follows conventions
174+
from the k8s community. Relevant scripts live in the `hack` directory:
175+
* `update-codegen.sh` triggers code generation for the APIs defined in `pkg/apis/acid.zalan.do/`,
176+
* `verify-codegen.sh` checks if the generated code is up-to-date (to be used within CI).
177+
178+
The `/pkg/generated/` contains the resultant code. To make these scripts work,
179+
you may need to `export GOPATH=$(go env GOPATH)`
171180

172181
References for code generation are:
173182
* [Relevant pull request](https://github.com/zalando/postgres-operator/pull/369)
@@ -176,7 +185,12 @@ See comments there for minor issues that can sometimes broke the generation proc
176185
* [Code Generation for CustomResources](https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/) - intro post on the topic
177186
* Code generation in [Prometheus](https://github.com/coreos/prometheus-operator) and [etcd](https://github.com/coreos/etcd-operator) operators
178187

179-
To debug the generated API locally, use the [kubectl proxy](https://kubernetes.io/docs/tasks/access-kubernetes-api/http-proxy-access-api/) and `kubectl --v=8` log level to display contents of HTTP requests (run the operator itself with `--v=8` to log all REST API requests). To attach a debugger to the operator, use the `-outofcluster` option to run the operator locally on the developer's laptop (and not in a docker container).
188+
To debug the generated API locally, use the
189+
[kubectl proxy](https://kubernetes.io/docs/tasks/access-kubernetes-api/http-proxy-access-api/)
190+
and `kubectl --v=8` log level to display contents of HTTP requests (run the
191+
operator itself with `--v=8` to log all REST API requests). To attach a debugger
192+
to the operator, use the `-outofcluster` option to run the operator locally on
193+
the developer's laptop (and not in a docker container).
180194

181195
# Debugging the operator
182196

@@ -201,15 +215,15 @@ defaults to 4)
201215
* /workers/$id/logs - log of the operations performed by a given worker
202216
* /clusters/ - list of teams and clusters known to the operator
203217
* /clusters/$team - list of clusters for the given team
204-
* /clusters/$team/$namespace/$clustername - detailed status of the cluster, including the
205-
specifications for CRD, master and replica services, endpoints and
206-
statefulsets, as well as any errors and the worker that cluster is assigned
207-
to.
208-
* /clusters/$team/$namespace/$clustername/logs/ - logs of all operations performed to the
209-
cluster so far.
210-
* /clusters/$team/$namespace/$clustername/history/ - history of cluster changes triggered
211-
by the changes of the manifest (shows the somewhat obscure diff and what
212-
exactly has triggered the change)
218+
* /clusters/$team/$namespace/$clustername - detailed status of the cluster,
219+
including the specifications for CRD, master and replica services, endpoints
220+
and statefulsets, as well as any errors and the worker that cluster is
221+
assigned to.
222+
* /clusters/$team/$namespace/$clustername/logs/ - logs of all operations
223+
performed to the cluster so far.
224+
* /clusters/$team/$namespace/$clustername/history/ - history of cluster changes
225+
triggered by the changes of the manifest (shows the somewhat obscure diff and
226+
what exactly has triggered the change)
213227

214228
The operator also supports pprof endpoints listed at the
215229
[pprof package](https://golang.org/pkg/net/http/pprof/), such as:
@@ -290,10 +304,38 @@ PASS
290304
```
291305

292306
To test the multinamespace setup, you can use
307+
293308
```
294309
./run_operator_locally.sh --rebuild-operator
295310
```
296-
It will automatically create an `acid-minimal-cluster` in the namespace `test`. Then you can for example check the Patroni logs:
311+
It will automatically create an `acid-minimal-cluster` in the namespace `test`.
312+
Then you can for example check the Patroni logs:
313+
297314
```
298315
kubectl logs acid-minimal-cluster-0
299316
```
317+
318+
## Introduce additional configuration parameters
319+
320+
In the case you want to add functionality to the operator that shall be
321+
controlled via the operator configuration there are a few placed that need to
322+
be updated. First define the parameters in:
323+
* the [ConfigMap](../manifests/configmap.yaml) manifest
324+
* the CR's [default configuration](..manifests/postgresql-operator-default-configuration.yaml)
325+
* the Helm chart [values](../charts/postgres-operator/values.yaml)
326+
327+
Update the following Go files that obtain the configuration parameter from the
328+
manifest files:
329+
* [operator_configuration_type.go](../pkg/apis/acid.zalan.do/v1/operator_configuration_type.go)
330+
* [operator_config.go](../pkg/controller/operator_config.go)
331+
* [config.go](../pkg/util/config/config.go)
332+
333+
The operator behavior has to be implemented at least in [k8sres.go](../pkg/cluster/k8sres.go).
334+
Please, reflect your changes in the tests, for example in:
335+
* [config-test.go](../pkg/util/config/config-test.go)
336+
* [k8sres_test.go](../pkg/cluster/k8sres-test.go)
337+
* [cluster_test.go](../cluster/k8sres-test.go)
338+
339+
Finally, document the new configuration option(s) for the operator in its
340+
[reference](reference/operator_parameters.md) document and explain the feature
341+
in the [administrator docs](administrator.md).

0 commit comments

Comments
 (0)