From 01704e3d6666369abeb8865e53c921b9691577f9 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Tue, 11 Sep 2018 09:59:21 +0200 Subject: [PATCH] Minor improvements --- .zappr.yaml | 12 ------------ Makefile | 5 ++++- README.md | 11 ++++++----- docs/developer.md | 9 +++++++++ docs/reference/operator_parameters.md | 2 +- manifests/configmap.yaml | 6 +++--- manifests/minimal-postgres-manifest.yaml | 1 + .../postgresql-operator-default-configuration.yaml | 3 ++- run_operator_locally.sh | 3 ++- 9 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 .zappr.yaml diff --git a/.zappr.yaml b/.zappr.yaml deleted file mode 100644 index 865e393d0..000000000 --- a/.zappr.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# for github.com -approvals: - groups: - zalando: - minimum: 2 - from: - orgs: - - "zalando" -X-Zalando-Team: "acid" -# type should be one of [code, doc, config, tools, secrets] -# code will be the default value, if X-Zalando-Type is not found in .zappr.yml -X-Zalando-Type: code diff --git a/Makefile b/Makefile index 34e8e22a2..45066a3a7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean local linux macos docker push scm-source.json +.PHONY: clean local test linux macos docker push scm-source.json BINARY ?= postgres-operator BUILD_FLAGS ?= -v @@ -76,3 +76,6 @@ vet: deps: @glide install --strip-vendor + +test: + @go test ./... diff --git a/README.md b/README.md index 595dca6d5..18ea97538 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,14 @@ kubectl create -f manifests/configmap.yaml # configuration kubectl create -f manifests/operator-service-account-rbac.yaml # identity and permissions kubectl create -f manifests/postgres-operator.yaml # deployment -# create a Postgres cluster +# create a Postgres cluster in a non-default namespace +kubectl create namespace test +kubectl config set-context minikube --namespace=test kubectl create -f manifests/minimal-postgres-manifest.yaml # connect to the Postgres master via psql # operator creates the relevant k8s secret -export HOST_PORT=$(minikube service acid-minimal-cluster --url | sed 's,.*/,,') +export HOST_PORT=$(minikube service --namespace test acid-minimal-cluster --url | sed 's,.*/,,') export PGHOST=$(echo $HOST_PORT | cut -d: -f 1) export PGPORT=$(echo $HOST_PORT | cut -d: -f 2) export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d) @@ -90,11 +92,10 @@ cd postgres-operator ## Running and testing the operator -The best way to test the operator is to run it in [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/). -Minikube is a tool to run Kubernetes cluster locally. +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. ### Configuration Options -The operator can be configured with the provided ConfigMap (`manifests/configmap.yaml`). +The operator can be configured with the provided ConfigMap(`manifests/configmap.yaml`) or the operator's own CRD. diff --git a/docs/developer.md b/docs/developer.md index dba627149..5d766b023 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -275,3 +275,12 @@ Type 'help' for list of commands. (dlv) c PASS ``` + +To test the multinamespace setup, you can use +``` +./run_operator_locally.sh --rebuild-operator +``` +It will automatically create an `acid-minimal-cluster` in the namespace `test`. Then you can for example check the Patroni logs: +``` +kubectl logs acid-minimal-cluster-0 +``` diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 7d8e243bb..5f703bcc2 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -378,7 +378,7 @@ key. infrastructure role. The default is `admin`. * **postgres_superuser_teams** - 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`. + 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. ## Logging and REST API diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 7725c3630..ed7652907 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -3,19 +3,19 @@ kind: ConfigMap metadata: name: postgres-operator data: - # if set to the "*", listen to all namespaces - # watched_namespace: development + watched_namespace: "*" # listen to all namespaces cluster_labels: application:spilo cluster_name_label: version pod_role_label: spilo-role debug_logging: "true" workers: "4" - docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p8 + docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p29 pod_service_account_name: "zalando-postgres-operator" secret_name_template: '{username}.{cluster}.credentials' super_username: postgres enable_teams_api: "false" + # postgres_superuser_teams: "postgres_superusers" # enable_team_superuser: "false" # team_admin_role: "admin" # teams_api_url: http://fake-teams-api.default.svc.cluster.local diff --git a/manifests/minimal-postgres-manifest.yaml b/manifests/minimal-postgres-manifest.yaml index c8f486201..ae5d36cbc 100644 --- a/manifests/minimal-postgres-manifest.yaml +++ b/manifests/minimal-postgres-manifest.yaml @@ -2,6 +2,7 @@ apiVersion: "acid.zalan.do/v1" kind: postgresql metadata: name: acid-minimal-cluster + namespace: test # assumes namespace exists beforehand spec: teamId: "ACID" volume: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index d2a1307f8..391702cdc 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -4,7 +4,7 @@ metadata: name: postgresql-operator-default-configuration configuration: etcd_host: "" - docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p8 + docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p29 workers: 4 min_instances: -1 max_instances: -1 @@ -68,6 +68,7 @@ configuration: protected_role_names: - admin # teams_api_url: "" + # postgres_superuser_teams: "postgres_superusers" logging_rest_api: api_port: 8008 ring_log_lines: 100 diff --git a/run_operator_locally.sh b/run_operator_locally.sh index a4cf5f45b..301803c35 100755 --- a/run_operator_locally.sh +++ b/run_operator_locally.sh @@ -94,7 +94,7 @@ function build_operator_binary(){ # redirecting stderr greatly reduces non-informative output during normal builds echo "Build operator binary (stderr redirected to /dev/null)..." - make tools deps local > /dev/null 2>&1 + make clean tools deps local test > /dev/null 2>&1 } @@ -215,6 +215,7 @@ function main(){ clean_up start_minikube + kubectl create namespace test start_operator forward_ports check_health