Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
Latest commit f25351c Nov 13, 2018
Permalink
Failed to load latest commit information.
cmd Allow configuring the operator via the YAML manifest. (#326) Jul 16, 2018
docker Fix typo in port (#219) Feb 2, 2018
docs Properly overwrite empty allowed source ranges for load balancers (#392) Nov 6, 2018
hack Use code-generation for CRD API and deepcopy methods (#369) Aug 15, 2018
manifests Make OperatorConfiguration work (#410) Nov 13, 2018
pkg Properly overwrite empty allowed source ranges for load balancers (#392) Nov 6, 2018
.gitignore Initial implementation for the statefulset annotations indicating rol… May 7, 2018
.travis.yml Update travis configuration. (#332) Jun 27, 2018
.zappr.yaml Restore .zappr.yaml (#405) Nov 7, 2018
CODEOWNERS Update CODEOWNERS (#376) Aug 29, 2018
CONTRIBUTING.md Change the broken reference. May 12, 2017
LICENSE Move license to the root folder. May 12, 2017
MAINTAINERS [WIP] Draft codeowners, update maintainers (#358) Aug 6, 2018
Makefile Minor improvements (#381) Nov 6, 2018
README.md Minor improvements (#381) Nov 6, 2018
SECURITY.md docs(general): Adding Security.md (#88) Sep 4, 2017
build-ci.sh Use zalando incubator instead of an old repo May 12, 2017
delivery.yaml Some fixes for travis ci and cdp Mar 27, 2018
glide.lock Fix the casing of github.com/Sirupsen/logrus to match what the projec… Sep 6, 2018
glide.yaml Fix the casing of github.com/Sirupsen/logrus to match what the projec… Sep 6, 2018
mkdocs.yml Docs/reference (#323) Jun 12, 2018
run_operator_locally.sh Minor improvements (#381) Nov 6, 2018

README.md

Postgres Operator

Build Status Coverage Status Go Report Card GoDoc

Introduction

The Postgres operator manages PostgreSQL clusters on Kubernetes:

  1. The operator watches additions, updates, and deletions of PostgreSQL cluster manifests and changes the running clusters accordingly. For example, when a user submits a new manifest, the operator fetches that manifest and spawns a new Postgres cluster along with all necessary entities such as Kubernetes StatefulSets and Postgres roles. See this Postgres cluster manifest for settings that a manifest may contain.

  2. The operator also watches updates to its own configuration and alters running Postgres clusters if necessary. For instance, if a pod docker image is changed, the operator carries out the rolling update. That is, the operator re-spawns one-by-one pods of each StatefulSet it manages with the new Docker image.

  3. Finally, the operator periodically synchronizes the actual state of each Postgres cluster with the desired state defined in the cluster's manifest.

There is a browser-friendly version of this documentation at postgres-operator.readthedocs.io

Table of contents

the rest of the document is a tutorial to get you up and running with the operator on Minikube.

Quickstart

Prerequisites:

Note that you can also use built-in Kubernetes support in the Docker Desktop for Mac to follow the steps of this tutorial. You would have to replace minikube start and minikube delete with your launch actionsfor the Docker built-in Kubernetes support.

Local execution

git clone https://github.com/zalando-incubator/postgres-operator.git
cd postgres-operator

minikube start

# start the operator; may take a few seconds
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 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 --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)
psql -U postgres

# tear down cleanly
minikube delete

We have automated starting the operator and submitting the acid-minimal-cluster for you:

cd postgres-operator
./run_operator_locally.sh

Running and testing the operator

The best way to test the operator is to run it locally in minikube. See developer docs(docs/developer.yaml) for details.

Configuration Options

The operator can be configured with the provided ConfigMap(manifests/configmap.yaml) or the operator's own CRD.