Skip to content

Commit ccaee94

Browse files
authored
Minor improvements (zalando#381)
* Minor improvements * Document empty list vs null for users without privileges * Change the wording for null values * Add talk by Oleksii in Atmosphere
1 parent 86ba92a commit ccaee94

11 files changed

+35
-29
lines changed

.zappr.yaml

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

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean local linux macos docker push scm-source.json
1+
.PHONY: clean local test linux macos docker push scm-source.json
22

33
BINARY ?= postgres-operator
44
BUILD_FLAGS ?= -v
@@ -86,3 +86,6 @@ vet:
8686

8787
deps:
8888
@glide install --strip-vendor
89+
90+
test:
91+
@go test ./...

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ kubectl create -f manifests/configmap.yaml # configuration
6767
kubectl create -f manifests/operator-service-account-rbac.yaml # identity and permissions
6868
kubectl create -f manifests/postgres-operator.yaml # deployment
6969

70-
# create a Postgres cluster
70+
# create a Postgres cluster in a non-default namespace
71+
kubectl create namespace test
72+
kubectl config set-context minikube --namespace=test
7173
kubectl create -f manifests/minimal-postgres-manifest.yaml
7274

7375
# connect to the Postgres master via psql
7476
# operator creates the relevant k8s secret
75-
export HOST_PORT=$(minikube service acid-minimal-cluster --url | sed 's,.*/,,')
77+
export HOST_PORT=$(minikube service --namespace test acid-minimal-cluster --url | sed 's,.*/,,')
7678
export PGHOST=$(echo $HOST_PORT | cut -d: -f 1)
7779
export PGPORT=$(echo $HOST_PORT | cut -d: -f 2)
7880
export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d)
@@ -90,11 +92,10 @@ cd postgres-operator
9092

9193
## Running and testing the operator
9294

93-
The best way to test the operator is to run it in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/).
94-
Minikube is a tool to run Kubernetes cluster locally.
95+
The best way to test the operator is to run it locally in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/). See developer docs(`docs/developer.yaml`) for details.
9596

9697
### Configuration Options
9798

98-
The operator can be configured with the provided ConfigMap (`manifests/configmap.yaml`).
99+
The operator can be configured with the provided ConfigMap(`manifests/configmap.yaml`) or the operator's own CRD.
99100

100101

