Skip to content

Commit 5d02c57

Browse files
alexeyklyukinsdudoladov
authored andcommitted
Docs/reference (zalando#323)
Document operator command-line options and environment variables.
1 parent b518a31 commit 5d02c57

File tree

11 files changed

+187
-71
lines changed

11 files changed

+187
-71
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ manages PostgreSQL clusters on Kubernetes:
2626
3. Finally, the operator periodically synchronizes the actual state of each
2727
Postgres cluster with the desired state defined in the cluster's manifest.
2828

29+
There is a browser-friendly version of this documentation at
30+
[postgres-operator.readthedocs.io](https://postgres-operator.readthedocs.io)
31+
32+
## Table of contents
33+
34+
* [concepts](docs/index.md)
35+
* [user documentation](docs/user.md)
36+
* [administrator documentation](docs/administrator.md)
37+
* [developer documentation](docs/developer.md)
38+
* [operator configuration reference](docs/reference/operator_parameters.md)
39+
* [cluster manifest reference](docs/reference/cluster_manifest.md)
40+
* [command-line options and environment variables](docs/reference/command_line_and_environment.md)
41+
42+
the rest of the document is a tutorial to get you up and running with the operator on Minikube.
2943

3044
## Quickstart
3145

@@ -34,6 +48,11 @@ Prerequisites:
3448
* [minikube](https://github.com/kubernetes/minikube/releases)
3549
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl)
3650

51+
Note that you can also use built-in Kubernetes support in the Docker Desktop
52+
for Mac to follow the steps of this tutorial. You would have to replace
53+
`minikube start` and `minikube delete` with your launch actionsfor the Docker
54+
built-in Kubernetes support.
55+
3756
### Local execution
3857

3958
```bash
@@ -77,10 +96,4 @@ Minikube is a tool to run Kubernetes cluster locally.
7796

7897
The operator can be configured with the provided ConfigMap (`manifests/configmap.yaml`).
7998

80-
## Table of contents
8199

82-
* [concepts](docs/concepts.md)
83-
* [user documentation](docs/user.md)
84-
* [administrator documentation](docs/administrator.md)
85-
* [developer documentation](docs/developer.md)
86-
* [reference](docs/reference.md)

docs/administrator.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# How to deploy PostgreSQL operator
2-
31
## Create ConfigMap
42

53
ConfigMap is used to store the configuration of the operator

docs/developer.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Installing and starting minikube
2-
31
## Intro
42

53
See [minikube installation guide](https://github.com/kubernetes/minikube/releases)
@@ -12,9 +10,7 @@ After the installation, issue
1210
$ minikube start
1311
```
1412

15-
Note: if you are running on a Mac, make sure to use the [xhyve
16-
driver](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#xhyve-driver)
17-
instead of the default docker-machine one for performance reasons.
13+
Note: if you are running on a Mac, you may also use Docker for Mac Kubernetes instead of a docker-machine.
1814

1915
Once you have it started successfully, use [the quickstart
2016
guide](https://github.com/kubernetes/minikube#quickstart) in order to test your

docs/concepts.md renamed to docs/index.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1-
# Concepts
1+
# Introduction
22

3-
## Scope
3+
The Postgres [operator](https://coreos.com/blog/introducing-operators.html)
4+
manages PostgreSQL clusters on Kubernetes:
5+
6+
1. The operator watches additions, updates, and deletions of PostgreSQL cluster
7+
manifests and changes the running clusters accordingly. For example, when a
8+
user submits a new manifest, the operator fetches that manifest and spawns a
9+
new Postgres cluster along with all necessary entities such as Kubernetes
10+
StatefulSets and Postgres roles. See this
11+
[Postgres cluster manifest](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/complete-postgres-manifest.yaml)
12+
for settings that a manifest may contain.
13+
14+
2. The operator also watches updates to [its own configuration](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/configmap.yaml)
15+
and alters running Postgres clusters if necessary. For instance, if a pod
16+
docker image is changed, the operator carries out the rolling update. That
17+
is, the operator re-spawns one-by-one pods of each StatefulSet it manages
18+
with the new Docker image.
19+
20+
3. Finally, the operator periodically synchronizes the actual state of each
21+
Postgres cluster with the desired state defined in the cluster's manifest.
22+
23+
## Concepts
24+
25+
### Scope
426

527
The scope of the postgres operator is on provisioning, modifying configuration
628
and cleaning up Postgres clusters that use Patroni, basically to make it easy
@@ -15,7 +37,7 @@ experience.
1537
Monitoring of clusters is not in scope, for this good tools already exist from
1638
ZMON to Prometheus and more Postgres specific options.
1739

18-
## Status
40+
### Status
1941

2042
This project is currently in active development. It is however already
2143
[used internally by Zalando](https://jobs.zalando.com/tech/blog/postgresql-in-a-time-of-kubernetes/)

docs/quickstart.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Prerequisites:
2+
3+
In order to run the Postgres operator locally in minikube you need to install the following tools:
4+
5+
* [minikube](https://github.com/kubernetes/minikube/releases)
6+
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl)
7+
8+
Note that you can also use built-in Kubernetes support in the Docker Desktop
9+
for Mac to follow the steps of this tutorial. You would have to replace
10+
`minikube start` and `minikube delete` with your launch actionsfor the Docker
11+
built-in Kubernetes support.
12+
13+
## Local execution
14+
15+
```bash
16+
git clone https://github.com/zalando-incubator/postgres-operator.git
17+
cd postgres-operator
18+
19+
minikube start
20+
21+
# start the operator; may take a few seconds
22+
kubectl create -f manifests/configmap.yaml # configuration
23+
kubectl create -f manifests/operator-service-account-rbac.yaml # identity and permissions
24+
kubectl create -f manifests/postgres-operator.yaml # deployment
25+
26+
# create a Postgres cluster
27+
kubectl create -f manifests/minimal-postgres-manifest.yaml
28+
29+
# connect to the Postgres master via psql
30+
# operator creates the relevant k8s secret
31+
export HOST_PORT=$(minikube service acid-minimal-cluster --url | sed 's,.*/,,')
32+
export PGHOST=$(echo $HOST_PORT | cut -d: -f 1)
33+
export PGPORT=$(echo $HOST_PORT | cut -d: -f 2)
34+
export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d)
35+
psql -U postgres
36+
37+
# tear down cleanly
38+
minikube delete
39+
```
40+
41+
We have automated starting the operator and submitting the `acid-minimal-cluster` for you:
42+
```bash
43+
cd postgres-operator
44+
./run_operator_locally.sh
45+
```
46+
47+
## Running and testing the operator
48+
49+
The best way to test the operator is to run it in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/).
50+
Minikube is a tool to run Kubernetes cluster locally.
51+
52+
### Configuration Options
53+
54+
The operator can be configured with the provided ConfigMap (`manifests/configmap.yaml`).

docs/reference.md

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

docs/cluster_manifest.md renamed to docs/reference/cluster_manifest.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Postgres Cluster Manifest
2-
=========================
31

42
Individual postgres clusters are described by the Kubernetes *cluster manifest*
53
that has the structure defined by the `postgres CRD` (custom resource
@@ -16,14 +14,13 @@ measurements. Please, refer to the [Kubernetes
1614
documentation](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
1715
for the possible values of those.
1816

19-
Manifest structure
20-
------------------
17+
## Manifest structure
2118

2219
A postgres manifest is a `YAML` document. On the top level both individual
2320
parameters and parameter groups can be defined. Parameter names are written
2421
in camelCase.
2522

26-
### Cluster metadata
23+
## Cluster metadata
2724

2825
Those parameters are grouped under the `metadata` top-level key.
2926

@@ -38,7 +35,7 @@ Those parameters are grouped under the `metadata` top-level key.
3835
namespace. Optional (if present, should match the namespace where the
3936
manifest is applied).
4037

41-
### Top-level parameters
38+
## Top-level parameters
4239

4340
Those are parameters grouped directly under the `spec` key in the manifest.
4441

@@ -93,7 +90,7 @@ Those are parameters grouped directly under the `spec` key in the manifest.
9390
for details on tolerations and possible values of those keys. When set, this
9491
value overrides the `pod_toleration` setting from the operator. Optional.
9592

96-
### Postgres parameters
93+
## Postgres parameters
9794

9895
Those parameters are grouped under the `postgresql` top-level key.
9996

@@ -108,7 +105,7 @@ Those parameters are grouped under the `postgresql` top-level key.
108105
cluster. Optional (Spilo automatically sets reasonable defaults for
109106
parameters like work_mem or max_connections).
110107

111-
### Patroni parameters
108+
## Patroni parameters
112109

113110
Those parameters are grouped under the `patroni` top-level key. See the [patroni
114111
documentation](https://patroni.readthedocs.io/en/latest/SETTINGS.html) for the
@@ -147,14 +144,14 @@ explanation of `ttl` and `loop_wait` parameters.
147144
patroni `maximum_lag_on_failover` parameter value, optional. The default is
148145
set by the Spilo docker image. Optional.
149146

150-
### Postgres container resources
147+
## Postgres container resources
151148

152149
Those parameters define [CPU and memory requests and
153150
limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
154151
for the postgres container. They are grouped under the `resources` top-level
155152
key. There are two subgroups, `requests` and `limits`.
156153

157-
#### Requests
154+
### Requests
158155

159156
CPU and memory requests for the postgres container.
160157

@@ -178,7 +175,7 @@ CPU and memory limits for the postgres container.
178175
memory limits for the postgres container. Optional, overrides the
179176
`default_memory_limits` operator configuration parameter. Optional.
180177

181-
### Parameters defining how to clone the cluster from another one
178+
## Parameters defining how to clone the cluster from another one
182179

183180
Those parameters are applied when the cluster should be a clone of another one
184181
that is either already running or has a basebackup on S3. They are grouped
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Command-line options
2+
3+
The following command-line options are supported for the operator:
4+
5+
* **-kubeconfig**
6+
the path to the kubeconfig file. Usually named config, it contains
7+
authorization information as well as the URL of the Kubernetes master.
8+
9+
* **-outofcluster**
10+
run the operator on a client machine, as opposed to a within the cluster.
11+
When running in this mode, the operator cannot connect to databases inside
12+
the cluster, as well as call URLs of in-cluster objects (i.e. teams api
13+
server). Mostly useful for debugging, it also requires setting the
14+
`OPERATOR_NAMESPACE` environment variable for the operator own namespace.
15+
16+
* **-nodatabaseaccess**
17+
disable database access from the operator. Equivalent to the
18+
`enable_database_access` set to off and can be overridden by the
19+
aforementioned operator configuration option.
20+
21+
* **-noteamsapi**
22+
disable access to the teams API. Equivalent to the `enable_teams_api` set to
23+
off can can be overridden by the aforementioned operator configuration
24+
option.
25+
26+
In addition to that, standard [glog
27+
flags](https://godoc.org/github.com/golang/glog) are also supported. For
28+
instance, one may want to add `-alsologtostderr` and `-v=8` to debug the
29+
operator REST calls.
30+
31+
## Environment variables
32+
33+
The following environment variables are accepted by the operator:
34+
35+
* **CONFIG_MAP_NAME**
36+
name of the config map where the operator should look for its configuration.
37+
Must be present.
38+
39+
* **OPERATOR_NAMESPACE**
40+
name of the namespace the operator runs it. Overrides autodetection by the
41+
operator itself.
42+
43+
* **WATCHED_NAMESPACE**
44+
the name of the namespace the operator watches. Special '*' character denotes
45+
all namespaces. Empty value defaults to the operator namespace. Overrides the
46+
`watched_namespace` operator parameter.
47+
48+
* **SCALYR_API_KEY**
49+
the value of the Scalyr API key to supply to the pods. Overrides the
50+
`scalyr_api_key` operator parameter.

0 commit comments

Comments
 (0)