resolve merge conflicts

This commit is contained in:
Sergey Dudoladov 2019-02-27 13:07:48 +01:00
commit 9d430fc141
101 changed files with 1025 additions and 370 deletions

4
.gitignore vendored
View File

@ -30,3 +30,7 @@ _testmain.go
.idea .idea
scm-source.json scm-source.json
# diagrams
*.aux
*.log

View File

@ -18,4 +18,5 @@ install:
- make deps - make deps
script: script:
- hack/verify-codegen.sh
- travis_wait 20 goveralls -service=travis-ci -package ./pkg/... -v - travis_wait 20 goveralls -service=travis-ci -package ./pkg/... -v

View File

@ -1,2 +1,2 @@
# global owners # global owners
* @alexeyklyukin @erthalion @zerg-junior @Jan-M @CyberDem0n @avaczi * @alexeyklyukin @erthalion @sdudoladov @Jan-M @CyberDem0n @avaczi @FxKu

View File

@ -5,7 +5,7 @@ Wanna contribute to the Postgres Operator? Yay - here is how!
## Reporting issues ## Reporting issues
If you have a question about patroni or have a problem using it, please read the`README` before filing an issue. If you have a question about patroni or have a problem using it, please read the`README` before filing an issue.
Also double check with the current issues on our [Issues Tracker](https://github.com/zalando-incubator/postgres-operator/issues). Also double check with the current issues on our [Issues Tracker](https://github.com/zalando/postgres-operator/issues).
## Contributing a pull request ## Contributing a pull request

View File

@ -44,6 +44,7 @@ clean:
rm -rf build scm-source.json rm -rf build scm-source.json
local: ${SOURCES} local: ${SOURCES}
hack/verify-codegen.sh
CGO_ENABLED=${CGO_ENABLED} go build -o build/${BINARY} $(LOCAL_BUILD_FLAGS) -ldflags "$(LDFLAGS)" $^ CGO_ENABLED=${CGO_ENABLED} go build -o build/${BINARY} $(LOCAL_BUILD_FLAGS) -ldflags "$(LDFLAGS)" $^
linux: ${SOURCES} linux: ${SOURCES}
@ -88,4 +89,5 @@ deps:
@glide install --strip-vendor @glide install --strip-vendor
test: test:
hack/verify-codegen.sh
@go test ./... @go test ./...

View File

@ -1,10 +1,16 @@
# Postgres Operator # Postgres Operator
[![Build Status](https://travis-ci.org/zalando-incubator/postgres-operator.svg?branch=master)](https://travis-ci.org/zalando-incubator/postgres-operator) [![Build Status](https://travis-ci.org/zalando/postgres-operator.svg?branch=master)](https://travis-ci.org/zalando/postgres-operator)
[![Coverage Status](https://coveralls.io/repos/github/zalando-incubator/postgres-operator/badge.svg)](https://coveralls.io/github/zalando-incubator/postgres-operator) [![Coverage Status](https://coveralls.io/repos/github/zalando/postgres-operator/badge.svg)](https://coveralls.io/github/zalando/postgres-operator)
[![Go Report Card](https://goreportcard.com/badge/github.com/zalando-incubator/postgres-operator)](https://goreportcard.com/report/github.com/zalando-incubator/postgres-operator) [![Go Report Card](https://goreportcard.com/badge/github.com/zalando/postgres-operator)](https://goreportcard.com/report/github.com/zalando/postgres-operator)
[![GoDoc](https://godoc.org/github.com/zalando-incubator/postgres-operator?status.svg)](https://godoc.org/github.com/zalando-incubator/postgres-operator) [![GoDoc](https://godoc.org/github.com/zalando/postgres-operator?status.svg)](https://godoc.org/github.com/zalando/postgres-operator)
[![golangci](https://golangci.com/badges/github.com/zalando-incubator/postgres-operator.svg)](https://golangci.com/r/github.com/zalando-incubator/postgres-operator) [![golangci](https://golangci.com/badges/github.com/zalando/postgres-operator.svg)](https://golangci.com/r/github.com/zalando/postgres-operator)
<img src="docs/diagrams/logo.png" width="200">
# Google Summer of Code
The Postgres Operator made it to the [Google Summer of Code 2019](https://summerofcode.withgoogle.com/)! As a brand new mentoring organization, we are now looking for our first mentees. Check [our ideas](https://github.com/zalando/postgres-operator/blob/master/docs/gsoc-2019/ideas.md#google-summer-of-code-2019) and start discussion in [the issue tracker](https://github.com/zalando/postgres-operator/issues). And don't forget to spread a word about our GSoC participation to attract even more students.
## Introduction ## Introduction
@ -28,8 +34,22 @@ manages PostgreSQL clusters on Kubernetes:
3. Finally, the operator periodically synchronizes the actual state of each 3. Finally, the operator periodically synchronizes the actual state of each
Postgres cluster with the desired state defined in the cluster's manifest. Postgres cluster with the desired state defined in the cluster's manifest.
There is a browser-friendly version of this documentation at Here is a diagram, that summarizes what would be created by the operator, when a
[postgres-operator.readthedocs.io](https://postgres-operator.readthedocs.io) new Postgres cluster CRD was submitted:
![postgresql-operator](docs/diagrams/operator.png "K8S resources, created by operator")
This picture is not complete without an overview of what is inside a pod, so
let's zoom in:
![pod](docs/diagrams/pod.png "Database pod components")
These two diagrams should help you to understand the basics of what kind of
functionality the operator provides. Below we discuss all everything in more
details.
There is a browser-friendly version of this documentation at [postgres-operator.readthedocs.io](https://postgres-operator.readthedocs.io)
## Table of contents ## Table of contents
@ -43,6 +63,13 @@ There is a browser-friendly version of this documentation at
the rest of the document is a tutorial to get you up and running with the operator on Minikube. the rest of the document is a tutorial to get you up and running with the operator on Minikube.
## Community
There are two places to get in touch with the community:
1. The [GitHub issue tracker](https://github.com/zalando/postgres-operator/issues)
2. The #postgres-operator slack channel under [Postgres Slack](https://postgres-slack.herokuapp.com)
## Quickstart ## Quickstart
Prerequisites: Prerequisites:
@ -58,7 +85,7 @@ built-in Kubernetes support.
### Local execution ### Local execution
```bash ```bash
git clone https://github.com/zalando-incubator/postgres-operator.git git clone https://github.com/zalando/postgres-operator.git
cd postgres-operator cd postgres-operator
minikube start minikube start

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
set -e -x set -e -x
team_repo="$GOPATH/src/github.com/zalando-incubator/" team_repo="$GOPATH/src/github.com/zalando/"
project_dir="$team_repo/postgres-operator" project_dir="$team_repo/postgres-operator"
mkdir -p "$team_repo" mkdir -p "$team_repo"

View File

@ -9,9 +9,9 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/zalando-incubator/postgres-operator/pkg/controller" "github.com/zalando/postgres-operator/pkg/controller"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
) )
var ( var (
@ -47,14 +47,14 @@ func init() {
log.Printf("Fully qualified configmap name: %v", config.ConfigMapName) log.Printf("Fully qualified configmap name: %v", config.ConfigMapName)
} }
if crd_interval := os.Getenv("CRD_READY_WAIT_INTERVAL"); crd_interval != "" { if crdInterval := os.Getenv("CRD_READY_WAIT_INTERVAL"); crdInterval != "" {
config.CRDReadyWaitInterval = mustParseDuration(crd_interval) config.CRDReadyWaitInterval = mustParseDuration(crdInterval)
} else { } else {
config.CRDReadyWaitInterval = 4 * time.Second config.CRDReadyWaitInterval = 4 * time.Second
} }
if crd_timeout := os.Getenv("CRD_READY_WAIT_TIMEOUT"); crd_timeout != "" { if crdTimeout := os.Getenv("CRD_READY_WAIT_TIMEOUT"); crdTimeout != "" {
config.CRDReadyWaitTimeout = mustParseDuration(crd_timeout) config.CRDReadyWaitTimeout = mustParseDuration(crdTimeout)
} else { } else {
config.CRDReadyWaitTimeout = 30 * time.Second config.CRDReadyWaitTimeout = 30 * time.Second
} }

View File

@ -4,7 +4,7 @@ pipeline:
type: script type: script
env: env:
GOPATH: /root/go GOPATH: /root/go
OPERATOR_TOP_DIR: /root/go/src/github.com/zalando-incubator OPERATOR_TOP_DIR: /root/go/src/github.com/zalando
commands: commands:
- desc: 'Update' - desc: 'Update'
cmd: | cmd: |
@ -20,9 +20,6 @@ pipeline:
mv go /usr/local mv go /usr/local
ln -s /usr/local/go/bin/go /usr/bin/go ln -s /usr/local/go/bin/go /usr/bin/go
go version go version
- desc: 'Install Docker'
cmd: |
curl -fLOsS https://delivery.cloud.zalando.com/utils/ensure-docker && sh ensure-docker && rm ensure-docker
- desc: 'Symlink sources into the GOPATH' - desc: 'Symlink sources into the GOPATH'
cmd: | cmd: |
mkdir -p $OPERATOR_TOP_DIR mkdir -p $OPERATOR_TOP_DIR

View File

@ -1,6 +1,6 @@
## Create ConfigMap ## Create ConfigMap
ConfigMap is used to store the configuration of the operator A ConfigMap is used to store the configuration of the operator.
```bash ```bash
$ kubectl create -f manifests/configmap.yaml $ kubectl create -f manifests/configmap.yaml
@ -46,7 +46,9 @@ manifests:
All subsequent `kubectl` commands will work with the `test` namespace. The All subsequent `kubectl` commands will work with the `test` namespace. The
operator will run in this namespace and look up needed resources - such as its operator will run in this namespace and look up needed resources - such as its
config map - there. Please note that the namespace for service accounts and cluster role bindings in [operator RBAC rules](manifests/operator-service-account-rbac.yaml) needs to be adjusted to the non-default value. ConfigMap - there. Please note that the namespace for service accounts and
cluster role bindings in [operator RBAC rules](../manifests/operator-service-account-rbac.yaml)
needs to be adjusted to the non-default value.
## Specify the namespace to watch ## Specify the namespace to watch
@ -56,8 +58,10 @@ replicas to 5" and reacting to the requests, in this example by actually
scaling up. scaling up.
By default, the operator watches the namespace it is deployed to. You can By default, the operator watches the namespace it is deployed to. You can
change this by altering the `WATCHED_NAMESPACE` env var in the operator change this by setting the `WATCHED_NAMESPACE` var in the `env` section of the
deployment manifest or the `watched_namespace` field in the operator configmap. [operator deployment](../manifests/postgres-operator.yaml) manifest or by
altering the `watched_namespace` field in the operator
[ConfigMap](../manifests/configmap.yaml#L6).
In the case both are set, the env var takes the precedence. To make the In the case both are set, the env var takes the precedence. To make the
operator listen to all namespaces, explicitly set the field/env var to "`*`". operator listen to all namespaces, explicitly set the field/env var to "`*`".
@ -75,7 +79,7 @@ in the case database pods need to talk to the Kubernetes API (e.g. when using
Kubernetes-native configuration of Patroni). The operator checks that the Kubernetes-native configuration of Patroni). The operator checks that the
`pod_service_account_name` exists in the target namespace, and, if not, deploys `pod_service_account_name` exists in the target namespace, and, if not, deploys
there the `pod_service_account_definition` from the operator there the `pod_service_account_definition` from the operator
[`Config`](pkg/util/config/config.go) with the default value of: [`Config`](../pkg/util/config/config.go) with the default value of:
```yaml ```yaml
apiVersion: v1 apiVersion: v1
@ -86,13 +90,13 @@ metadata:
In this definition, the operator overwrites the account's name to match In this definition, the operator overwrites the account's name to match
`pod_service_account_name` and the `default` namespace to match the target `pod_service_account_name` and the `default` namespace to match the target
namespace. The operator performs **no** further syncing of this account. namespace. The operator performs **no** further syncing of this account.
## Role-based access control for the operator ## Role-based access control for the operator
The `manifests/operator-service-account-rbac.yaml` defines cluster roles and bindings needed The `manifests/operator-service-account-rbac.yaml` defines cluster roles and
for the operator to function under access control restrictions. To deploy the bindings needed for the operator to function under access control restrictions.
operator with this RBAC policy use: To deploy the operator with this RBAC policy use:
```bash ```bash
$ kubectl create -f manifests/configmap.yaml $ kubectl create -f manifests/configmap.yaml
@ -103,18 +107,18 @@ operator with this RBAC policy use:
Note that the service account in `operator-rbac.yaml` is named Note that the service account in `operator-rbac.yaml` is named
`zalando-postgres-operator`. You may have to change the `service_account_name` `zalando-postgres-operator`. You may have to change the `service_account_name`
in the operator configmap and `serviceAccountName` in the postgres-operator in the operator ConfigMap and `serviceAccountName` in the postgres-operator
deployment appropriately. deployment appropriately.
This is done intentionally, as to avoid breaking those setups that already work This is done intentionally to avoid breaking those setups that already work
with the default `operator` account. In the future the operator should ideally with the default `operator` account. In the future the operator should ideally
be run under the `zalando-postgres-operator` service account. be run under the `zalando-postgres-operator` service account.
The service account defined in `operator-rbac.yaml` acquires some privileges The service account defined in `operator-rbac.yaml` acquires some privileges
not really used by the operator (i.e. we only need list and watch on not really used by the operator (i.e. we only need `list` and `watch` on
configmaps), this is also done intentionally to avoid breaking things if `configmaps` resources), this is also done intentionally to avoid breaking
someone decides to configure the same service account in the operator's things if someone decides to configure the same service account in the
configmap to run postgres clusters. operator's ConfigMap to run postgres clusters.
### Use taints and tolerations for dedicated PostgreSQL nodes ### Use taints and tolerations for dedicated PostgreSQL nodes
@ -142,14 +146,101 @@ data:
... ...
``` ```
Note that the Kubernetes version 1.13 brings [taint-based eviction](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions) to the beta stage and enables it by default.
Postgres pods by default receive tolerations for `unreachable` and `noExecute` taints with the timeout of `5m`.
Depending on your setup, you may want to adjust these parameters to prevent master pods from being evicted by the Kubernetes runtime.
To prevent eviction completely, specify the toleration by leaving out the `tolerationSeconds` value (similar to how Kubernetes' own DaemonSets are configured)
### Enable pod anti affinity
To ensure Postgres pods are running on different topologies, you can use [pod anti affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/)
and configure the required topology in the operator ConfigMap.
Enable pod anti affinity by adding following line to the operator ConfigMap:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-operator
data:
enable_pod_antiaffinity: "true"
```
By default the topology key for the pod anti affinity is set to `kubernetes.io/hostname`,
you can set another topology key e.g. `failure-domain.beta.kubernetes.io/zone` by adding following line
to the operator ConfigMap, see [built-in node labels](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#interlude-built-in-node-labels) for available topology keys:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-operator
data:
enable_pod_antiaffinity: "true"
pod_antiaffinity_topology_key: "failure-domain.beta.kubernetes.io/zone"
```
### Add cluster-specific labels
In some cases, you might want to add `labels` that are specific to a given
postgres cluster, in order to identify its child objects.
The typical use case is to add labels that identifies the `Pods` created by the
operator, in order to implement fine-controlled `NetworkPolicies`.
**OperatorConfiguration**
```yaml
apiVersion: "acid.zalan.do/v1"
kind: OperatorConfiguration
metadata:
name: postgresql-operator-configuration
configuration:
kubernetes:
inherited_labels:
- application
- environment
...
```
**cluster manifest**
```yaml
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: demo-cluster
labels:
application: my-app
environment: demo
spec:
...
```
**network policy**
```yaml
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: netpol-example
spec:
podSelector:
matchLabels:
application: my-app
environment: demo
...
```
## Custom Pod Environment Variables ## Custom Pod Environment Variables
It is possible to configure a config map which is used by the Postgres pods as It is possible to configure a ConfigMap which is used by the Postgres pods as
an additional provider for environment variables. an additional provider for environment variables.
One use case is to customize the Spilo image and configure it with environment One use case is to customize the Spilo image and configure it with environment
variables. The config map with the additional settings is configured in the variables. The ConfigMap with the additional settings is configured in the
operator's main config map: operator's main ConfigMap:
**postgres-operator ConfigMap** **postgres-operator ConfigMap**
@ -186,12 +277,12 @@ instances permitted by each Postgres cluster managed by the operator. If either
`min_instances` or `max_instances` is set to a non-zero value, the operator may `min_instances` or `max_instances` is set to a non-zero value, the operator may
adjust the number of instances specified in the cluster manifest to match adjust the number of instances specified in the cluster manifest to match
either the min or the max boundary. For instance, of a cluster manifest has 1 either the min or the max boundary. For instance, of a cluster manifest has 1
instance and the min_instances is set to 3, the cluster will be created with 3 instance and the `min_instances` is set to 3, the cluster will be created with 3
instances. By default, both parameters are set to -1. instances. By default, both parameters are set to `-1`.
## Load balancers ## Load balancers
For any Postgresql/Spilo cluster, the operator creates two separate k8s For any Postgresql/Spilo cluster, the operator creates two separate Kubernetes
services: one for the master pod and one for replica pods. To expose these services: one for the master pod and one for replica pods. To expose these
services to an outer network, one can attach load balancers to them by setting services to an outer network, one can attach load balancers to them by setting
`enableMasterLoadBalancer` and/or `enableReplicaLoadBalancer` to `true` in the `enableMasterLoadBalancer` and/or `enableReplicaLoadBalancer` to `true` in the
@ -200,28 +291,41 @@ manifest, the operator configmap's settings `enable_master_load_balancer` and
`enable_replica_load_balancer` apply. Note that the operator settings affect `enable_replica_load_balancer` apply. Note that the operator settings affect
all Postgresql services running in all namespaces watched by the operator. all Postgresql services running in all namespaces watched by the operator.
To limit the range of IP adresses that can reach a load balancer, specify desired ranges in the `allowedSourceRanges` field (applies to both master and replica LBs). To prevent exposing LBs to the entire Internet, this field is set at cluster creation time to `127.0.0.1/32` unless overwritten explicitly. If you want to revoke all IP ranges from an existing cluster, please set the `allowedSourceRanges` field to `127.0.0.1/32` or to the empty sequence `[]`. Setting the field to `null` or omitting entirely may lead to k8s removing this field from the manifest due to [the k8s handling of null fields](https://kubernetes.io/docs/concepts/overview/object-management-kubectl/declarative-config/#how-apply-calculates-differences-and-merges-changes). Then the resultant manifest will not have the necessary change, and the operator will respectively do noting with the existing source ranges. To limit the range of IP adresses that can reach a load balancer, specify the
desired ranges in the `allowedSourceRanges` field (applies to both master and
replica load balancers). To prevent exposing load balancers to the entire
Internet, this field is set at cluster creation time to `127.0.0.1/32` unless
overwritten explicitly. If you want to revoke all IP ranges from an existing
cluster, please set the `allowedSourceRanges` field to `127.0.0.1/32` or to an
empty sequence `[]`. Setting the field to `null` or omitting it entirely may
lead to Kubernetes removing this field from the manifest due to its
[handling of null fields](https://kubernetes.io/docs/concepts/overview/object-management-kubectl/declarative-config/#how-apply-calculates-differences-and-merges-changes).
Then the resultant manifest will not contain the necessary change, and the
operator will respectively do noting with the existing source ranges.
## Running periodic 'autorepair' scans of Kubernetes objects ## Running periodic 'autorepair' scans of Kubernetes objects
The Postgres operator periodically scans all Kubernetes objects belonging to The Postgres operator periodically scans all Kubernetes objects belonging to
each cluster and repairs all discrepancies between them and the definitions each cluster and repairs all discrepancies between them and the definitions
generated from the current cluster manifest. There are two types of scans: a generated from the current cluster manifest. There are two types of scans:
`sync scan`, running every `resync_period` seconds for every cluster, and the
`repair scan`, coming every `repair_period` only for those clusters that didn't * `sync scan`, running every `resync_period` seconds for every cluster
report success as a result of the last operation applied to them.
* `repair scan`, coming every `repair_period` only for those clusters that didn't
report success as a result of the last operation applied to them.
## Postgres roles supported by the operator ## Postgres roles supported by the operator
The operator is capable of maintaining roles of multiple kinds within a Postgres database cluster: The operator is capable of maintaining roles of multiple kinds within a
Postgres database cluster:
1. **System roles** are roles necessary for the proper work of Postgres itself such as a replication role or the initial superuser role. The operator delegates creating such roles to Patroni and only establishes relevant secrets. * **System roles** are roles necessary for the proper work of Postgres itself such as a replication role or the initial superuser role. The operator delegates creating such roles to Patroni and only establishes relevant secrets.
2. **Infrastructure roles** are roles for processes originating from external systems, e.g. monitoring robots. The operator creates such roles in all PG clusters it manages assuming k8s secrets with the relevant credentials exist beforehand. * **Infrastructure roles** are roles for processes originating from external systems, e.g. monitoring robots. The operator creates such roles in all Postgres clusters it manages assuming that Kubernetes secrets with the relevant credentials exist beforehand.
3. **Per-cluster robot users** are also roles for processes originating from external systems but defined for an individual Postgres cluster in its manifest. A typical example is a role for connections from an application that uses the database. * **Per-cluster robot users** are also roles for processes originating from external systems but defined for an individual Postgres cluster in its manifest. A typical example is a role for connections from an application that uses the database.
4. **Human users** originate from the Teams API that returns list of the team members given a team id. Operator differentiates between (a) product teams that own a particular Postgres cluster and are granted admin rights to maintain it, and (b) Postgres superuser teams that get the superuser access to all PG databases running in a k8s cluster for the purposes of maintaining and troubleshooting. * **Human users** originate from the Teams API that returns a list of the team members given a team id. The operator differentiates between (a) product teams that own a particular Postgres cluster and are granted admin rights to maintain it, and (b) Postgres superuser teams that get the superuser access to all Postgres databases running in a Kubernetes cluster for the purposes of maintaining and troubleshooting.
## Understanding rolling update of Spilo pods ## Understanding rolling update of Spilo pods

View File

@ -93,14 +93,14 @@ would create a directory for the GOPATH (i.e. ~/go) and place the source code
under the ~/go/src subdirectories. under the ~/go/src subdirectories.
Given the schema above, the postgres operator source code located at Given the schema above, the postgres operator source code located at
`github.com/zalando-incubator/postgres-operator` should be put at `github.com/zalando/postgres-operator` should be put at
-`~/go/src/github.com/zalando-incubator/postgres-operator`. -`~/go/src/github.com/zalando/postgres-operator`.
```bash ```bash
$ export GOPATH=~/go $ export GOPATH=~/go
$ mkdir -p ${GOPATH}/src/github.com/zalando-incubator/ $ mkdir -p ${GOPATH}/src/github.com/zalando/
$ cd ${GOPATH}/src/github.com/zalando-incubator/ $ cd ${GOPATH}/src/github.com/zalando/
$ git clone https://github.com/zalando-incubator/postgres-operator.git $ git clone https://github.com/zalando/postgres-operator.git
``` ```
## Building the operator ## Building the operator
@ -157,7 +157,7 @@ The operator employs k8s-provided code generation to obtain deep copy methods an
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)` 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)`
References for code generation are: References for code generation are:
* [Relevant pull request](https://github.com/zalando-incubator/postgres-operator/pull/369) * [Relevant pull request](https://github.com/zalando/postgres-operator/pull/369)
See comments there for minor issues that can sometimes broke the generation process. See comments there for minor issues that can sometimes broke the generation process.
* [Code generator source code](https://github.com/kubernetes/code-generator) * [Code generator source code](https://github.com/kubernetes/code-generator)
* [Code Generation for CustomResources](https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/) - intro post on the topic * [Code Generation for CustomResources](https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/) - intro post on the topic
@ -188,13 +188,13 @@ defaults to 4)
* /workers/$id/logs - log of the operations performed by a given worker * /workers/$id/logs - log of the operations performed by a given worker
* /clusters/ - list of teams and clusters known to the operator * /clusters/ - list of teams and clusters known to the operator
* /clusters/$team - list of clusters for the given team * /clusters/$team - list of clusters for the given team
* /cluster/$team/$clustername - detailed status of the cluster, including the * /clusters/$team/$namespace/$clustername - detailed status of the cluster, including the
specifications for CRD, master and replica services, endpoints and specifications for CRD, master and replica services, endpoints and
statefulsets, as well as any errors and the worker that cluster is assigned statefulsets, as well as any errors and the worker that cluster is assigned
to. to.
* /cluster/$team/$clustername/logs/ - logs of all operations performed to the * /clusters/$team/$namespace/$clustername/logs/ - logs of all operations performed to the
cluster so far. cluster so far.
* /cluster/$team/$clustername/history/ - history of cluster changes triggered * /clusters/$team/$namespace/$clustername/history/ - history of cluster changes triggered
by the changes of the manifest (shows the somewhat obscure diff and what by the changes of the manifest (shows the somewhat obscure diff and what
exactly has triggered the change) exactly has triggered the change)

11
docs/diagrams/Makefile Normal file
View File

@ -0,0 +1,11 @@
OBJ=$(patsubst %.tex, %.png, $(wildcard *.tex))
.PHONY: all
all: $(OBJ)
%.pdf: %.tex
lualatex $< -shell-escape $@
%.png: %.pdf
convert -flatten -density 300 $< -quality 90 $@

BIN
docs/diagrams/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
docs/diagrams/operator.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

101
docs/diagrams/operator.tex Normal file
View File

@ -0,0 +1,101 @@
\documentclass{article}
\usepackage{tikz}
\usepackage[graphics,tightpage,active]{preview}
\usetikzlibrary{arrows, shadows.blur, positioning, fit, calc, backgrounds}
\usepackage{lscape}
\pagenumbering{gobble}
\PreviewEnvironment{tikzpicture}
\PreviewEnvironment{equation}
\PreviewEnvironment{equation*}
\newlength{\imagewidth}
\newlength{\imagescale}
\pagestyle{empty}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[
scale=0.5,transform shape,
font=\sffamily,
every matrix/.style={ampersand replacement=\&,column sep=2cm,row sep=2cm},
operator/.style={draw,solid,thick,circle,fill=red!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
component/.style={draw,solid,thick,rounded corners,fill=yellow!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
border/.style={draw,dashed,rounded corners,fill=gray!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
pod/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
service/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
endpoint/.style={draw,solid,thick,rounded corners,fill=blue!20, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
secret/.style={draw,solid,thick,rounded corners,fill=blue!20, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
pvc/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
label/.style={rectangle,inner sep=0,outer sep=0},
to/.style={->,>=stealth',shorten >=1pt,semithick,font=\sffamily\footnotesize},
every node/.style={align=center}]
% Position the nodes using a matrix layout
\matrix{
\& \node[component] (crd) {CRD}; \\
\& \node[operator] (operator) {Operator}; \\
\path
node[service] (service-master) {Master}
node[label, right of=service-master] (service-middle) {}
node[label, below of=service-middle] (services-label) {Services}
node[service, right=.5cm of service-master] (service-replica) {Replica}
node[border, behind path,
fit=(service-master)(service-replica)(services-label)
] (services) {};
\&
\node[component] (sts) {Statefulset}; \& \node[component] (pdb) {Pod Disruption Budget}; \\
\path
node[service] (master-endpoint) {Master}
node[service, right=.5cm of master-endpoint] (replica-endpoint) {Replica}
node[label, right of=master-endpoint] (endpoint-middle) {}
node[label, below of=endpoint-middle] (endpoint-label) {Endpoints}
node[border, behind path,
fit=(master-endpoint)(replica-endpoint)(endpoint-label)
] (endpoints) {}; \&
\node[component] (pod-template) {Pod Template}; \&
\node[border] (secrets) {
\begin{tikzpicture}[]
\node[secret] (users-secret) at (0, 0) {Users};
\node[secret] (robots-secret) at (2, 0) {Robots};
\node[secret] (standby-secret) at (4, 0) {Standby};
\end{tikzpicture} \\
Secrets
}; \\ \&
\path
node[pod] (replica1-pod) {Replica}
node[pod, left=.5cm of replica1-pod] (master-pod) {Master}
node[pod, right=.5cm of replica1-pod] (replica2-pod) {Replica}
node[label, below of=replica1-pod] (pod-label) {Pods}
node[border, behind path,
fit=(master-pod)(replica1-pod)(replica2-pod)(pod-label)
] (pods) {}; \\ \&
\path
node[pvc] (replica1-pvc) {Replica}
node[pvc, left=.5cm of replica1-pvc] (master-pvc) {Master}
node[pvc, right=.5cm of replica1-pvc] (replica2-pvc) {Replica}
node[label, below of=replica1-pvc] (pvc-label) {Persistent Volume Claims}
node[border, behind path,
fit=(master-pvc)(replica1-pvc)(replica2-pvc)(pvc-label)
] (pvcs) {}; \&
\\ \& \\
};
% Draw the arrows between the nodes and label them.
\draw[to] (crd) -- node[midway,above] {} node[midway,below] {} (operator);
\draw[to] (operator) -- node[midway,above] {} node[midway,below] {} (sts);
\draw[to] (operator) -- node[midway,above] {} node[midway,below] {} (secrets);
\draw[to] (operator) -| node[midway,above] {} node[midway,below] {} (pdb);
\draw[to] (service-master) -- node[midway,above] {} node[midway,below] {} (master-endpoint);
\draw[to] (service-replica) -- node[midway,above] {} node[midway,below] {} (replica-endpoint);
\draw[to] (master-pod) -- node[midway,above] {} node[midway,below] {} (master-pvc);
\draw[to] (replica1-pod) -- node[midway,above] {} node[midway,below] {} (replica1-pvc);
\draw[to] (replica2-pod) -- node[midway,above] {} node[midway,below] {} (replica2-pvc);
\draw[to] (operator) -| node[midway,above] {} node[midway,below] {} (services);
\draw[to] (sts) -- node[midway,above] {} node[midway,below] {} (pod-template);
\draw[to] (pod-template) -- node[midway,above] {} node[midway,below] {} (pods);
\end{tikzpicture}
\end{center}
\end{document}

BIN
docs/diagrams/pod.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

92
docs/diagrams/pod.tex Normal file
View File

@ -0,0 +1,92 @@
\documentclass{article}
\usepackage{tikz}
\usepackage[graphics,tightpage,active]{preview}
\usetikzlibrary{arrows, shadows.blur, positioning, fit, calc, backgrounds}
\usepackage{lscape}
\pagenumbering{gobble}
\PreviewEnvironment{tikzpicture}
\PreviewEnvironment{equation}
\PreviewEnvironment{equation*}
\newlength{\imagewidth}
\newlength{\imagescale}
\pagestyle{empty}
\thispagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[
scale=0.5,transform shape,
font=\sffamily,
every matrix/.style={ampersand replacement=\&,column sep=2cm,row sep=2cm},
pod/.style={draw,solid,thick,circle,fill=red!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
component/.style={draw,solid,thick,rounded corners,fill=yellow!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
border/.style={draw,dashed,rounded corners,fill=gray!20,inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
volume/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
sidecar/.style={draw,solid,thick,rounded corners,fill=blue!20, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
k8s-label/.style={draw,solid,thick,rounded corners,fill=blue!20, minimum width=1.5cm, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
affinity/.style={draw,solid,thick,rounded corners,fill=blue!20, minimum width=2cm, inner sep=.3cm, blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt}},
label/.style={rectangle,inner sep=0,outer sep=0},
to/.style={->,>=stealth',shorten >=1pt,semithick,font=\sffamily\footnotesize},
every node/.style={align=center}]
% Position the nodes using a matrix layout
\matrix{
\path
node[k8s-label] (app-label) {App}
node[k8s-label, right=.25cm of app-label] (role-label) {Role}
node[k8s-label, right=.25cm of role-label] (custom-label) {Custom}
node[label, below of=role-label] (k8s-label-label) {K8S Labels}
node[border, behind path,
fit=(app-label)(role-label)(custom-label)(k8s-label-label)
] (k8s-labels) {}; \& \&
\path
node[affinity] (affinity) {Affinity}
node[label, right=.25cm of affinity] (affinity-middle) {}
node[affinity, right=.25cm of affinity-middle] (anti-affinity) {Anti-affinity}
node[label, below of=affinity-middle] (affinity-label) {Assigning to nodes}
node[border, behind path,
fit=(affinity)(anti-affinity)(affinity-label)
] (affinity) {}; \\
\& \node[pod] (pod) {Pod}; \& \\
\path
node[volume, minimum width={width("shm-volume")}] (data-volume) {Data}
node[volume, right=.25cm of data-volume, minimum width={width("shm-volume")}] (tokens-volume) {Tokens}
node[volume, right=.25cm of tokens-volume] (shm-volume) {/dev/shm}
node[label, below of=tokens-volume] (volumes-label) {Volumes}
node[border, behind path,
fit=(data-volume)(shm-volume)(tokens-volume)(volumes-label)
] (volumes) {}; \&
\node[component] (spilo) {Spilo}; \&
\node[sidecar] (scalyr) {Scalyr}; \& \\ \&
\path
node[component] (patroni) {Patroni}
node[component, below=.25cm of patroni] (postgres) {PostgreSQL}
node[border, behind path,
fit=(postgres)(patroni)
] (spilo-components) {}; \&
\path
node[sidecar] (custom-sidecar1) {User defined}
node[label, right=.25cm of custom-sidecar1] (sidecars-middle) {}
node[sidecar, right=.25cm of sidecars-middle] (custom-sidecar2) {User defined}
node[label, below of=sidecars-middle] (sidecars-label) {Custom sidecars}
node[border, behind path,
fit=(custom-sidecar1)(custom-sidecar2)(sidecars-label)
] (sidecars) {};
\\ \& \\
};
% Draw the arrows between the nodes and label them.
\draw[to] (pod) to [bend left=25] (volumes);
\draw[to] (pod) to [bend left=25] (k8s-labels);
\draw[to] (pod) to [bend right=25] (affinity);
\draw[to] (pod) to [bend right=25] (scalyr);
\draw[to] (pod) to [bend right=25] (sidecars);
\draw[to] (pod) -- node[midway,above] {} node[midway,below] {} (spilo);
\draw[to] (spilo) -- node[midway,above] {} node[midway,below] {} (spilo-components);
\end{tikzpicture}
\end{center}
\end{document}

64
docs/gsoc-2019/ideas.md Normal file
View File

@ -0,0 +1,64 @@
# Google Summer of Code 2019
## Applications steps
1. Please carefully read the official [Google Summer of Code Student Guide](https://google.github.io/gsocguides/student/)
2. Join the #postgres-operator slack channel under [Postgres Slack](https://postgres-slack.herokuapp.com) to introduce yourself to the community and get quick feedback on your application.
3. Select a project from the list of ideas below or propose your own.
4. Write a proposal draft. Please open an issue with the label `gsoc2019_application` in the [operator repository](https://github.com/zalando/postgres-operator/issues) so that the community members can publicly review it. See proposal instructions below for details.
5. Submit proposal and the proof of enrollment before April 9 2019 18:00 UTC through the web site of the Program.
## Project ideas
### Place database pods into the "Guaranteed" Quality-of-Service class
* **Description**: Kubernetes runtime does not kill pods in this class on condition they stay within their resource limits, which is desirable for the DB pods serving production workloads. To be assigned to that class, pod's resources must equal its limits. The task is to add the `enableGuaranteedQoSClass` or the like option to the Postgres manifest and the operator configmap that forcibly re-write pod resources to match the limits.
* **Recommended skills**: golang, basic Kubernetes abstractions
* **Difficulty**: moderate
* **Mentor(s)**: Felix Kunde [@FxKu](https://github.com/fxku), Sergey Dudoladov [@sdudoladov](https://github.com/sdudoladov)
### Implement the kubectl plugin for the Postgres CustomResourceDefinition
* **Description**: [kubectl plugins](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/) enable extending the Kubernetes command-line client `kubectl` with commands to manage custom resources. The task is to design and implement a plugin for the `kubectl postgres` command,
that can enable, for example, correct deletion or major version upgrade of Postgres clusters.
* **Recommended skills**: golang, shell scripting, operational experience with Kubernetes
* **Difficulty**: moderate to medium, depending on the plugin design
* **Mentor(s)**: Felix Kunde [@FxKu](https://github.com/fxku), Sergey Dudoladov [@sdudoladov](https://github.com/sdudoladov)
### Implement the openAPIV3Schema for the Postgres CRD
* **Description**: at present the operator validates a database manifest on its own.
It will be helpful to reject erroneous manifests before they reach the operator using the [native Kubernetes CRD validation](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation). It is up to the student to decide whether to write the schema manually or to adopt existing [schema generator developed for the Prometheus project](https://github.com/ant31/crd-validation).
* **Recommended skills**: golang, JSON schema
* **Difficulty**: medium
* **Mentor(s)**: Sergey Dudoladov [@sdudoladov](https://github.com/sdudoladov)
* **Issue**: [#388](https://github.com/zalando/postgres-operator/issues/388)
### Design a solution for the local testing of the operator
* **Description**: The current way of testing is to run minikube, either manually or with some tooling around it like `/run-operator_locally.sh` or Vagrant. This has at least three problems:
First, minikube is a single node cluster, so it is unsuitable for testing vital functions such as pod migration between nodes. Second, minikube starts slowly; that prolongs local testing.
Third, every contributor needs to come up with their own solution for local testing. The task is to come up with a better option which will enable us to conveniently and uniformly run e2e tests locally / potentially in Travis CI.
A promising option is the Kubernetes own [kind](https://github.com/kubernetes-sigs/kind)
* **Recommended skills**: Docker, shell scripting, basic Kubernetes abstractions
* **Difficulty**: medium to hard depending on the selected desing
* **Mentor(s)**: Dmitry Dolgov [@erthalion](https://github.com/erthalion), Sergey Dudoladov [@sdudoladov](https://github.com/sdudoladov)
* **Issue**: [#475](https://github.com/zalando/postgres-operator/issues/475)
### Detach a Postgres cluster from the operator for maintenance
* **Description**: sometimes a Postgres cluster requires manual maintenance. During such maintenance the operator should ignore all the changes manually applied to the cluster.
Currently the only way to achieve this behavior is to shutdown the operator altogether, for instance by scaling down the operator's own deployment to zero pods. That approach evidently affects all Postgres databases under the operator control and thus is highly undesirable in production Kubernetes clusters. It would be much better to be able to detach only the desired Postgres cluster from the operator for the time being and re-attach it again after maintenance.
* **Recommended skills**: golang, architecture of a Kubernetes operator
* **Difficulty**: hard - requires significant modification of the operator's internals and careful consideration of the corner cases.
* **Mentor(s)**: Dmitry Dolgov [@erthalion](https://github.com/erthalion), Sergey Dudoladov [@sdudoladov](https://github.com/sdudoladov)
* **Issue**: [#421](https://github.com/zalando/postgres-operator/issues/421)
### Propose your own idea
Feel free to come up with your own ideas. For inspiration,
see [our bug tracker](https://github.com/zalando/postgres-operator/issues),
the [official `CustomResouceDefinition` docs](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/)
and [other operators](https://github.com/operator-framework/awesome-operators).

View File

@ -8,10 +8,10 @@ manages PostgreSQL clusters on Kubernetes:
user submits a new manifest, the operator fetches that manifest and spawns 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 new Postgres cluster along with all necessary entities such as Kubernetes
StatefulSets and Postgres roles. See this StatefulSets and Postgres roles. See this
[Postgres cluster manifest](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/complete-postgres-manifest.yaml) [Postgres cluster manifest](https://github.com/zalando/postgres-operator/blob/master/manifests/complete-postgres-manifest.yaml)
for settings that a manifest may contain. for settings that a manifest may contain.
2. The operator also watches updates to [its own configuration](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/configmap.yaml) 2. The operator also watches updates to [its own configuration](https://github.com/zalando/postgres-operator/blob/master/manifests/configmap.yaml)
and alters running Postgres clusters if necessary. For instance, if a pod and alters running Postgres clusters if necessary. For instance, if a pod
docker image is changed, the operator carries out the rolling update. That 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 is, the operator re-spawns one-by-one pods of each StatefulSet it manages
@ -47,11 +47,11 @@ the operator is deployed to multiple Kubernetes clusters, where users deploy
manifests via our CI/CD infrastructure or rely on a slim user interface to manifests via our CI/CD infrastructure or rely on a slim user interface to
create manifests. create manifests.
Please, report any issues discovered to https://github.com/zalando-incubator/postgres-operator/issues. Please, report any issues discovered to https://github.com/zalando/postgres-operator/issues.
## Talks ## Talks
1. "PostgreSQL and Kubernetes: DBaaS without a vendor-lock" talk by Oleksii Kliukin, PostgreSQL Sessions 2018: [slides](https://speakerdeck.com/alexeyklyukin/postgresql-and-kubernetes-dbaas-without-a-vendor-lock) 1. "PostgreSQL and Kubernetes: DBaaS without a vendor-lock" talk by Oleksii Kliukin, PostgreSQL Sessions 2018: [video](https://www.youtube.com/watch?v=q26U2rQcqMw) | [slides](https://speakerdeck.com/alexeyklyukin/postgresql-and-kubernetes-dbaas-without-a-vendor-lock)
2. "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) 2. "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)

View File

@ -13,7 +13,7 @@ built-in Kubernetes support.
## Local execution ## Local execution
```bash ```bash
git clone https://github.com/zalando-incubator/postgres-operator.git git clone https://github.com/zalando/postgres-operator.git
cd postgres-operator cd postgres-operator
minikube start minikube start

View File

@ -3,9 +3,9 @@ Individual postgres clusters are described by the Kubernetes *cluster manifest*
that has the structure defined by the `postgres CRD` (custom resource that has the structure defined by the `postgres CRD` (custom resource
definition). The following section describes the structure of the manifest and definition). The following section describes the structure of the manifest and
the purpose of individual keys. You can take a look at the examples of the the purpose of individual keys. You can take a look at the examples of the
[minimal](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml) [minimal](https://github.com/zalando/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml)
and the and the
[complete](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/complete-postgres-manifest.yaml) [complete](https://github.com/zalando/postgres-operator/blob/master/manifests/complete-postgres-manifest.yaml)
cluster manifests. cluster manifests.
When Kubernetes resources, such as memory, CPU or volumes, are configured, When Kubernetes resources, such as memory, CPU or volumes, are configured,
@ -35,7 +35,15 @@ Those parameters are grouped under the `metadata` top-level key.
services, secrets) for the cluster. Changing it after the cluster creation services, secrets) for the cluster. Changing it after the cluster creation
results in deploying or updating a completely separate cluster in the target results in deploying or updating a completely separate cluster in the target
namespace. Optional (if present, should match the namespace where the namespace. Optional (if present, should match the namespace where the
manifest is applied). manifest is applied).
* **labels**
if labels are matching one of the `inherited_labels` [configured in the
operator parameters](operator_parameters.md#kubernetes-resources),
they will automatically be added to all the objects (StatefulSet, Service,
Endpoints, etc.) that are created by the operator.
Labels that are set here but not listed as `inherited_labels` in the operator
parameters are ignored.
## Top-level parameters ## Top-level parameters
@ -91,7 +99,7 @@ These parameters are grouped directly under the `spec` key in the manifest.
examples](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) examples](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
for details on tolerations and possible values of those keys. When set, this for details on tolerations and possible values of those keys. When set, this
value overrides the `pod_toleration` setting from the operator. Optional. value overrides the `pod_toleration` setting from the operator. Optional.
* **podPriorityClassName** * **podPriorityClassName**
a name of the [priority a name of the [priority
class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass) class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass)
@ -143,7 +151,7 @@ explanation of `ttl` and `loop_wait` parameters.
a map of key-value pairs describing initdb parameters. For `data-checksum`, a map of key-value pairs describing initdb parameters. For `data-checksum`,
`debug`, `no-locale`, `noclean`, `nosync` and `sync-only` parameters use `debug`, `no-locale`, `noclean`, `nosync` and `sync-only` parameters use
`true` as the value if you want to set them. Changes to this option do not `true` as the value if you want to set them. Changes to this option do not
affect the already initialized clusters. Optional. affect the already initialized clusters. Optional.
* **pg_hba** * **pg_hba**
list of custom `pg_hba` lines to replace default ones. Note that the default list of custom `pg_hba` lines to replace default ones. Note that the default
@ -223,7 +231,7 @@ under the `clone` top-level key and do not affect the already running cluster.
different namespaces) , the operator uses UID in the S3 bucket name in order different namespaces) , the operator uses UID in the S3 bucket name in order
to guarantee uniqueness. Has no effect when cloning from the running to guarantee uniqueness. Has no effect when cloning from the running
clusters. Optional. clusters. Optional.
* **timestamp** * **timestamp**
the timestamp up to which the recovery should proceed. The operator always the timestamp up to which the recovery should proceed. The operator always
configures non-inclusive recovery target, stopping right before the given configures non-inclusive recovery target, stopping right before the given
@ -243,7 +251,7 @@ properties of the persistent storage that stores postgres data.
the name of the Kubernetes storage class to draw the persistent volume from. the name of the Kubernetes storage class to draw the persistent volume from.
See [Kubernetes See [Kubernetes
documentation](https://kubernetes.io/docs/concepts/storage/storage-classes/) documentation](https://kubernetes.io/docs/concepts/storage/storage-classes/)
for the details on storage classes. Optional. for the details on storage classes. Optional.
### Sidecar definitions ### Sidecar definitions

View File

@ -8,20 +8,20 @@ configuration.
maps. String values containing ':' should be enclosed in quotes. The maps. String values containing ':' should be enclosed in quotes. The
configuration is flat, parameter group names below are not reflected in the configuration is flat, parameter group names below are not reflected in the
configuration structure. There is an configuration structure. There is an
[example](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/configmap.yaml) [example](https://github.com/zalando/postgres-operator/blob/master/manifests/configmap.yaml)
* CRD-based configuration. The configuration is stored in a custom YAML * CRD-based configuration. The configuration is stored in a custom YAML
manifest. The manifest is an instance of the custom resource definition (CRD) called manifest. The manifest is an instance of the custom resource definition (CRD) called
`OperatorConfiguration`. The operator registers this CRD `OperatorConfiguration`. The operator registers this CRD
during the start and uses it for configuration if the [operator deployment manifest ](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/postgres-operator.yaml#L21) sets the `POSTGRES_OPERATOR_CONFIGURATION_OBJECT` env variable to a non-empty value. The variable should point to the during the start and uses it for configuration if the [operator deployment manifest ](https://github.com/zalando/postgres-operator/blob/master/manifests/postgres-operator.yaml#L21) sets the `POSTGRES_OPERATOR_CONFIGURATION_OBJECT` env variable to a non-empty value. The variable should point to the
`postgresql-operator-configuration` object in the operator's namespace. `postgresql-operator-configuration` object in the operator's namespace.
The CRD-based configuration is a regular YAML The CRD-based configuration is a regular YAML
document; non-scalar keys are simply represented in the usual YAML way. document; non-scalar keys are simply represented in the usual YAML way.
There are no default values built-in in the operator, each parameter that is There are no default values built-in in the operator, each parameter that is
not supplied in the configuration receives an empty value. In order to not supplied in the configuration receives an empty value. In order to
create your own configuration just copy the [default create your own configuration just copy the [default
one](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/postgresql-operator-default-configuration.yaml) one](https://github.com/zalando/postgres-operator/blob/master/manifests/postgresql-operator-default-configuration.yaml)
and change it. and change it.
To test the CRD-based configuration locally, use the following To test the CRD-based configuration locally, use the following
@ -172,6 +172,14 @@ configuration they are grouped under the `kubernetes` key.
list of `name:value` pairs for additional labels assigned to the cluster list of `name:value` pairs for additional labels assigned to the cluster
objects. The default is `application:spilo`. objects. The default is `application:spilo`.
* **inherited_labels**
list of labels that can be inherited from the cluster manifest, and added to
each child objects (`StatefulSet`, `Pod`, `Service` and `Endpoints`) created by
the opertor.
Typical use case is to dynamically pass labels that are specific to a given
postgres cluster, in order to implement `NetworkPolicy`.
The default is empty.
* **cluster_name_label** * **cluster_name_label**
name of the label assigned to Kubernetes objects created by the operator that name of the label assigned to Kubernetes objects created by the operator that
indicates which cluster a given object belongs to. The default is indicates which cluster a given object belongs to. The default is
@ -198,13 +206,21 @@ configuration they are grouped under the `kubernetes` key.
All variables from that ConfigMap are injected to the pod's environment, on All variables from that ConfigMap are injected to the pod's environment, on
conflicts they are overridden by the environment variables generated by the conflicts they are overridden by the environment variables generated by the
operator. The default is empty. operator. The default is empty.
* **pod_priority_class_name** * **pod_priority_class_name**
a name of the [priority a name of the [priority
class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass) class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass)
that should be assigned to the Postgres pods. The priority class itself must be defined in advance. that should be assigned to the Postgres pods. The priority class itself must be defined in advance.
Default is empty (use the default priority class). Default is empty (use the default priority class).
* **enable_pod_antiaffinity**
toggles [pod anti affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/) on the Postgres pods, to avoid multiple pods
of the same Postgres cluster in the same topology , e.g. node. The default is `false`.
* **pod_antiaffinity_topology_key**
override
[topology key](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#interlude-built-in-node-labels)
for pod anti affinity. The default is `kubernetes.io/hostname`.
## Kubernetes resource requests ## Kubernetes resource requests
@ -229,7 +245,7 @@ CRD-based configuration.
settings. The default is `1Gi`. settings. The default is `1Gi`.
* **set_memory_request_to_limit** * **set_memory_request_to_limit**
Set `memory_request` to `memory_limit` for all Postgres clusters (the default value is also increased). This prevents certain cases of memory overcommitment at the cost of overprovisioning memory and potential scheduling problems for containers with high memory limits due to the lack of memory on Kubernetes cluster nodes. This affects all containers created by the operator (Postgres, Scalyr sidecar, and other sidecars); to set resources for the operator's own container, change the [operator deployment manually](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/postgres-operator.yaml#L13). The default is `false`. Set `memory_request` to `memory_limit` for all Postgres clusters (the default value is also increased). This prevents certain cases of memory overcommitment at the cost of overprovisioning memory and potential scheduling problems for containers with high memory limits due to the lack of memory on Kubernetes cluster nodes. This affects all containers created by the operator (Postgres, Scalyr sidecar, and other sidecars); to set resources for the operator's own container, change the [operator deployment manually](https://github.com/zalando/postgres-operator/blob/master/manifests/postgres-operator.yaml#L13). The default is `false`.
* **enable_shm_volume** * **enable_shm_volume**
Instruct operator to start any new database pod without limitations on shm Instruct operator to start any new database pod without limitations on shm
@ -294,6 +310,11 @@ In the CRD-based configuration they are grouped under the `load_balancer` key.
cluster. Can be overridden by individual cluster settings. The default is cluster. Can be overridden by individual cluster settings. The default is
`false`. `false`.
* **custom_service_annotations**
when load balancing is enabled, LoadBalancer service is created and
this parameter takes service annotations that are applied to service.
Optional.
* **master_dns_name_format** defines the DNS name string template for the * **master_dns_name_format** defines the DNS name string template for the
master load balancer cluster. The default is master load balancer cluster. The default is
`{cluster}.{team}.{hostedzone}`, where `{cluster}` is replaced by the cluster `{cluster}.{team}.{hostedzone}`, where `{cluster}` is replaced by the cluster
@ -308,12 +329,12 @@ In the CRD-based configuration they are grouped under the `load_balancer` key.
replaced with the hosted zone (the value of the `db_hosted_zone` parameter). replaced with the hosted zone (the value of the `db_hosted_zone` parameter).
No other placeholders are allowed. No other placeholders are allowed.
## AWS or GSC interaction ## AWS or GCP interaction
The options in this group configure operator interactions with non-Kubernetes The options in this group configure operator interactions with non-Kubernetes
objects from AWS or Google cloud. They have no effect unless you are using objects from Amazon Web Services (AWS) or Google Cloud Platform (GCP). They have no effect unless you are using
either. In the CRD-based configuration those options are grouped under the either. In the CRD-based configuration those options are grouped under the
`aws_or_gcp` key. `aws_or_gcp` key. Note the GCP integration is not yet officially supported.
* **wal_s3_bucket** * **wal_s3_bucket**
S3 bucket to use for shipping WAL segments with WAL-E. A bucket has to be S3 bucket to use for shipping WAL segments with WAL-E. A bucket has to be
@ -345,7 +366,7 @@ Options to aid debugging of the operator itself. Grouped under the `debug` key.
boolean parameter that toggles the functionality of the operator that require boolean parameter that toggles the functionality of the operator that require
access to the postgres database, i.e. creating databases and users. The default access to the postgres database, i.e. creating databases and users. The default
is `true`. is `true`.
## Automatic creation of human users in the database ## Automatic creation of human users in the database
Options to automate creation of human users with the aid of the teams API Options to automate creation of human users with the aid of the teams API
@ -461,4 +482,4 @@ scalyr sidecar. In the CRD-based configuration they are grouped under the
S3 bucket to store backup results. Default: same as the bucket as for WAL. S3 bucket to store backup results. Default: same as the bucket as for WAL.
For the configmap operator configuration, the [default parameter values](https://github.com/zalando-incubator/postgres-operator/blob/master/pkg/util/config/config.go#L14) mentioned here are likely to be overwritten in your local operator installation via your local version of the operator configmap. In the case you use the operator CRD, all the CRD defaults are provided in the [operator's default configuration manifest](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/postgresql-operator-default-configuration.yaml) For the configmap operator configuration, the [default parameter values](https://github.com/zalando-incubator/postgres-operator/blob/master/pkg/util/config/config.go#L14) mentioned here are likely to be overwritten in your local operator installation via your local version of the operator configmap. In the case you use the operator CRD, all the CRD defaults are provided in the [operator's default configuration manifest](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/postgresql-operator-default-configuration.yaml)

View File

@ -1,7 +1,7 @@
## Create a manifest for a new PostgreSQL cluster ## Create a manifest for a new PostgreSQL cluster
As an example you can take this As an example you can take this
[minimal example](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml): [minimal example](https://github.com/zalando/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml):
```yaml ```yaml
apiVersion: "acid.zalan.do/v1" apiVersion: "acid.zalan.do/v1"
@ -57,25 +57,24 @@ $ psql -U postgres
Postgres operator allows defining roles to be created in the resulting database Postgres operator allows defining roles to be created in the resulting database
cluster. It covers three use-cases: cluster. It covers three use-cases:
* create application roles specific to the cluster described in the manifest: * `manifest roles`: create application roles specific to the cluster described in the manifest.
`manifest roles`. * `infrastructure roles`: create application roles that should be automatically created on every
* create application roles that should be automatically created on every cluster managed by the operator.
cluster managed by the operator: `infrastructure roles`. * `teams API roles`: automatically create users for every member of the team owning the database
* automatically create users for every member of the team owning the database cluster.
cluster: `teams API roles`.
In the next sections, we will cover those use cases in more details. In the next sections, we will cover those use cases in more details.
## Manifest roles ## Manifest roles
Manifest roles are defined directly in the cluster manifest. See Manifest roles are defined directly in the cluster manifest. See
[minimal postgres manifest](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml) [minimal postgres manifest](https://github.com/zalando/postgres-operator/blob/master/manifests/minimal-postgres-manifest.yaml)
for an example of `zalando` role, defined with `superuser` and `createdb` for an example of `zalando` role, defined with `superuser` and `createdb`
flags. flags.
Manifest roles are defined as a dictionary, with a role name as a key and a Manifest roles are defined as a dictionary, with a role name as a key and a
list of role options as a value. For a role without any options it is best to supply the empty list of role options as a value. For a role without any options it is best to supply the empty
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`). 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`).
The operator accepts the following options: `superuser`, `inherit`, `login`, The operator accepts the following options: `superuser`, `inherit`, `login`,
`nologin`, `createrole`, `createdb`, `replication`, `bypassrls`. `nologin`, `createrole`, `createdb`, `replication`, `bypassrls`.
@ -99,10 +98,13 @@ An infrastructure role is a role that should be present on every PostgreSQL
cluster managed by the operator. An example of such a role is a monitoring cluster managed by the operator. An example of such a role is a monitoring
user. There are two ways to define them: user. There are two ways to define them:
* Exclusively via the infrastructure roles secret (specified by the * With the infrastructure roles secret only
`infrastructure_roles_secret_name` parameter). * With both the the secret and the infrastructure role ConfigMap.
The role definition looks like this (values are base64 encoded): ### Infrastructure roles secret
The infrastructure roles secret is specified by the `infrastructure_roles_secret_name`
parameter. The role definition looks like this (values are base64 encoded):
```yaml ```yaml
user1: ZGJ1c2Vy user1: ZGJ1c2Vy
@ -110,25 +112,29 @@ The role definition looks like this (values are base64 encoded):
inrole1: b3BlcmF0b3I= inrole1: b3BlcmF0b3I=
``` ```
A block above describes the infrastructure role 'dbuser' with the password The block above describes the infrastructure role 'dbuser' with password
'secret' that is the member of the 'operator' role. For the following 'secret' that is a member of the 'operator' role. For the following
definitions one must increase the index, i.e. the next role will be defined as definitions one must increase the index, i.e. the next role will be defined as
'user2' and so on. Note that there is no way to specify role options (like 'user2' and so on. The resulting role will automatically be a login role.
superuser or nologin) this way, and the resulting role will automatically be a
login role.
* Via both the infrastructure roles secret and the infrastructure role Note that with definitions that solely use the infrastructure roles secret
configmap (with the same name as the infrastructure roles secret). there is no way to specify role options (like superuser or nologin) or role
memberships. This is where the ConfigMap comes into play.
The infrastructure roles secret should contain an entry with 'rolename: ### Secret plus ConfigMap
rolepassword' for each role, and the role description should be specified in
the configmap. Below is the example: A [ConfigMap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/)
allows for defining more details regarding the infrastructure roles.
Therefore, one should use the new style that specifies infrastructure roles
using both the secret and a ConfigMap. The ConfigMap must have the same name as
the secret. The secret should contain an entry with 'rolename:rolepassword' for
each role.
```yaml ```yaml
dbuser: c2VjcmV0 dbuser: c2VjcmV0
``` ```
and the configmap definition for that user: And the role description for that user should be specified in the ConfigMap.
```yaml ```yaml
data: data:
@ -140,25 +146,20 @@ and the configmap definition for that user:
log_statement: all log_statement: all
``` ```
Note that the definition above allows for more details than the one that relies One can allow membership in multiple roles via the `inrole` array parameter,
solely on the infrastructure role secret. In particular, one can allow define role flags via the `user_flags` list and supply per-role options through
membership in multiple roles via the `inrole` array parameter, define role the `db_parameters` dictionary. All those parameters are optional.
flags via the `user_flags` list and supply per-role options through the
`db_parameters` dictionary. All those parameters are optional.
The definitions that solely use the infrastructure roles secret are more Both definitions can be mixed in the infrastructure role secret, as long as
limited and considered legacy ones; one should use the new style that specifies your new-style definition can be clearly distinguished from the old-style one
infrastructure roles using both the secret and the configmap. You can mix both (for instance, do not name new-style roles `userN`).
in the infrastructure role secret, as long as your new-style definition can be
clearly distinguished from the old-style one (for instance, do not name
new-style roles`userN`).
Since an infrastructure role is created uniformly on all clusters managed by Since an infrastructure role is created uniformly on all clusters managed by
the operator, it makes no sense to define it without the password. Such the operator, it makes no sense to define it without the password. Such
definitions will be ignored with a prior warning. definitions will be ignored with a prior warning.
See [infrastructure roles secret](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/infrastructure-roles.yaml) See [infrastructure roles secret](https://github.com/zalando/postgres-operator/blob/master/manifests/infrastructure-roles.yaml)
and [infrastructure roles configmap](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/infrastructure-roles-configmap.yaml) for the examples. and [infrastructure roles configmap](https://github.com/zalando/postgres-operator/blob/master/manifests/infrastructure-roles-configmap.yaml) for the examples.
## Use taints and tolerations for dedicated PostgreSQL nodes ## Use taints and tolerations for dedicated PostgreSQL nodes
@ -272,6 +273,32 @@ are always passed to sidecars:
The PostgreSQL volume is shared with sidecars and is mounted at `/home/postgres/pgdata`. The PostgreSQL volume is shared with sidecars and is mounted at `/home/postgres/pgdata`.
## InitContainers Support
Each cluster can specify arbitrary init containers to run. These containers can be
used to run custom actions before any normal and sidecar containers start.
An init container can be specified like this:
```yaml
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: acid-minimal-cluster
spec:
...
init_containers:
- name: "container-name"
image: "company/image:tag"
env:
- name: "ENV_VAR_NAME"
value: "any-k8s-env-things"
```
`init_containers` accepts full `v1.Container` definition.
## Increase volume size ## Increase volume size
PostgreSQL operator supports statefulset volume resize if you're using the PostgreSQL operator supports statefulset volume resize if you're using the

24
glide.lock generated
View File

@ -1,8 +1,8 @@
hash: bd5394acf101795aac9da20c104a57344a6c4fd71080bf1b16845367e6360578 hash: e4d0d48b4142d5d335e48e030621564207f3aa288ea1e41e0d1e4d29135de3e8
updated: 2018-08-14T15:18:08.144086+02:00 updated: 2019-02-25T14:54:51.736946406+01:00
imports: imports:
- name: github.com/aws/aws-sdk-go - name: github.com/aws/aws-sdk-go
version: f831d5a0822a1ad72420ab18c6269bca1ddaf490 version: e8b22c9937cae1fee9bc364a88f3752cc4d1ac2f
subpackages: subpackages:
- aws - aws
- aws/awserr - aws/awserr
@ -13,6 +13,7 @@ imports:
- aws/credentials - aws/credentials
- aws/credentials/ec2rolecreds - aws/credentials/ec2rolecreds
- aws/credentials/endpointcreds - aws/credentials/endpointcreds
- aws/credentials/processcreds
- aws/credentials/stscreds - aws/credentials/stscreds
- aws/csm - aws/csm
- aws/defaults - aws/defaults
@ -21,6 +22,7 @@ imports:
- aws/request - aws/request
- aws/session - aws/session
- aws/signer/v4 - aws/signer/v4
- internal/ini
- internal/sdkio - internal/sdkio
- internal/sdkrand - internal/sdkrand
- internal/sdkuri - internal/sdkuri
@ -43,8 +45,6 @@ imports:
- spdy - spdy
- name: github.com/ghodss/yaml - name: github.com/ghodss/yaml
version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee
- name: github.com/go-ini/ini
version: d58d458bec3cb5adec4b7ddb41131855eac0b33f
- name: github.com/gogo/protobuf - name: github.com/gogo/protobuf
version: c0656edd0d9eab7c66d1eb0c568f9039345796f7 version: c0656edd0d9eab7c66d1eb0c568f9039345796f7
subpackages: subpackages:
@ -84,6 +84,8 @@ imports:
version: c2b33e8439af944379acbdd9c3a5fe0bc44bd8a5 version: c2b33e8439af944379acbdd9c3a5fe0bc44bd8a5
- name: github.com/json-iterator/go - name: github.com/json-iterator/go
version: f2b4162afba35581b6d4a50d3b8f34e33c144682 version: f2b4162afba35581b6d4a50d3b8f34e33c144682
- name: github.com/konsorten/go-windows-terminal-sequences
version: 5c8c8bd35d3832f5d134ae1e1e375b69a4d25242
- name: github.com/kr/text - name: github.com/kr/text
version: e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f version: e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f
- name: github.com/lib/pq - name: github.com/lib/pq
@ -101,12 +103,14 @@ imports:
- name: github.com/peterbourgon/diskv - name: github.com/peterbourgon/diskv
version: 5f041e8faa004a95c88a202771f4cc3e991971e6 version: 5f041e8faa004a95c88a202771f4cc3e991971e6
- name: github.com/sirupsen/logrus - name: github.com/sirupsen/logrus
version: 3e01752db0189b9157070a0e1668a620f9a85da2 version: e1e72e9de974bd926e5c56f83753fba2df402ce5
- name: github.com/spf13/pflag - name: github.com/spf13/pflag
version: 583c0c0531f06d5278b7d917446061adc344b5cd version: 583c0c0531f06d5278b7d917446061adc344b5cd
- name: golang.org/x/crypto - name: golang.org/x/crypto
version: c126467f60eb25f8f27e5a981f32a87e3965053f version: 49796115aa4b964c318aad4f3084fdb41e9aa067
subpackages: subpackages:
- bcrypt
- blowfish
- ssh/terminal - ssh/terminal
- name: golang.org/x/net - name: golang.org/x/net
version: 1c05540f6879653db88113bc4a2b70aec4bd491f version: 1c05540f6879653db88113bc4a2b70aec4bd491f
@ -139,6 +143,7 @@ imports:
- name: k8s.io/api - name: k8s.io/api
version: 2d6f90ab1293a1fb871cf149423ebb72aa7423aa version: 2d6f90ab1293a1fb871cf149423ebb72aa7423aa
subpackages: subpackages:
- admission/v1beta1
- admissionregistration/v1alpha1 - admissionregistration/v1alpha1
- admissionregistration/v1beta1 - admissionregistration/v1beta1
- apps/v1 - apps/v1
@ -157,7 +162,6 @@ imports:
- core/v1 - core/v1
- events/v1beta1 - events/v1beta1
- extensions/v1beta1 - extensions/v1beta1
- imagepolicy/v1alpha1
- networking/v1 - networking/v1
- policy/v1beta1 - policy/v1beta1
- rbac/v1 - rbac/v1
@ -296,5 +300,9 @@ imports:
- name: k8s.io/kube-openapi - name: k8s.io/kube-openapi
version: 91cfa479c814065e420cee7ed227db0f63a5854e version: 91cfa479c814065e420cee7ed227db0f63a5854e
subpackages: subpackages:
- pkg/builder
- pkg/common
- pkg/handler
- pkg/util
- pkg/util/proto - pkg/util/proto
testImports: [] testImports: []

View File

@ -1,4 +1,4 @@
package: github.com/zalando-incubator/postgres-operator package: github.com/zalando/postgres-operator
import: import:
- package: github.com/sirupsen/logrus - package: github.com/sirupsen/logrus
version: ^1.0.1 version: ^1.0.1

View File

@ -8,6 +8,6 @@ SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ${GOPATH}/src/k8s.io/code-generator)} CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ${GOPATH}/src/k8s.io/code-generator)}
vendor/k8s.io/code-generator/generate-groups.sh all \ vendor/k8s.io/code-generator/generate-groups.sh all \
github.com/zalando-incubator/postgres-operator/pkg/generated github.com/zalando-incubator/postgres-operator/pkg/apis \ github.com/zalando/postgres-operator/pkg/generated github.com/zalando/postgres-operator/pkg/apis \
acid.zalan.do:v1 \ acid.zalan.do:v1 \
--go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt

View File

@ -4,6 +4,10 @@ kind: postgresql
metadata: metadata:
name: acid-test-cluster name: acid-test-cluster
spec: spec:
init_containers:
- name: date
image: busybox
command: [ "/bin/date" ]
teamId: "ACID" teamId: "ACID"
volume: volume:
size: 1Gi size: 1Gi

View File

@ -10,11 +10,13 @@ data:
debug_logging: "true" debug_logging: "true"
workers: "4" workers: "4"
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-11:1.5-p42 docker_image: registry.opensource.zalan.do/acid/spilo-11:1.5-p4
pod_service_account_name: "zalando-postgres-operator" pod_service_account_name: "zalando-postgres-operator"
secret_name_template: '{username}.{cluster}.credentials' secret_name_template: '{username}.{cluster}.credentials'
super_username: postgres super_username: postgres
enable_teams_api: "false" enable_teams_api: "false"
# custom_service_annotations:
# "keyx:valuez,keya:valuea"
# set_memory_request_to_limit: "true" # set_memory_request_to_limit: "true"
# postgres_superuser_teams: "postgres_superusers" # postgres_superuser_teams: "postgres_superusers"
# enable_team_superuser: "false" # enable_team_superuser: "false"

View File

@ -2,7 +2,7 @@ apiVersion: "acid.zalan.do/v1"
kind: postgresql kind: postgresql
metadata: metadata:
name: acid-minimal-cluster name: acid-minimal-cluster
namespace: test # assumes namespace exists beforehand namespace: default
spec: spec:
teamId: "ACID" teamId: "ACID"
volume: volume:

View File

@ -12,7 +12,7 @@ spec:
serviceAccountName: zalando-postgres-operator serviceAccountName: zalando-postgres-operator
containers: containers:
- name: postgres-operator - name: postgres-operator
image: registry.opensource.zalan.do/acid/smoke-tested-postgres-operator:v1.0.0-21-ge39915c image: registry.opensource.zalan.do/acid/smoke-tested-postgres-operator:v1.0.0-37-g2422d72
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
resources: resources:
requests: requests:

View File

@ -25,8 +25,11 @@ configuration:
pod_role_label: spilo-role pod_role_label: spilo-role
cluster_labels: cluster_labels:
application: spilo application: spilo
# inherited_labels:
# - application
# - app
cluster_name_label: cluster-name cluster_name_label: cluster-name
# watched_namespace:"" # watched_namespace:""
# node_readiness_label: "" # node_readiness_label: ""
# toleration: {} # toleration: {}
# infrastructure_roles_secret_name: "" # infrastructure_roles_secret_name: ""
@ -46,11 +49,14 @@ configuration:
load_balancer: load_balancer:
enable_master_load_balancer: false enable_master_load_balancer: false
enable_replica_load_balancer: false enable_replica_load_balancer: false
# custom_service_annotations:
# keyx: valuex
# keyy: valuey
master_dns_name_format: "{cluster}.{team}.{hostedzone}" master_dns_name_format: "{cluster}.{team}.{hostedzone}"
replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}" replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}"
aws_or_gcp: aws_or_gcp:
# db_hosted_zone: "" # db_hosted_zone: ""
# wal_s3_bucket: "" # wal_s3_bucket: ""
# log_s3_bucket: "" # log_s3_bucket: ""
# kube_iam_role: "" # kube_iam_role: ""
aws_region: eu-central-1 aws_region: eu-central-1
@ -59,13 +65,13 @@ configuration:
enable_database_access: true enable_database_access: true
teams_api: teams_api:
enable_teams_api: false enable_teams_api: false
team_api_role_configuration: team_api_role_configuration:
log_statement: all log_statement: all
enable_team_superuser: false enable_team_superuser: false
team_admin_role: admin team_admin_role: admin
pam_role_name: zalandos pam_role_name: zalandos
# pam_configuration: "" # pam_configuration: ""
protected_role_names: protected_role_names:
- admin - admin
# teams_api_url: "" # teams_api_url: ""
# postgres_superuser_teams: "postgres_superusers" # postgres_superuser_teams: "postgres_superusers"

View File

@ -1,5 +1,5 @@
site_name: Postgres Operator site_name: Postgres Operator
repo_url: https://github.com/zalando-incubator/postgres-operator repo_url: https://github.com/zalando/postgres-operator
theme: readthedocs theme: readthedocs
pages: pages:

View File

@ -1,10 +1,7 @@
package v1 package v1
// ClusterStatusUnknown etc : status of a Postgres cluster known to the operator
const ( const (
serviceNameMaxLength = 63
clusterNameMaxLength = serviceNameMaxLength - len("-repl")
serviceNameRegexString = `^[a-z]([-a-z0-9]*[a-z0-9])?$`
ClusterStatusUnknown PostgresStatus = "" ClusterStatusUnknown PostgresStatus = ""
ClusterStatusCreating PostgresStatus = "Creating" ClusterStatusCreating PostgresStatus = "Creating"
ClusterStatusUpdating PostgresStatus = "Updating" ClusterStatusUpdating PostgresStatus = "Updating"
@ -14,3 +11,9 @@ const (
ClusterStatusRunning PostgresStatus = "Running" ClusterStatusRunning PostgresStatus = "Running"
ClusterStatusInvalid PostgresStatus = "Invalid" ClusterStatusInvalid PostgresStatus = "Invalid"
) )
const (
serviceNameMaxLength = 63
clusterNameMaxLength = serviceNameMaxLength - len("-repl")
serviceNameRegexString = `^[a-z]([-a-z0-9]*[a-z0-9])?$`
)

View File

@ -1,11 +1,12 @@
package v1 package v1
import ( import (
"github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do"
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// CRDResource* define names necesssary for the k8s CRD API
const ( const (
PostgresCRDResourceKind = "postgresql" PostgresCRDResourceKind = "postgresql"
PostgresCRDResourcePlural = "postgresqls" PostgresCRDResourcePlural = "postgresqls"
@ -39,6 +40,7 @@ func buildCRD(name, kind, plural, short string) *apiextv1beta1.CustomResourceDef
} }
} }
// PostgresCRD returns CustomResourceDefinition built from PostgresCRDResource
func PostgresCRD() *apiextv1beta1.CustomResourceDefinition { func PostgresCRD() *apiextv1beta1.CustomResourceDefinition {
return buildCRD(PostgresCRDResouceName, return buildCRD(PostgresCRDResouceName,
PostgresCRDResourceKind, PostgresCRDResourceKind,
@ -46,6 +48,7 @@ func PostgresCRD() *apiextv1beta1.CustomResourceDefinition {
PostgresCRDResourceShort) PostgresCRDResourceShort)
} }
// ConfigurationCRD returns CustomResourceDefinition built from OperatorConfigCRDResource
func ConfigurationCRD() *apiextv1beta1.CustomResourceDefinition { func ConfigurationCRD() *apiextv1beta1.CustomResourceDefinition {
return buildCRD(OperatorConfigCRDResourceName, return buildCRD(OperatorConfigCRDResourceName,
OperatorConfigCRDResouceKind, OperatorConfigCRDResouceKind,

View File

@ -1,6 +1,6 @@
// Package v1 is the v1 version of the API.
// +k8s:deepcopy-gen=package,register // +k8s:deepcopy-gen=package,register
// Package v1 is the v1 version of the API.
// +groupName=acid.zalan.do // +groupName=acid.zalan.do
package v1 package v1

View File

@ -104,6 +104,7 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error {
return nil return nil
} }
// UnmarshalJSON convert to Duration from byte slice of json
func (d *Duration) UnmarshalJSON(b []byte) error { func (d *Duration) UnmarshalJSON(b []byte) error {
var ( var (
v interface{} v interface{}

View File

@ -1,11 +1,11 @@
package v1 package v1
import ( import (
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"time" "time"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
@ -13,6 +13,8 @@ import (
// +genclient:onlyVerbs=get // +genclient:onlyVerbs=get
// +genclient:noStatus // +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// OperatorConfiguration defines the specification for the OperatorConfiguration.
type OperatorConfiguration struct { type OperatorConfiguration struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"` metav1.ObjectMeta `json:"metadata"`
@ -21,6 +23,8 @@ type OperatorConfiguration struct {
} }
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// OperatorConfigurationList is used in the k8s API calls
type OperatorConfigurationList struct { type OperatorConfigurationList struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"` metav1.ListMeta `json:"metadata"`
@ -28,11 +32,13 @@ type OperatorConfigurationList struct {
Items []OperatorConfiguration `json:"items"` Items []OperatorConfiguration `json:"items"`
} }
// PostgresUsersConfiguration defines the system users of Postgres.
type PostgresUsersConfiguration struct { type PostgresUsersConfiguration struct {
SuperUsername string `json:"super_username,omitempty"` SuperUsername string `json:"super_username,omitempty"`
ReplicationUsername string `json:"replication_username,omitempty"` ReplicationUsername string `json:"replication_username,omitempty"`
} }
// KubernetesMetaConfiguration defines k8s conf required for all Postgres clusters and the operator itself
type KubernetesMetaConfiguration struct { type KubernetesMetaConfiguration struct {
PodServiceAccountName string `json:"pod_service_account_name,omitempty"` PodServiceAccountName string `json:"pod_service_account_name,omitempty"`
// TODO: change it to the proper json // TODO: change it to the proper json
@ -46,6 +52,7 @@ type KubernetesMetaConfiguration struct {
InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"` InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"`
PodRoleLabel string `json:"pod_role_label,omitempty"` PodRoleLabel string `json:"pod_role_label,omitempty"`
ClusterLabels map[string]string `json:"cluster_labels,omitempty"` ClusterLabels map[string]string `json:"cluster_labels,omitempty"`
InheritedLabels []string `json:"inherited_labels,omitempty"`
ClusterNameLabel string `json:"cluster_name_label,omitempty"` ClusterNameLabel string `json:"cluster_name_label,omitempty"`
NodeReadinessLabel map[string]string `json:"node_readiness_label,omitempty"` NodeReadinessLabel map[string]string `json:"node_readiness_label,omitempty"`
// TODO: use a proper toleration structure? // TODO: use a proper toleration structure?
@ -53,8 +60,11 @@ type KubernetesMetaConfiguration struct {
// TODO: use namespacedname // TODO: use namespacedname
PodEnvironmentConfigMap string `json:"pod_environment_configmap,omitempty"` PodEnvironmentConfigMap string `json:"pod_environment_configmap,omitempty"`
PodPriorityClassName string `json:"pod_priority_class_name,omitempty"` PodPriorityClassName string `json:"pod_priority_class_name,omitempty"`
EnablePodAntiAffinity bool `json:"enable_pod_antiaffinity" default:"false"`
PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"`
} }
// PostgresPodResourcesDefaults defines the spec of default resources
type PostgresPodResourcesDefaults struct { type PostgresPodResourcesDefaults struct {
DefaultCPURequest string `json:"default_cpu_request,omitempty"` DefaultCPURequest string `json:"default_cpu_request,omitempty"`
DefaultMemoryRequest string `json:"default_memory_request,omitempty"` DefaultMemoryRequest string `json:"default_memory_request,omitempty"`
@ -62,6 +72,7 @@ type PostgresPodResourcesDefaults struct {
DefaultMemoryLimit string `json:"default_memory_limit,omitempty"` DefaultMemoryLimit string `json:"default_memory_limit,omitempty"`
} }
// OperatorTimeouts defines the timeout of ResourceCheck, PodWait, ReadyWait
type OperatorTimeouts struct { type OperatorTimeouts struct {
ResourceCheckInterval Duration `json:"resource_check_interval,omitempty"` ResourceCheckInterval Duration `json:"resource_check_interval,omitempty"`
ResourceCheckTimeout Duration `json:"resource_check_timeout,omitempty"` ResourceCheckTimeout Duration `json:"resource_check_timeout,omitempty"`
@ -71,14 +82,18 @@ type OperatorTimeouts struct {
ReadyWaitTimeout Duration `json:"ready_wait_timeout,omitempty"` ReadyWaitTimeout Duration `json:"ready_wait_timeout,omitempty"`
} }
// LoadBalancerConfiguration defines the LB configuration
type LoadBalancerConfiguration struct { type LoadBalancerConfiguration struct {
DbHostedZone string `json:"db_hosted_zone,omitempty"` DbHostedZone string `json:"db_hosted_zone,omitempty"`
EnableMasterLoadBalancer bool `json:"enable_master_load_balancer,omitempty"` EnableMasterLoadBalancer bool `json:"enable_master_load_balancer,omitempty"`
EnableReplicaLoadBalancer bool `json:"enable_replica_load_balancer,omitempty"` EnableReplicaLoadBalancer bool `json:"enable_replica_load_balancer,omitempty"`
CustomServiceAnnotations map[string]string `json:"custom_service_annotations,omitempty"`
MasterDNSNameFormat config.StringTemplate `json:"master_dns_name_format,omitempty"` MasterDNSNameFormat config.StringTemplate `json:"master_dns_name_format,omitempty"`
ReplicaDNSNameFormat config.StringTemplate `json:"replica_dns_name_format,omitempty"` ReplicaDNSNameFormat config.StringTemplate `json:"replica_dns_name_format,omitempty"`
} }
// AWSGCPConfiguration defines the configuration for AWS
// TODO complete Google Cloud Platform (GCP) configuration
type AWSGCPConfiguration struct { type AWSGCPConfiguration struct {
WALES3Bucket string `json:"wal_s3_bucket,omitempty"` WALES3Bucket string `json:"wal_s3_bucket,omitempty"`
AWSRegion string `json:"aws_region,omitempty"` AWSRegion string `json:"aws_region,omitempty"`
@ -86,11 +101,13 @@ type AWSGCPConfiguration struct {
KubeIAMRole string `json:"kube_iam_role,omitempty"` KubeIAMRole string `json:"kube_iam_role,omitempty"`
} }
// OperatorDebugConfiguration defines options for the debug mode
type OperatorDebugConfiguration struct { type OperatorDebugConfiguration struct {
DebugLogging bool `json:"debug_logging,omitempty"` DebugLogging bool `json:"debug_logging,omitempty"`
EnableDBAccess bool `json:"enable_database_access,omitempty"` EnableDBAccess bool `json:"enable_database_access,omitempty"`
} }
// TeamsAPIConfiguration defines the configration of TeamsAPI
type TeamsAPIConfiguration struct { type TeamsAPIConfiguration struct {
EnableTeamsAPI bool `json:"enable_teams_api,omitempty"` EnableTeamsAPI bool `json:"enable_teams_api,omitempty"`
TeamsAPIUrl string `json:"teams_api_url,omitempty"` TeamsAPIUrl string `json:"teams_api_url,omitempty"`
@ -103,12 +120,14 @@ type TeamsAPIConfiguration struct {
PostgresSuperuserTeams []string `json:"postgres_superuser_teams,omitempty"` PostgresSuperuserTeams []string `json:"postgres_superuser_teams,omitempty"`
} }
// LoggingRESTAPIConfiguration defines Logging API conf
type LoggingRESTAPIConfiguration struct { type LoggingRESTAPIConfiguration struct {
APIPort int `json:"api_port,omitempty"` APIPort int `json:"api_port,omitempty"`
RingLogLines int `json:"ring_log_lines,omitempty"` RingLogLines int `json:"ring_log_lines,omitempty"`
ClusterHistoryEntries int `json:"cluster_history_entries,omitempty"` ClusterHistoryEntries int `json:"cluster_history_entries,omitempty"`
} }
// ScalyrConfiguration defines the configuration for ScalyrAPI
type ScalyrConfiguration struct { type ScalyrConfiguration struct {
ScalyrAPIKey string `json:"scalyr_api_key,omitempty"` ScalyrAPIKey string `json:"scalyr_api_key,omitempty"`
ScalyrImage string `json:"scalyr_image,omitempty"` ScalyrImage string `json:"scalyr_image,omitempty"`
@ -119,6 +138,7 @@ type ScalyrConfiguration struct {
ScalyrMemoryLimit string `json:"scalyr_memory_limit,omitempty"` ScalyrMemoryLimit string `json:"scalyr_memory_limit,omitempty"`
} }
// OperatorConfigurationData defines the operation config
type OperatorConfigurationData struct { type OperatorConfigurationData struct {
EtcdHost string `json:"etcd_host,omitempty"` EtcdHost string `json:"etcd_host,omitempty"`
DockerImage string `json:"docker_image,omitempty"` DockerImage string `json:"docker_image,omitempty"`
@ -142,6 +162,7 @@ type OperatorConfigurationData struct {
LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"` LogicalBackup OperatorLogicalBackupConfiguration `json:"logical_backup"`
} }
// OperatorConfigurationUsers defines configration for super user
type OperatorConfigurationUsers struct { type OperatorConfigurationUsers struct {
SuperUserName string `json:"superuser_name,omitempty"` SuperUserName string `json:"superuser_name,omitempty"`
Replication string `json:"replication_user_name,omitempty"` Replication string `json:"replication_user_name,omitempty"`
@ -149,6 +170,7 @@ type OperatorConfigurationUsers struct {
TeamAPIRoleConfiguration map[string]string `json:"team_api_role_configuration,omitempty"` TeamAPIRoleConfiguration map[string]string `json:"team_api_role_configuration,omitempty"`
} }
//Duration shortens this frequently used name
type Duration time.Duration type Duration time.Duration
type OperatorLogicalBackupConfiguration struct { type OperatorLogicalBackupConfiguration struct {

View File

@ -9,7 +9,8 @@ import (
// +genclient // +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//Postgresql defines PostgreSQL Custom Resource Definition Object.
// Postgresql defines PostgreSQL Custom Resource Definition Object.
type Postgresql struct { type Postgresql struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"` metav1.ObjectMeta `json:"metadata,omitempty"`
@ -50,6 +51,7 @@ type PostgresSpec struct {
Databases map[string]string `json:"databases,omitempty"` Databases map[string]string `json:"databases,omitempty"`
Tolerations []v1.Toleration `json:"tolerations,omitempty"` Tolerations []v1.Toleration `json:"tolerations,omitempty"`
Sidecars []Sidecar `json:"sidecars,omitempty"` Sidecars []Sidecar `json:"sidecars,omitempty"`
InitContainers []v1.Container `json:"init_containers,omitempty"`
PodPriorityClassName string `json:"pod_priority_class_name,omitempty"` PodPriorityClassName string `json:"pod_priority_class_name,omitempty"`
ShmVolume *bool `json:"enableShmVolume,omitempty"` ShmVolume *bool `json:"enableShmVolume,omitempty"`
@ -59,6 +61,7 @@ type PostgresSpec struct {
} }
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PostgresqlList defines a list of PostgreSQL clusters. // PostgresqlList defines a list of PostgreSQL clusters.
type PostgresqlList struct { type PostgresqlList struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`

View File

@ -5,18 +5,23 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do"
) )
// APIVersion of the `postgresql` and `operator` CRDs
const ( const (
APIVersion = "v1" APIVersion = "v1"
) )
var ( var (
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
// An instance of runtime.SchemeBuilder, global for this package
SchemeBuilder runtime.SchemeBuilder SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme //AddToScheme is localSchemeBuilder.AddToScheme
AddToScheme = localSchemeBuilder.AddToScheme
//SchemeGroupVersion has GroupName and APIVersion
SchemeGroupVersion = schema.GroupVersion{Group: acidzalando.GroupName, Version: APIVersion} SchemeGroupVersion = schema.GroupVersion{Group: acidzalando.GroupName, Version: APIVersion}
) )

View File

@ -14,6 +14,7 @@ var (
serviceNameRegex = regexp.MustCompile(serviceNameRegexString) serviceNameRegex = regexp.MustCompile(serviceNameRegexString)
) )
// Clone convenience wrapper around DeepCopy
func (p *Postgresql) Clone() *Postgresql { func (p *Postgresql) Clone() *Postgresql {
if p == nil { if p == nil {
return nil return nil
@ -83,6 +84,7 @@ func validateCloneClusterDescription(clone *CloneDescription) error {
return nil return nil
} }
// Success of the current Status
func (status PostgresStatus) Success() bool { func (status PostgresStatus) Success() bool {
return status != ClusterStatusAddFailed && return status != ClusterStatusAddFailed &&
status != ClusterStatusUpdateFailed && status != ClusterStatusUpdateFailed &&

View File

@ -1,7 +1,7 @@
// +build !ignore_autogenerated // +build !ignore_autogenerated
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -75,6 +75,11 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura
(*out)[key] = val (*out)[key] = val
} }
} }
if in.InheritedLabels != nil {
in, out := &in.InheritedLabels, &out.InheritedLabels
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.NodeReadinessLabel != nil { if in.NodeReadinessLabel != nil {
in, out := &in.NodeReadinessLabel, &out.NodeReadinessLabel in, out := &in.NodeReadinessLabel, &out.NodeReadinessLabel
*out = make(map[string]string, len(*in)) *out = make(map[string]string, len(*in))
@ -105,6 +110,13 @@ func (in *KubernetesMetaConfiguration) DeepCopy() *KubernetesMetaConfiguration {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LoadBalancerConfiguration) DeepCopyInto(out *LoadBalancerConfiguration) { func (in *LoadBalancerConfiguration) DeepCopyInto(out *LoadBalancerConfiguration) {
*out = *in *out = *in
if in.CustomServiceAnnotations != nil {
in, out := &in.CustomServiceAnnotations, &out.CustomServiceAnnotations
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return return
} }
@ -193,7 +205,7 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData
in.Kubernetes.DeepCopyInto(&out.Kubernetes) in.Kubernetes.DeepCopyInto(&out.Kubernetes)
out.PostgresPodResources = in.PostgresPodResources out.PostgresPodResources = in.PostgresPodResources
out.Timeouts = in.Timeouts out.Timeouts = in.Timeouts
out.LoadBalancer = in.LoadBalancer in.LoadBalancer.DeepCopyInto(&out.LoadBalancer)
out.AWSGCP = in.AWSGCP out.AWSGCP = in.AWSGCP
out.OperatorDebug = in.OperatorDebug out.OperatorDebug = in.OperatorDebug
in.TeamsAPI.DeepCopyInto(&out.TeamsAPI) in.TeamsAPI.DeepCopyInto(&out.TeamsAPI)
@ -442,6 +454,18 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) {
(*in)[i].DeepCopyInto(&(*out)[i]) (*in)[i].DeepCopyInto(&(*out)[i])
} }
} }
if in.InitContainers != nil {
in, out := &in.InitContainers, &out.InitContainers
*out = make([]corev1.Container, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.ShmVolume != nil {
in, out := &in.ShmVolume, &out.ShmVolume
*out = new(bool)
**out = **in
}
return return
} }

View File

@ -13,10 +13,10 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
) )
const ( const (

View File

@ -12,7 +12,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"k8s.io/api/apps/v1beta1" "k8s.io/api/apps/v1beta1"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
policybeta1 "k8s.io/api/policy/v1beta1" policybeta1 "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -22,15 +22,15 @@ import (
"encoding/json" "encoding/json"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/patroni" "github.com/zalando/postgres-operator/pkg/util/patroni"
"github.com/zalando-incubator/postgres-operator/pkg/util/teams" "github.com/zalando/postgres-operator/pkg/util/teams"
"github.com/zalando-incubator/postgres-operator/pkg/util/users" "github.com/zalando/postgres-operator/pkg/util/users"
rbacv1beta1 "k8s.io/api/rbac/v1beta1" rbacv1beta1 "k8s.io/api/rbac/v1beta1"
) )
@ -503,7 +503,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
defer func() { defer func() {
if updateFailed { if updateFailed {
c.setStatus(acidv1.ClusterStatusUpdateFailed) c.setStatus(acidv1.ClusterStatusUpdateFailed)
} else if c.Status != acidv1.ClusterStatusRunning { } else {
c.setStatus(acidv1.ClusterStatusRunning) c.setStatus(acidv1.ClusterStatusRunning)
} }
}() }()
@ -886,7 +886,7 @@ func (c *Cluster) GetStatus() *ClusterStatus {
func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) error { func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) error {
var err error var err error
c.logger.Debugf("failing over from %q to %q", curMaster.Name, candidate) c.logger.Debugf("switching over from %q to %q", curMaster.Name, candidate)
var wg sync.WaitGroup var wg sync.WaitGroup
@ -912,12 +912,12 @@ func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) e
}() }()
if err = c.patroni.Switchover(curMaster, candidate.Name); err == nil { if err = c.patroni.Switchover(curMaster, candidate.Name); err == nil {
c.logger.Debugf("successfully failed over from %q to %q", curMaster.Name, candidate) c.logger.Debugf("successfully switched over from %q to %q", curMaster.Name, candidate)
if err = <-podLabelErr; err != nil { if err = <-podLabelErr; err != nil {
err = fmt.Errorf("could not get master pod label: %v", err) err = fmt.Errorf("could not get master pod label: %v", err)
} }
} else { } else {
err = fmt.Errorf("could not failover: %v", err) err = fmt.Errorf("could not switch over: %v", err)
} }
// signal the role label waiting goroutine to close the shop and go home // signal the role label waiting goroutine to close the shop and go home

View File

@ -6,11 +6,11 @@ import (
"testing" "testing"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/teams" "github.com/zalando/postgres-operator/pkg/util/teams"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
) )

View File

@ -9,9 +9,9 @@ import (
"github.com/lib/pq" "github.com/lib/pq"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" "github.com/zalando/postgres-operator/pkg/util/retryutil"
) )
const ( const (

View File

@ -10,8 +10,8 @@ import (
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand" "k8s.io/client-go/tools/remotecommand"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
) )
//ExecCommand executes arbitrary command inside the pod //ExecCommand executes arbitrary command inside the pod

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/filesystems" "github.com/zalando/postgres-operator/pkg/util/filesystems"
) )
func (c *Cluster) getPostgresFilesystemInfo(podName *spec.NamespacedName) (device, fstype string, err error) { func (c *Cluster) getPostgresFilesystemInfo(podName *spec.NamespacedName) (device, fstype string, err error) {

View File

@ -15,11 +15,11 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
batchv1 "k8s.io/api/batch/v1" batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1" batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
@ -293,6 +293,26 @@ func nodeAffinity(nodeReadinessLabel map[string]string) *v1.Affinity {
} }
} }
func generatePodAffinity(labels labels.Set, topologyKey string, nodeAffinity *v1.Affinity) *v1.Affinity {
// generate pod anti-affinity to avoid multiple pods of the same Postgres cluster in the same topology , e.g. node
podAffinity := v1.Affinity{
PodAntiAffinity: &v1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{{
LabelSelector: &metav1.LabelSelector{
MatchLabels: labels,
},
TopologyKey: topologyKey,
}},
},
}
if nodeAffinity != nil && nodeAffinity.NodeAffinity != nil {
podAffinity.NodeAffinity = nodeAffinity.NodeAffinity
}
return &podAffinity
}
func tolerations(tolerationsSpec *[]v1.Toleration, podToleration map[string]string) []v1.Toleration { func tolerations(tolerationsSpec *[]v1.Toleration, podToleration map[string]string) []v1.Toleration {
// allow to override tolerations by postgresql manifest // allow to override tolerations by postgresql manifest
if len(*tolerationsSpec) > 0 { if len(*tolerationsSpec) > 0 {
@ -413,6 +433,7 @@ func generatePodTemplate(
namespace string, namespace string,
labels labels.Set, labels labels.Set,
spiloContainer *v1.Container, spiloContainer *v1.Container,
initContainers []v1.Container,
sidecarContainers []v1.Container, sidecarContainers []v1.Container,
tolerationsSpec *[]v1.Toleration, tolerationsSpec *[]v1.Toleration,
nodeAffinity *v1.Affinity, nodeAffinity *v1.Affinity,
@ -421,6 +442,8 @@ func generatePodTemplate(
kubeIAMRole string, kubeIAMRole string,
priorityClassName string, priorityClassName string,
shmVolume bool, shmVolume bool,
podAntiAffinity bool,
podAntiAffinityTopologyKey string,
) (*v1.PodTemplateSpec, error) { ) (*v1.PodTemplateSpec, error) {
terminateGracePeriodSeconds := terminateGracePeriod terminateGracePeriodSeconds := terminateGracePeriod
@ -431,6 +454,7 @@ func generatePodTemplate(
ServiceAccountName: podServiceAccountName, ServiceAccountName: podServiceAccountName,
TerminationGracePeriodSeconds: &terminateGracePeriodSeconds, TerminationGracePeriodSeconds: &terminateGracePeriodSeconds,
Containers: containers, Containers: containers,
InitContainers: initContainers,
Tolerations: *tolerationsSpec, Tolerations: *tolerationsSpec,
} }
@ -438,7 +462,9 @@ func generatePodTemplate(
addShmVolume(&podSpec) addShmVolume(&podSpec)
} }
if nodeAffinity != nil { if podAntiAffinity {
podSpec.Affinity = generatePodAffinity(labels, podAntiAffinityTopologyKey, nodeAffinity)
} else if nodeAffinity != nil {
podSpec.Affinity = nodeAffinity podSpec.Affinity = nodeAffinity
} }
@ -806,6 +832,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*v1beta1.State
c.Namespace, c.Namespace,
c.labelsSet(true), c.labelsSet(true),
spiloContainer, spiloContainer,
spec.InitContainers,
sidecarContainers, sidecarContainers,
&tolerationSpec, &tolerationSpec,
nodeAffinity(c.OpConfig.NodeReadinessLabel), nodeAffinity(c.OpConfig.NodeReadinessLabel),
@ -813,7 +840,9 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*v1beta1.State
c.OpConfig.PodServiceAccountName, c.OpConfig.PodServiceAccountName,
c.OpConfig.KubeIAMRole, c.OpConfig.KubeIAMRole,
effectivePodPriorityClassName, effectivePodPriorityClassName,
mountShmVolumeNeeded(c.OpConfig, spec)); err != nil { mountShmVolumeNeeded(c.OpConfig, spec),
c.OpConfig.EnablePodAntiAffinity,
c.OpConfig.PodAntiAffinityTopologyKey); err != nil {
return nil, fmt.Errorf("could not generate pod template: %v", err) return nil, fmt.Errorf("could not generate pod template: %v", err)
} }
@ -1073,7 +1102,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec)
} }
if role == Replica { if role == Replica {
serviceSpec.Selector = c.roleLabelsSet(role) serviceSpec.Selector = c.roleLabelsSet(false, role)
} }
var annotations map[string]string var annotations map[string]string
@ -1096,6 +1125,13 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec)
constants.ZalandoDNSNameAnnotation: dnsName, constants.ZalandoDNSNameAnnotation: dnsName,
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue, constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
} }
if len(c.OpConfig.CustomServiceAnnotations) != 0 {
c.logger.Debugf("There are custom annotations defined, creating them.")
for customAnnotationKey, customAnnotationValue := range c.OpConfig.CustomServiceAnnotations {
annotations[customAnnotationKey] = customAnnotationValue
}
}
} else if role == Replica { } else if role == Replica {
// before PR #258, the replica service was only created if allocated a LB // before PR #258, the replica service was only created if allocated a LB
// now we always create the service but warn if the LB is absent // now we always create the service but warn if the LB is absent
@ -1106,7 +1142,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec)
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: c.serviceName(role), Name: c.serviceName(role),
Namespace: c.Namespace, Namespace: c.Namespace,
Labels: c.roleLabelsSet(role), Labels: c.roleLabelsSet(true, role),
Annotations: annotations, Annotations: annotations,
}, },
Spec: serviceSpec, Spec: serviceSpec,
@ -1120,7 +1156,7 @@ func (c *Cluster) generateEndpoint(role PostgresRole, subsets []v1.EndpointSubse
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: c.endpointName(role), Name: c.endpointName(role),
Namespace: c.Namespace, Namespace: c.Namespace,
Labels: c.roleLabelsSet(role), Labels: c.roleLabelsSet(true, role),
}, },
} }
if len(subsets) > 0 { if len(subsets) > 0 {
@ -1184,7 +1220,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policybeta1.PodDisruptionBudget
Spec: policybeta1.PodDisruptionBudgetSpec{ Spec: policybeta1.PodDisruptionBudgetSpec{
MinAvailable: &minAvailable, MinAvailable: &minAvailable,
Selector: &metav1.LabelSelector{ Selector: &metav1.LabelSelector{
MatchLabels: c.roleLabelsSet(Master), MatchLabels: c.roleLabelsSet(false, Master),
}, },
}, },
} }
@ -1201,16 +1237,14 @@ func (c *Cluster) getClusterServiceConnectionParameters(clusterName string) (hos
func (c *Cluster) generateCronJob() *batchv1beta1.CronJob { func (c *Cluster) generateCronJob() *batchv1beta1.CronJob {
jobSpec := batchv1.JobSpec{Template : v1.PodTemplateSpec{ jobSpec := batchv1.JobSpec{Template: v1.PodTemplateSpec{
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
Containers: []corev1.Container{ Containers: []corev1.Container{
corev1.Container { corev1.Container{
Name: "Hello world", Name: "Hello world",
Image: "hello-world", Image: "hello-world",
Command: []string{"date", "echo Hello from the Kubernetes cluster"}, Command: []string{"date", "echo Hello from the Kubernetes cluster"},
}, },
}, },
}, },
}, },
@ -1218,7 +1252,6 @@ func (c *Cluster) generateCronJob() *batchv1beta1.CronJob {
jobTemplateSpec := batchv1beta1.JobTemplateSpec{ jobTemplateSpec := batchv1beta1.JobTemplateSpec{
Spec: jobSpec, Spec: jobSpec,
} }
cronJob := &batchv1beta1.CronJob{ cronJob := &batchv1beta1.CronJob{

View File

@ -3,10 +3,10 @@ package cluster
import ( import (
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"testing" "testing"
) )

View File

@ -4,11 +4,11 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"k8s.io/api/apps/v1beta1" "k8s.io/api/apps/v1beta1"
) )
@ -27,7 +27,7 @@ func (c *Cluster) listPods() ([]v1.Pod, error) {
func (c *Cluster) getRolePods(role PostgresRole) ([]v1.Pod, error) { func (c *Cluster) getRolePods(role PostgresRole) ([]v1.Pod, error) {
listOptions := metav1.ListOptions{ listOptions := metav1.ListOptions{
LabelSelector: c.roleLabelsSet(role).String(), LabelSelector: c.roleLabelsSet(false, role).String(),
} }
pods, err := c.KubeClient.Pods(c.Namespace).List(listOptions) pods, err := c.KubeClient.Pods(c.Namespace).List(listOptions)
@ -77,11 +77,7 @@ func (c *Cluster) deletePod(podName spec.NamespacedName) error {
return err return err
} }
if err := c.waitForPodDeletion(ch); err != nil { return c.waitForPodDeletion(ch)
return err
}
return nil
} }
func (c *Cluster) unregisterPodSubscriber(podName spec.NamespacedName) { func (c *Cluster) unregisterPodSubscriber(podName spec.NamespacedName) {
@ -122,7 +118,7 @@ func (c *Cluster) movePodFromEndOfLifeNode(pod *v1.Pod) (*v1.Pod, error) {
if eol, err = c.podIsEndOfLife(pod); err != nil { if eol, err = c.podIsEndOfLife(pod); err != nil {
return nil, fmt.Errorf("could not get node %q: %v", pod.Spec.NodeName, err) return nil, fmt.Errorf("could not get node %q: %v", pod.Spec.NodeName, err)
} else if !eol { } else if !eol {
c.logger.Infof("pod %q is already on a live node", podName) c.logger.Infof("check failed: pod %q is already on a live node", podName)
return pod, nil return pod, nil
} }
@ -162,7 +158,7 @@ func (c *Cluster) masterCandidate(oldNodeName string) (*v1.Pod, error) {
} }
if len(replicas) == 0 { if len(replicas) == 0 {
c.logger.Warningf("no available master candidates, migration will cause longer downtime of the master instance") c.logger.Warningf("no available master candidates, migration will cause longer downtime of Postgres cluster")
return nil, nil return nil, nil
} }
@ -193,18 +189,18 @@ func (c *Cluster) MigrateMasterPod(podName spec.NamespacedName) error {
return fmt.Errorf("could not get pod: %v", err) return fmt.Errorf("could not get pod: %v", err)
} }
c.logger.Infof("migrating master pod %q", podName) c.logger.Infof("starting process to migrate master pod %q", podName)
if eol, err = c.podIsEndOfLife(oldMaster); err != nil { if eol, err = c.podIsEndOfLife(oldMaster); err != nil {
return fmt.Errorf("could not get node %q: %v", oldMaster.Spec.NodeName, err) return fmt.Errorf("could not get node %q: %v", oldMaster.Spec.NodeName, err)
} }
if !eol { if !eol {
c.logger.Debugf("pod is already on a live node") c.logger.Debugf("no action needed: master pod is already on a live node")
return nil return nil
} }
if role := PostgresRole(oldMaster.Labels[c.OpConfig.PodRoleLabel]); role != Master { if role := PostgresRole(oldMaster.Labels[c.OpConfig.PodRoleLabel]); role != Master {
c.logger.Warningf("pod %q is not a master", podName) c.logger.Warningf("no action needed: pod %q is not the master (anymore)", podName)
return nil return nil
} }
// we must have a statefulset in the cluster for the migration to work // we must have a statefulset in the cluster for the migration to work
@ -219,10 +215,10 @@ func (c *Cluster) MigrateMasterPod(podName spec.NamespacedName) error {
// We may not have a cached statefulset if the initial cluster sync has aborted, revert to the spec in that case. // We may not have a cached statefulset if the initial cluster sync has aborted, revert to the spec in that case.
if *c.Statefulset.Spec.Replicas > 1 { if *c.Statefulset.Spec.Replicas > 1 {
if masterCandidatePod, err = c.masterCandidate(oldMaster.Spec.NodeName); err != nil { if masterCandidatePod, err = c.masterCandidate(oldMaster.Spec.NodeName); err != nil {
return fmt.Errorf("could not get new master candidate: %v", err) return fmt.Errorf("could not find suitable replica pod as candidate for failover: %v", err)
} }
} else { } else {
c.logger.Warningf("single master pod for cluster %q, migration will cause longer downtime of the master instance", c.clusterName()) c.logger.Warningf("migrating single pod cluster %q, this will cause downtime of the Postgres cluster until pod is back", c.clusterName())
} }
// there are two cases for each postgres cluster that has its master pod on the node to migrate from: // there are two cases for each postgres cluster that has its master pod on the node to migrate from:
@ -256,15 +252,15 @@ func (c *Cluster) MigrateReplicaPod(podName spec.NamespacedName, fromNodeName st
return fmt.Errorf("could not get pod: %v", err) return fmt.Errorf("could not get pod: %v", err)
} }
c.logger.Infof("migrating replica pod %q", podName) c.logger.Infof("migrating replica pod %q to live node", podName)
if replicaPod.Spec.NodeName != fromNodeName { if replicaPod.Spec.NodeName != fromNodeName {
c.logger.Infof("pod %q has already migrated to node %q", podName, replicaPod.Spec.NodeName) c.logger.Infof("check failed: pod %q has already migrated to node %q", podName, replicaPod.Spec.NodeName)
return nil return nil
} }
if role := PostgresRole(replicaPod.Labels[c.OpConfig.PodRoleLabel]); role != Replica { if role := PostgresRole(replicaPod.Labels[c.OpConfig.PodRoleLabel]); role != Replica {
return fmt.Errorf("pod %q is not a replica", podName) return fmt.Errorf("check failed: pod %q is not a replica", podName)
} }
_, err = c.movePodFromEndOfLifeNode(replicaPod) _, err = c.movePodFromEndOfLifeNode(replicaPod)
@ -296,7 +292,7 @@ func (c *Cluster) recreatePod(podName spec.NamespacedName) (*v1.Pod, error) {
} }
func (c *Cluster) recreatePods() error { func (c *Cluster) recreatePods() error {
c.setProcessName("recreating pods") c.setProcessName("starting to recreate pods")
ls := c.labelsSet(false) ls := c.labelsSet(false)
namespace := c.Namespace namespace := c.Namespace
@ -337,10 +333,10 @@ func (c *Cluster) recreatePods() error {
// failover if we have not observed a master pod when re-creating former replicas. // failover if we have not observed a master pod when re-creating former replicas.
if newMasterPod == nil && len(replicas) > 0 { if newMasterPod == nil && len(replicas) > 0 {
if err := c.Switchover(masterPod, masterCandidate(replicas)); err != nil { if err := c.Switchover(masterPod, masterCandidate(replicas)); err != nil {
c.logger.Warningf("could not perform failover: %v", err) c.logger.Warningf("could not perform switch over: %v", err)
} }
} else if newMasterPod == nil && len(replicas) == 0 { } else if newMasterPod == nil && len(replicas) == 0 {
c.logger.Warningf("cannot switch master role before re-creating the pod: no replicas") c.logger.Warningf("cannot perform switch over before re-creating the pod: no replicas")
} }
c.logger.Infof("recreating old master pod %q", util.NameFromMeta(masterPod.ObjectMeta)) c.logger.Infof("recreating old master pod %q", util.NameFromMeta(masterPod.ObjectMeta))

View File

@ -11,10 +11,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" "github.com/zalando/postgres-operator/pkg/util/retryutil"
) )
const ( const (
@ -437,7 +437,11 @@ func (c *Cluster) updateService(role PostgresRole, newService *v1.Service) error
func (c *Cluster) deleteService(role PostgresRole) error { func (c *Cluster) deleteService(role PostgresRole) error {
c.logger.Debugf("deleting service %s", role) c.logger.Debugf("deleting service %s", role)
service := c.Services[role] service, ok := c.Services[role]
if !ok {
c.logger.Debugf("No service for %s role was found, nothing to delete", role)
return nil
}
if err := c.KubeClient.Services(service.Namespace).Delete(service.Name, c.deleteOptions); err != nil { if err := c.KubeClient.Services(service.Namespace).Delete(service.Name, c.deleteOptions); err != nil {
return err return err

View File

@ -7,12 +7,12 @@ import (
policybeta1 "k8s.io/api/policy/v1beta1" policybeta1 "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/volumes" "github.com/zalando/postgres-operator/pkg/util/volumes"
) )
// Sync syncs the cluster, making sure the actual Kubernetes objects correspond to what is defined in the manifest. // Sync syncs the cluster, making sure the actual Kubernetes objects correspond to what is defined in the manifest.

View File

@ -1,12 +1,13 @@
package cluster package cluster
import ( import (
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" "time"
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"k8s.io/api/apps/v1beta1" "k8s.io/api/apps/v1beta1"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
policybeta1 "k8s.io/api/policy/v1beta1" policybeta1 "k8s.io/api/policy/v1beta1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"time"
) )
// PostgresRole describes role of the node // PostgresRole describes role of the node
@ -20,6 +21,7 @@ const (
Replica PostgresRole = "replica" Replica PostgresRole = "replica"
) )
// PodEventType represents the type of a pod-related event
type PodEventType string type PodEventType string
// Possible values for the EventType // Possible values for the EventType

View File

@ -17,13 +17,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
acidzalando "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" acidzalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" "github.com/zalando/postgres-operator/pkg/util/retryutil"
) )
// OAuthTokenGetter provides the method for fetching OAuth tokens // OAuthTokenGetter provides the method for fetching OAuth tokens
@ -389,6 +389,19 @@ func (c *Cluster) labelsSet(shouldAddExtraLabels bool) labels.Set {
if shouldAddExtraLabels { if shouldAddExtraLabels {
// enables filtering resources owned by a team // enables filtering resources owned by a team
lbls["team"] = c.Postgresql.Spec.TeamID lbls["team"] = c.Postgresql.Spec.TeamID
// allow to inherit certain labels from the 'postgres' object
if spec, err := c.GetSpec(); err == nil {
for k, v := range spec.ObjectMeta.Labels {
for _, match := range c.OpConfig.InheritedLabels {
if k == match {
lbls[k] = v
}
}
}
} else {
c.logger.Warningf("could not get the list of InheritedLabels for cluster %q: %v", c.Name, err)
}
} }
return labels.Set(lbls) return labels.Set(lbls)
@ -398,8 +411,8 @@ func (c *Cluster) labelsSelector() *metav1.LabelSelector {
return &metav1.LabelSelector{MatchLabels: c.labelsSet(false), MatchExpressions: nil} return &metav1.LabelSelector{MatchLabels: c.labelsSet(false), MatchExpressions: nil}
} }
func (c *Cluster) roleLabelsSet(role PostgresRole) labels.Set { func (c *Cluster) roleLabelsSet(shouldAddExtraLabels bool, role PostgresRole) labels.Set {
lbls := c.labelsSet(false) lbls := c.labelsSet(shouldAddExtraLabels)
lbls[c.OpConfig.PodRoleLabel] = string(role) lbls[c.OpConfig.PodRoleLabel] = string(role)
return lbls return lbls
} }
@ -460,6 +473,7 @@ func (c *Cluster) setSpec(newSpec *acidv1.Postgresql) {
c.specMu.Unlock() c.specMu.Unlock()
} }
// GetSpec returns a copy of the operator-side spec of a Postgres cluster in a thread-safe manner
func (c *Cluster) GetSpec() (*acidv1.Postgresql, error) { func (c *Cluster) GetSpec() (*acidv1.Postgresql, error) {
c.specMu.RLock() c.specMu.RLock()
defer c.specMu.RUnlock() defer c.specMu.RUnlock()

View File

@ -9,12 +9,12 @@ import (
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/filesystems" "github.com/zalando/postgres-operator/pkg/util/filesystems"
"github.com/zalando-incubator/postgres-operator/pkg/util/volumes" "github.com/zalando/postgres-operator/pkg/util/volumes"
) )
func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) { func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) {

View File

@ -13,16 +13,16 @@ import (
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/zalando-incubator/postgres-operator/pkg/apiserver" "github.com/zalando/postgres-operator/pkg/apiserver"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/ringlog" "github.com/zalando/postgres-operator/pkg/util/ringlog"
acidv1informer "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1" acidv1informer "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1"
) )
// Controller represents operator controller // Controller represents operator controller

View File

@ -7,10 +7,10 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )

View File

@ -7,8 +7,8 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
) )
func (c *Controller) nodeListFunc(options metav1.ListOptions) (runtime.Object, error) { func (c *Controller) nodeListFunc(options metav1.ListOptions) (runtime.Object, error) {

View File

@ -3,7 +3,7 @@ package controller
import ( import (
"testing" "testing"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )

View File

@ -5,8 +5,8 @@ import (
"time" "time"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
@ -39,6 +39,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
result.PodServiceAccountName = fromCRD.Kubernetes.PodServiceAccountName result.PodServiceAccountName = fromCRD.Kubernetes.PodServiceAccountName
result.PodServiceAccountDefinition = fromCRD.Kubernetes.PodServiceAccountDefinition result.PodServiceAccountDefinition = fromCRD.Kubernetes.PodServiceAccountDefinition
result.PodServiceAccountRoleBindingDefinition = fromCRD.Kubernetes.PodServiceAccountRoleBindingDefinition result.PodServiceAccountRoleBindingDefinition = fromCRD.Kubernetes.PodServiceAccountRoleBindingDefinition
result.PodEnvironmentConfigMap = fromCRD.Kubernetes.PodEnvironmentConfigMap
result.PodTerminateGracePeriod = time.Duration(fromCRD.Kubernetes.PodTerminateGracePeriod) result.PodTerminateGracePeriod = time.Duration(fromCRD.Kubernetes.PodTerminateGracePeriod)
result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace
result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat
@ -47,10 +48,14 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
result.InfrastructureRolesSecretName = fromCRD.Kubernetes.InfrastructureRolesSecretName result.InfrastructureRolesSecretName = fromCRD.Kubernetes.InfrastructureRolesSecretName
result.PodRoleLabel = fromCRD.Kubernetes.PodRoleLabel result.PodRoleLabel = fromCRD.Kubernetes.PodRoleLabel
result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels
result.InheritedLabels = fromCRD.Kubernetes.InheritedLabels
result.ClusterNameLabel = fromCRD.Kubernetes.ClusterNameLabel result.ClusterNameLabel = fromCRD.Kubernetes.ClusterNameLabel
result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel
result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName
result.EnablePodAntiAffinity = fromCRD.Kubernetes.EnablePodAntiAffinity;
result.PodAntiAffinityTopologyKey = fromCRD.Kubernetes.PodAntiAffinityTopologyKey;
result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest
result.DefaultMemoryRequest = fromCRD.PostgresPodResources.DefaultMemoryRequest result.DefaultMemoryRequest = fromCRD.PostgresPodResources.DefaultMemoryRequest
result.DefaultCPULimit = fromCRD.PostgresPodResources.DefaultCPULimit result.DefaultCPULimit = fromCRD.PostgresPodResources.DefaultCPULimit
@ -67,6 +72,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
result.DbHostedZone = fromCRD.LoadBalancer.DbHostedZone result.DbHostedZone = fromCRD.LoadBalancer.DbHostedZone
result.EnableMasterLoadBalancer = fromCRD.LoadBalancer.EnableMasterLoadBalancer result.EnableMasterLoadBalancer = fromCRD.LoadBalancer.EnableMasterLoadBalancer
result.EnableReplicaLoadBalancer = fromCRD.LoadBalancer.EnableReplicaLoadBalancer result.EnableReplicaLoadBalancer = fromCRD.LoadBalancer.EnableReplicaLoadBalancer
result.CustomServiceAnnotations = fromCRD.LoadBalancer.CustomServiceAnnotations
result.MasterDNSNameFormat = fromCRD.LoadBalancer.MasterDNSNameFormat result.MasterDNSNameFormat = fromCRD.LoadBalancer.MasterDNSNameFormat
result.ReplicaDNSNameFormat = fromCRD.LoadBalancer.ReplicaDNSNameFormat result.ReplicaDNSNameFormat = fromCRD.LoadBalancer.ReplicaDNSNameFormat

View File

@ -6,9 +6,9 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )

View File

@ -14,12 +14,12 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/ringlog" "github.com/zalando/postgres-operator/pkg/util/ringlog"
) )
func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) { func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) {
@ -385,8 +385,14 @@ func (c *Controller) queueClusterEvent(informerOldSpec, informerNewSpec *acidv1.
if informerOldSpec != nil { //update, delete if informerOldSpec != nil { //update, delete
uid = informerOldSpec.GetUID() uid = informerOldSpec.GetUID()
clusterName = util.NameFromMeta(informerOldSpec.ObjectMeta) clusterName = util.NameFromMeta(informerOldSpec.ObjectMeta)
// user is fixing previously incorrect spec
if eventType == EventUpdate && informerNewSpec.Error == "" && informerOldSpec.Error != "" { if eventType == EventUpdate && informerNewSpec.Error == "" && informerOldSpec.Error != "" {
eventType = EventSync eventType = EventSync
}
// set current error to be one of the new spec if present
if informerNewSpec != nil {
clusterError = informerNewSpec.Error clusterError = informerNewSpec.Error
} else { } else {
clusterError = informerOldSpec.Error clusterError = informerOldSpec.Error

View File

@ -1,8 +1,8 @@
package controller package controller
import ( import (
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"reflect" "reflect"
"testing" "testing"
) )

View File

@ -4,7 +4,7 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
"time" "time"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
) )
// EventType contains type of the events for the TPRs and Pods received from Kubernetes // EventType contains type of the events for the TPRs and Pods received from Kubernetes

View File

@ -8,11 +8,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/cluster" "github.com/zalando/postgres-operator/pkg/cluster"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/config" "github.com/zalando/postgres-operator/pkg/util/config"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )

View File

@ -10,8 +10,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1core "k8s.io/client-go/kubernetes/typed/core/v1" v1core "k8s.io/client-go/kubernetes/typed/core/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" "github.com/zalando/postgres-operator/pkg/util/k8sutil"
) )
const ( const (

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package versioned package versioned
import ( import (
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
discovery "k8s.io/client-go/discovery" discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol" flowcontrol "k8s.io/client-go/util/flowcontrol"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,9 +25,9 @@ SOFTWARE.
package fake package fake
import ( import (
clientset "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" clientset "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
fakeacidv1 "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake" fakeacidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch" "k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package fake package fake
import ( import (
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package scheme package scheme
import ( import (
acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,8 @@ SOFTWARE.
package v1 package v1
import ( import (
v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme"
serializer "k8s.io/apimachinery/pkg/runtime/serializer" serializer "k8s.io/apimachinery/pkg/runtime/serializer"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
) )

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package fake package fake
import ( import (
v1 "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"
) )

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package fake package fake
import ( import (
acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
testing "k8s.io/client-go/testing" testing "k8s.io/client-go/testing"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package fake package fake
import ( import (
acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels" labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,8 @@ SOFTWARE.
package v1 package v1
import ( import (
acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
scheme "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" scheme "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
rest "k8s.io/client-go/rest" rest "k8s.io/client-go/rest"
) )

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,8 @@ SOFTWARE.
package v1 package v1
import ( import (
v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
scheme "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" scheme "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types" types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,8 @@ SOFTWARE.
package acid package acid
import ( import (
v1 "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1"
internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces"
) )
// Interface provides access to each of this group's versions. // Interface provides access to each of this group's versions.

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package v1 package v1
import ( import (
internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces"
) )
// Interface provides access to all the informers in this group version. // Interface provides access to all the informers in this group version.

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -27,10 +27,10 @@ package v1
import ( import (
time "time" time "time"
acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" acidzalandov1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
versioned "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces"
v1 "github.com/zalando-incubator/postgres-operator/pkg/generated/listers/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/generated/listers/acid.zalan.do/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch" watch "k8s.io/apimachinery/pkg/watch"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -29,9 +29,9 @@ import (
sync "sync" sync "sync"
time "time" time "time"
versioned "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
acidzalando "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do" acidzalando "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do"
internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -27,7 +27,7 @@ package externalversions
import ( import (
"fmt" "fmt"
v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
schema "k8s.io/apimachinery/pkg/runtime/schema" schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"
) )

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -27,7 +27,7 @@ package internalinterfaces
import ( import (
time "time" time "time"
versioned "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache" cache "k8s.io/client-go/tools/cache"

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2018 Compose, Zalando SE Copyright 2019 Compose, Zalando SE
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -25,7 +25,7 @@ SOFTWARE.
package v1 package v1
import ( import (
v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"

View File

@ -126,6 +126,7 @@ func (n *NamespacedName) Decode(value string) error {
return n.DecodeWorker(value, GetOperatorNamespace()) return n.DecodeWorker(value, GetOperatorNamespace())
} }
// UnmarshalJSON converts a byte slice to NamespacedName
func (n *NamespacedName) UnmarshalJSON(data []byte) error { func (n *NamespacedName) UnmarshalJSON(data []byte) error {
result := NamespacedName{} result := NamespacedName{}
var tmp string var tmp string

View File

@ -7,7 +7,7 @@ import (
"fmt" "fmt"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
) )
// CRD describes CustomResourceDefinition specific configuration parameters // CRD describes CustomResourceDefinition specific configuration parameters
@ -27,6 +27,7 @@ type Resources struct {
PodTerminateGracePeriod time.Duration `name:"pod_terminate_grace_period" default:"5m"` PodTerminateGracePeriod time.Duration `name:"pod_terminate_grace_period" default:"5m"`
PodPriorityClassName string `name:"pod_priority_class_name"` PodPriorityClassName string `name:"pod_priority_class_name"`
ClusterLabels map[string]string `name:"cluster_labels" default:"application:spilo"` ClusterLabels map[string]string `name:"cluster_labels" default:"application:spilo"`
InheritedLabels []string `name:"inherited_labels" default:""`
ClusterNameLabel string `name:"cluster_name_label" default:"cluster-name"` ClusterNameLabel string `name:"cluster_name_label" default:"cluster-name"`
PodRoleLabel string `name:"pod_role_label" default:"spilo-role"` PodRoleLabel string `name:"pod_role_label" default:"spilo-role"`
PodToleration map[string]string `name:"toleration" default:""` PodToleration map[string]string `name:"toleration" default:""`
@ -102,6 +103,9 @@ type Config struct {
EnableAdminRoleForUsers bool `name:"enable_admin_role_for_users" default:"true"` EnableAdminRoleForUsers bool `name:"enable_admin_role_for_users" default:"true"`
EnableMasterLoadBalancer bool `name:"enable_master_load_balancer" default:"true"` EnableMasterLoadBalancer bool `name:"enable_master_load_balancer" default:"true"`
EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"` EnableReplicaLoadBalancer bool `name:"enable_replica_load_balancer" default:"false"`
CustomServiceAnnotations map[string]string `name:"custom_service_annotations"`
EnablePodAntiAffinity bool `name:"enable_pod_antiaffinity" default:"false"`
PodAntiAffinityTopologyKey string `name:"pod_antiaffinity_topology_key" default:"kubernetes.io/hostname"`
// deprecated and kept for backward compatibility // deprecated and kept for backward compatibility
EnableLoadBalancer *bool `name:"enable_load_balancer"` EnableLoadBalancer *bool `name:"enable_load_balancer"`
MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"`

View File

@ -19,6 +19,7 @@ type fieldInfo struct {
Field reflect.Value Field reflect.Value
} }
// StringTemplate is a convenience alias
type StringTemplate string type StringTemplate string
func decoderFrom(field reflect.Value) (d decoder) { func decoderFrom(field reflect.Value) (d decoder) {
@ -221,12 +222,14 @@ func getMapPairsFromString(value string) (pairs []string, err error) {
return return
} }
// Decode cast value to StringTemplate
func (f *StringTemplate) Decode(value string) error { func (f *StringTemplate) Decode(value string) error {
*f = StringTemplate(value) *f = StringTemplate(value)
return nil return nil
} }
// Format formatted string from StringTemplate
func (f *StringTemplate) Format(a ...string) string { func (f *StringTemplate) Format(a ...string) string {
res := string(*f) res := string(*f)
@ -237,6 +240,7 @@ func (f *StringTemplate) Format(a ...string) string {
return res return res
} }
// MarshalJSON converts a StringTemplate to byte slice
func (f StringTemplate) MarshalJSON() ([]byte, error) { func (f StringTemplate) MarshalJSON() ([]byte, error) {
return json.Marshal(string(f)) return json.Marshal(string(f))
} }

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants"
batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1" batchv1beta1 "k8s.io/client-go/kubernetes/typed/batch/v1beta1"
"github.com/zalando/postgres-operator/pkg/util/constants"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
policybeta1 "k8s.io/api/policy/v1beta1" policybeta1 "k8s.io/api/policy/v1beta1"
apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
@ -20,7 +20,7 @@ import (
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
acidv1client "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" acidv1client "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned"
) )
// KubernetesClient describes getters for Kubernetes objects // KubernetesClient describes getters for Kubernetes objects

View File

@ -17,8 +17,10 @@ type Ticker struct {
ticker *time.Ticker ticker *time.Ticker
} }
// Stop is a convenience wrapper around ticker.Stop
func (t *Ticker) Stop() { t.ticker.Stop() } func (t *Ticker) Stop() { t.ticker.Stop() }
// Tick is a convenience wrapper around ticker.C
func (t *Ticker) Tick() { <-t.ticker.C } func (t *Ticker) Tick() { <-t.ticker.C }
// Retry is a wrapper around RetryWorker that provides a real RetryTicker // Retry is a wrapper around RetryWorker that provides a real RetryTicker

View File

@ -43,6 +43,7 @@ type httpClient interface {
Do(req *http.Request) (*http.Response, error) Do(req *http.Request) (*http.Response, error)
} }
// Interface to the TeamsAPIClient
type Interface interface { type Interface interface {
TeamInfo(teamID, token string) (tm *Team, err error) TeamInfo(teamID, token string) (tm *Team, err error)
} }

View File

@ -7,8 +7,8 @@ import (
"reflect" "reflect"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util" "github.com/zalando/postgres-operator/pkg/util"
) )
const ( const (

View File

@ -13,7 +13,7 @@ import (
resource "k8s.io/apimachinery/pkg/api/resource" resource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
) )
const ( const (

View File

@ -8,7 +8,7 @@ import (
"regexp" "regexp"
"github.com/zalando-incubator/postgres-operator/pkg/spec" "github.com/zalando/postgres-operator/pkg/spec"
) )
var pgUsers = []struct { var pgUsers = []struct {

View File

@ -9,8 +9,8 @@ import (
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"github.com/zalando-incubator/postgres-operator/pkg/util/constants" "github.com/zalando/postgres-operator/pkg/util/constants"
"github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" "github.com/zalando/postgres-operator/pkg/util/retryutil"
) )
// EBSVolumeResizer implements volume resizing interface for AWS EBS volumes. // EBSVolumeResizer implements volume resizing interface for AWS EBS volumes.

Some files were not shown because too many files have changed in this diff Show More