docs/developer.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,12 @@ Type 'help' for list of commands.
275275
(dlv) c
276276
PASS
277277
```
278+
279+
To test the multinamespace setup, you can use
280+
```
281+
./run_operator_locally.sh --rebuild-operator
282+
```
283+
It will automatically create an `acid-minimal-cluster` in the namespace `test`. Then you can for example check the Patroni logs:
284+
```
285+
kubectl logs acid-minimal-cluster-0
286+
```

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Please, report any issues discovered to https://github.com/zalando-incubator/pos
5151

5252
## Talks
5353

54-
1. "Blue elephant on-demand: Postgres + Kubernetes" talk by Oleksii Kliukin and Jan Mussler, FOSDEM 2018: [video](https://fosdem.org/2018/schedule/event/blue_elephant_on_demand_postgres_kubernetes/) | [slides (pdf)](https://www.postgresql.eu/events/fosdem2018/sessions/session/1735/slides/59/FOSDEM%202018_%20Blue_Elephant_On_Demand.pdf)
54+
1. "PostgreSQL High Availability on Kubernetes with Patroni" talk by Oleksii Kliukin, Atmosphere 2018: [video](https://www.youtube.com/watch?v=cFlwQOPPkeg) | [slides](https://speakerdeck.com/alexeyklyukin/postgresql-high-availability-on-kubernetes-with-patroni)
5555

56-
2. "Kube-Native Postgres" talk by Josh Berkus, KubeCon 2017: [video](https://www.youtube.com/watch?v=Zn1vd7sQ_bc)
56+
2. "Blue elephant on-demand: Postgres + Kubernetes" talk by Oleksii Kliukin and Jan Mussler, FOSDEM 2018: [video](https://fosdem.org/2018/schedule/event/blue_elephant_on_demand_postgres_kubernetes/) | [slides (pdf)](https://www.postgresql.eu/events/fosdem2018/sessions/session/1735/slides/59/FOSDEM%202018_%20Blue_Elephant_On_Demand.pdf)
57+
58+
3. "Kube-Native Postgres" talk by Josh Berkus, KubeCon 2017: [video](https://www.youtube.com/watch?v=Zn1vd7sQ_bc)

docs/reference/operator_parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ key.
379379
infrastructure role. The default is `admin`.
380380

381381
* **postgres_superuser_teams**
382-
List of teams which members need the superuser role in each PG database cluster to administer Postgres and maintain infrastructure built around it. The default is `postgres_superuser`.
382+
List of teams which members need the superuser role in each PG database cluster to administer Postgres and maintain infrastructure built around it. The default is empty.
383383

384384
## Logging and REST API
385385

docs/user.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
- createdb
2121

2222
# role for application foo
23-
foo_user:
23+
foo_user: # or 'foo_user: []'
2424

2525
#databases: name->owner
2626
databases:
@@ -74,8 +74,8 @@ for an example of `zalando` role, defined with `superuser` and `createdb`
7474
flags.
7575

7676
Manifest roles are defined as a dictionary, with a role name as a key and a
77-
list of role options as a value. For a role without any options supply an empty
78-
list.
77+
list of role options as a value. For a role without any options it is best to supply the empty
78+
list `[]`. It is also possible to leave this field empty as in our example manifests, but in certain cases such empty field may removed by Kubernetes [due to the `null` value it gets](https://kubernetes.io/docs/concepts/overview/object-management-kubectl/declarative-config/#how-apply-calculates-differences-and-merges-changes) (`foobar_user:` is equivalent to `foobar_user: null`).
7979

8080
The operator accepts the following options: `superuser`, `inherit`, `login`,
8181
`nologin`, `createrole`, `createdb`, `replication`, `bypassrls`.

manifests/configmap.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ kind: ConfigMap
33
metadata:
44
name: postgres-operator
55
data:
6-
# if set to the "*", listen to all namespaces
7-
# watched_namespace: development
6+
watched_namespace: "*" # listen to all namespaces
87
cluster_labels: application:spilo
98
cluster_name_label: version
109
pod_role_label: spilo-role
1110

1211
debug_logging: "true"
1312
workers: "4"
14-
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p8
13+
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p29
1514
pod_service_account_name: "zalando-postgres-operator"
1615
secret_name_template: '{username}.{cluster}.credentials'
1716
super_username: postgres
1817
enable_teams_api: "false"
18+
# postgres_superuser_teams: "postgres_superusers"
1919
# enable_team_superuser: "false"
2020
# team_admin_role: "admin"
2121
# teams_api_url: http://fake-teams-api.default.svc.cluster.local

manifests/minimal-postgres-manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: "acid.zalan.do/v1"
22
kind: postgresql
33
metadata:
44
name: acid-minimal-cluster
5+
namespace: test # assumes namespace exists beforehand
56
spec:
67
teamId: "ACID"
78
volume:

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: postgresql-operator-default-configuration
55
configuration:
66
etcd_host: ""
7-
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p8
7+
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p29
88
workers: 4
99
min_instances: -1
1010
max_instances: -1
@@ -68,6 +68,7 @@ configuration:
6868
protected_role_names:
6969
- admin
7070
# teams_api_url: ""
71+
# postgres_superuser_teams: "postgres_superusers"
7172
logging_rest_api:
7273
api_port: 8008
7374
ring_log_lines: 100

run_operator_locally.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function build_operator_binary(){
9494

9595
# redirecting stderr greatly reduces non-informative output during normal builds
9696
echo "Build operator binary (stderr redirected to /dev/null)..."
97-
make tools deps local > /dev/null 2>&1
97+
make clean tools deps local test > /dev/null 2>&1
9898

9999
}
100100

@@ -215,6 +215,7 @@ function main(){
215215

216216
clean_up
217217
start_minikube
218+
kubectl create namespace test
218219
start_operator
219220
forward_ports
220221
check_health

0 commit comments

Comments
 (0)