diff --git a/.gitignore b/.gitignore index ad08aa383..e09b6644b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ _testmain.go .idea scm-source.json + +# diagrams +*.aux +*.log diff --git a/.travis.yml b/.travis.yml index faeb2cc8b..4901e45ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,5 @@ install: - make deps script: + - hack/verify-codegen.sh - travis_wait 20 goveralls -service=travis-ci -package ./pkg/... -v diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66d2aac99..3a40a700b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Wanna contribute to the Postgres Operator? Yay - here is how! ## Reporting issues 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 diff --git a/Makefile b/Makefile index a13d830e2..5b27281c2 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,7 @@ clean: rm -rf build scm-source.json local: ${SOURCES} + hack/verify-codegen.sh CGO_ENABLED=${CGO_ENABLED} go build -o build/${BINARY} $(LOCAL_BUILD_FLAGS) -ldflags "$(LDFLAGS)" $^ linux: ${SOURCES} @@ -88,4 +89,5 @@ deps: @glide install --strip-vendor test: + hack/verify-codegen.sh @go test ./... diff --git a/README.md b/README.md index d96458eec..d7505477d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,16 @@ # Postgres Operator -[![Build Status](https://travis-ci.org/zalando-incubator/postgres-operator.svg?branch=master)](https://travis-ci.org/zalando-incubator/postgres-operator) -[![Coverage Status](https://coveralls.io/repos/github/zalando-incubator/postgres-operator/badge.svg)](https://coveralls.io/github/zalando-incubator/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) -[![GoDoc](https://godoc.org/github.com/zalando-incubator/postgres-operator?status.svg)](https://godoc.org/github.com/zalando-incubator/postgres-operator) -[![golangci](https://golangci.com/badges/github.com/zalando-incubator/postgres-operator.svg)](https://golangci.com/r/github.com/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/postgres-operator/badge.svg)](https://coveralls.io/github/zalando/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/postgres-operator?status.svg)](https://godoc.org/github.com/zalando/postgres-operator) +[![golangci](https://golangci.com/badges/github.com/zalando/postgres-operator.svg)](https://golangci.com/r/github.com/zalando/postgres-operator) + + + +# 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 @@ -28,8 +34,22 @@ manages PostgreSQL clusters on Kubernetes: 3. Finally, the operator periodically synchronizes the actual state of each Postgres cluster with the desired state defined in the cluster's manifest. -There is a browser-friendly version of this documentation at -[postgres-operator.readthedocs.io](https://postgres-operator.readthedocs.io) +Here is a diagram, that summarizes what would be created by the operator, when a +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 @@ -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. + +## 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 Prerequisites: @@ -58,7 +85,7 @@ built-in Kubernetes support. ### Local execution ```bash -git clone https://github.com/zalando-incubator/postgres-operator.git +git clone https://github.com/zalando/postgres-operator.git cd postgres-operator minikube start diff --git a/build-ci.sh b/build-ci.sh index 71080b220..a4805ad28 100755 --- a/build-ci.sh +++ b/build-ci.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -x -team_repo="$GOPATH/src/github.com/zalando-incubator/" +team_repo="$GOPATH/src/github.com/zalando/" project_dir="$team_repo/postgres-operator" mkdir -p "$team_repo" diff --git a/cmd/main.go b/cmd/main.go index 09ab40a87..7fadd611a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,9 +9,9 @@ import ( "syscall" "time" - "github.com/zalando-incubator/postgres-operator/pkg/controller" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/controller" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" ) var ( diff --git a/delivery.yaml b/delivery.yaml index 5f1f5384f..de043a20d 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -4,7 +4,7 @@ pipeline: type: script env: GOPATH: /root/go - OPERATOR_TOP_DIR: /root/go/src/github.com/zalando-incubator + OPERATOR_TOP_DIR: /root/go/src/github.com/zalando commands: - desc: 'Update' cmd: | diff --git a/docs/administrator.md b/docs/administrator.md index a69dc99cf..208e9ddb9 100644 --- a/docs/administrator.md +++ b/docs/administrator.md @@ -146,6 +146,93 @@ 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 It is possible to configure a ConfigMap which is used by the Postgres pods as diff --git a/docs/developer.md b/docs/developer.md index 220d764d0..8132be018 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -93,14 +93,14 @@ would create a directory for the GOPATH (i.e. ~/go) and place the source code under the ~/go/src subdirectories. Given the schema above, the postgres operator source code located at -`github.com/zalando-incubator/postgres-operator` should be put at --`~/go/src/github.com/zalando-incubator/postgres-operator`. +`github.com/zalando/postgres-operator` should be put at +-`~/go/src/github.com/zalando/postgres-operator`. ```bash $ export GOPATH=~/go - $ mkdir -p ${GOPATH}/src/github.com/zalando-incubator/ - $ cd ${GOPATH}/src/github.com/zalando-incubator/ - $ git clone https://github.com/zalando-incubator/postgres-operator.git + $ mkdir -p ${GOPATH}/src/github.com/zalando/ + $ cd ${GOPATH}/src/github.com/zalando/ + $ git clone https://github.com/zalando/postgres-operator.git ``` ## 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)` 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. * [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 diff --git a/docs/diagrams/Makefile b/docs/diagrams/Makefile new file mode 100644 index 000000000..0c0c7c918 --- /dev/null +++ b/docs/diagrams/Makefile @@ -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 $@ diff --git a/docs/diagrams/logo.png b/docs/diagrams/logo.png new file mode 100644 index 000000000..8b8372fa3 Binary files /dev/null and b/docs/diagrams/logo.png differ diff --git a/docs/diagrams/operator.png b/docs/diagrams/operator.png new file mode 100644 index 000000000..5e1cbfe83 Binary files /dev/null and b/docs/diagrams/operator.png differ diff --git a/docs/diagrams/operator.tex b/docs/diagrams/operator.tex new file mode 100644 index 000000000..a8ee0a05f --- /dev/null +++ b/docs/diagrams/operator.tex @@ -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} diff --git a/docs/diagrams/pod.png b/docs/diagrams/pod.png new file mode 100644 index 000000000..f54d1a2bd Binary files /dev/null and b/docs/diagrams/pod.png differ diff --git a/docs/diagrams/pod.tex b/docs/diagrams/pod.tex new file mode 100644 index 000000000..f4451399a --- /dev/null +++ b/docs/diagrams/pod.tex @@ -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} diff --git a/docs/gsoc-2019/ideas.md b/docs/gsoc-2019/ideas.md new file mode 100644 index 000000000..23a3e3eb7 --- /dev/null +++ b/docs/gsoc-2019/ideas.md @@ -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). \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index e038f713e..5b8479a91 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,10 +8,10 @@ manages PostgreSQL clusters on Kubernetes: user submits a new manifest, the operator fetches that manifest and spawns a new Postgres cluster along with all necessary entities such as Kubernetes StatefulSets and Postgres roles. See this - [Postgres cluster manifest](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. -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 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 @@ -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 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 -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) diff --git a/docs/quickstart.md b/docs/quickstart.md index 7b9c667e1..7b662e420 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -13,7 +13,7 @@ built-in Kubernetes support. ## Local execution ```bash -git clone https://github.com/zalando-incubator/postgres-operator.git +git clone https://github.com/zalando/postgres-operator.git cd postgres-operator minikube start diff --git a/docs/reference/cluster_manifest.md b/docs/reference/cluster_manifest.md index efc850aff..f1491525d 100644 --- a/docs/reference/cluster_manifest.md +++ b/docs/reference/cluster_manifest.md @@ -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 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 -[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 -[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. When Kubernetes resources, such as memory, CPU or volumes, are configured, @@ -33,7 +33,15 @@ Those parameters are grouped under the `metadata` top-level key. services, secrets) for the cluster. Changing it after the cluster creation results in deploying or updating a completely separate cluster in the target 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 @@ -89,7 +97,7 @@ Those are parameters grouped directly under the `spec` key in the manifest. examples](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) for details on tolerations and possible values of those keys. When set, this value overrides the `pod_toleration` setting from the operator. Optional. - + * **podPriorityClassName** a name of the [priority class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass) @@ -135,7 +143,7 @@ explanation of `ttl` and `loop_wait` parameters. a map of key-value pairs describing initdb parameters. For `data-checksum`, `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 - affect the already initialized clusters. Optional. + affect the already initialized clusters. Optional. * **pg_hba** list of custom `pg_hba` lines to replace default ones. Note that the default @@ -215,7 +223,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 to guarantee uniqueness. Has no effect when cloning from the running clusters. Optional. - + * **timestamp** the timestamp up to which the recovery should proceed. The operator always configures non-inclusive recovery target, stopping right before the given @@ -235,7 +243,7 @@ properties of the persistent storage that stores postgres data. the name of the Kubernetes storage class to draw the persistent volume from. See [Kubernetes 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 diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 8e2793023..4fee044f8 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -8,20 +8,20 @@ configuration. maps. String values containing ':' should be enclosed in quotes. The configuration is flat, parameter group names below are not reflected in the 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 manifest. The manifest is an instance of the custom resource definition (CRD) called - `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 + `OperatorConfiguration`. The operator registers this CRD + 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. 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 not supplied in the configuration receives an empty value. In order to 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. 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 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** name of the label assigned to Kubernetes objects created by the operator that indicates which cluster a given object belongs to. The default is @@ -198,7 +206,7 @@ configuration they are grouped under the `kubernetes` key. All variables from that ConfigMap are injected to the pod's environment, on conflicts they are overridden by the environment variables generated by the operator. The default is empty. - + * **pod_priority_class_name** a name of the [priority class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass) @@ -209,7 +217,15 @@ configuration they are grouped under the `kubernetes` key. The period of time to wait for the success of Patroni switchovers from master pods on an unschedulable node to their respective replicas on healthy nodes. The situation where master pods still exist on the old node after this timeout expires has to be fixed manually. The default is 10 minutes. - + +* **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 @@ -234,7 +250,7 @@ CRD-based configuration. settings. The default is `1Gi`. * **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** Instruct operator to start any new database pod without limitations on shm @@ -355,7 +371,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 access to the postgres database, i.e. creating databases and users. The default is `true`. - + ## Automatic creation of human users in the database Options to automate creation of human users with the aid of the teams API @@ -453,4 +469,4 @@ scalyr sidecar. In the CRD-based configuration they are grouped under the Memory limit value for the Scalyr sidecar. The default is `1Gi`. -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) \ No newline at end of file +For the configmap operator configuration, the [default parameter values](https://github.com/zalando/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/postgres-operator/blob/master/manifests/postgresql-operator-default-configuration.yaml) diff --git a/docs/user.md b/docs/user.md index 8c93449c3..a0569fe2b 100644 --- a/docs/user.md +++ b/docs/user.md @@ -1,7 +1,7 @@ ## Create a manifest for a new PostgreSQL cluster 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 apiVersion: "acid.zalan.do/v1" @@ -68,7 +68,7 @@ In the next sections, we will cover those use cases in more details. ## Manifest roles 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` flags. @@ -158,8 +158,8 @@ 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 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) -and [infrastructure roles configmap](https://github.com/zalando-incubator/postgres-operator/blob/master/manifests/infrastructure-roles-configmap.yaml) for the examples. +See [infrastructure roles secret](https://github.com/zalando/postgres-operator/blob/master/manifests/infrastructure-roles.yaml) +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 @@ -273,6 +273,32 @@ are always passed to sidecars: 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 PostgreSQL operator supports statefulset volume resize if you're using the diff --git a/glide.lock b/glide.lock index acedb47f5..8b8f2814d 100644 --- a/glide.lock +++ b/glide.lock @@ -1,8 +1,8 @@ -hash: bd5394acf101795aac9da20c104a57344a6c4fd71080bf1b16845367e6360578 -updated: 2018-08-14T15:18:08.144086+02:00 +hash: e4d0d48b4142d5d335e48e030621564207f3aa288ea1e41e0d1e4d29135de3e8 +updated: 2019-02-25T14:54:51.736946406+01:00 imports: - name: github.com/aws/aws-sdk-go - version: f831d5a0822a1ad72420ab18c6269bca1ddaf490 + version: e8b22c9937cae1fee9bc364a88f3752cc4d1ac2f subpackages: - aws - aws/awserr @@ -13,6 +13,7 @@ imports: - aws/credentials - aws/credentials/ec2rolecreds - aws/credentials/endpointcreds + - aws/credentials/processcreds - aws/credentials/stscreds - aws/csm - aws/defaults @@ -21,6 +22,7 @@ imports: - aws/request - aws/session - aws/signer/v4 + - internal/ini - internal/sdkio - internal/sdkrand - internal/sdkuri @@ -43,8 +45,6 @@ imports: - spdy - name: github.com/ghodss/yaml version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee -- name: github.com/go-ini/ini - version: d58d458bec3cb5adec4b7ddb41131855eac0b33f - name: github.com/gogo/protobuf version: c0656edd0d9eab7c66d1eb0c568f9039345796f7 subpackages: @@ -84,6 +84,8 @@ imports: version: c2b33e8439af944379acbdd9c3a5fe0bc44bd8a5 - name: github.com/json-iterator/go version: f2b4162afba35581b6d4a50d3b8f34e33c144682 +- name: github.com/konsorten/go-windows-terminal-sequences + version: 5c8c8bd35d3832f5d134ae1e1e375b69a4d25242 - name: github.com/kr/text version: e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f - name: github.com/lib/pq @@ -101,12 +103,14 @@ imports: - name: github.com/peterbourgon/diskv version: 5f041e8faa004a95c88a202771f4cc3e991971e6 - name: github.com/sirupsen/logrus - version: 3e01752db0189b9157070a0e1668a620f9a85da2 + version: e1e72e9de974bd926e5c56f83753fba2df402ce5 - name: github.com/spf13/pflag version: 583c0c0531f06d5278b7d917446061adc344b5cd - name: golang.org/x/crypto - version: c126467f60eb25f8f27e5a981f32a87e3965053f + version: 49796115aa4b964c318aad4f3084fdb41e9aa067 subpackages: + - bcrypt + - blowfish - ssh/terminal - name: golang.org/x/net version: 1c05540f6879653db88113bc4a2b70aec4bd491f @@ -139,6 +143,7 @@ imports: - name: k8s.io/api version: 2d6f90ab1293a1fb871cf149423ebb72aa7423aa subpackages: + - admission/v1beta1 - admissionregistration/v1alpha1 - admissionregistration/v1beta1 - apps/v1 @@ -157,7 +162,6 @@ imports: - core/v1 - events/v1beta1 - extensions/v1beta1 - - imagepolicy/v1alpha1 - networking/v1 - policy/v1beta1 - rbac/v1 @@ -296,5 +300,9 @@ imports: - name: k8s.io/kube-openapi version: 91cfa479c814065e420cee7ed227db0f63a5854e subpackages: + - pkg/builder + - pkg/common + - pkg/handler + - pkg/util - pkg/util/proto testImports: [] diff --git a/glide.yaml b/glide.yaml index 41d8dee29..986970887 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,4 +1,4 @@ -package: github.com/zalando-incubator/postgres-operator +package: github.com/zalando/postgres-operator import: - package: github.com/sirupsen/logrus version: ^1.0.1 diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index a1c1555c9..70f041d07 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -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)} 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 \ --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt diff --git a/manifests/complete-postgres-manifest.yaml b/manifests/complete-postgres-manifest.yaml index c5f80f373..4a4c6078a 100644 --- a/manifests/complete-postgres-manifest.yaml +++ b/manifests/complete-postgres-manifest.yaml @@ -4,6 +4,10 @@ kind: postgresql metadata: name: acid-test-cluster spec: + init_containers: + - name: date + image: busybox + command: [ "/bin/date" ] teamId: "ACID" volume: size: 1Gi diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index f49cbe71d..97ff9a2b2 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -10,7 +10,7 @@ data: debug_logging: "true" 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" secret_name_template: '{username}.{cluster}.credentials' super_username: postgres diff --git a/manifests/minimal-postgres-manifest.yaml b/manifests/minimal-postgres-manifest.yaml index 402946b09..37d772567 100644 --- a/manifests/minimal-postgres-manifest.yaml +++ b/manifests/minimal-postgres-manifest.yaml @@ -2,7 +2,7 @@ apiVersion: "acid.zalan.do/v1" kind: postgresql metadata: name: acid-minimal-cluster - namespace: test # assumes namespace exists beforehand + namespace: default spec: teamId: "ACID" volume: diff --git a/manifests/postgres-operator.yaml b/manifests/postgres-operator.yaml index fffb8ede8..d43c0f8a8 100644 --- a/manifests/postgres-operator.yaml +++ b/manifests/postgres-operator.yaml @@ -12,7 +12,7 @@ spec: serviceAccountName: zalando-postgres-operator containers: - 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 resources: requests: diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index cba8ea38e..5b9de1073 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -25,8 +25,11 @@ configuration: pod_role_label: spilo-role cluster_labels: application: spilo + # inherited_labels: + # - application + # - app cluster_name_label: cluster-name - # watched_namespace:"" + # watched_namespace:"" # node_readiness_label: "" # toleration: {} # infrastructure_roles_secret_name: "" @@ -53,7 +56,7 @@ configuration: replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}" aws_or_gcp: # db_hosted_zone: "" - # wal_s3_bucket: "" + # wal_s3_bucket: "" # log_s3_bucket: "" # kube_iam_role: "" aws_region: eu-central-1 @@ -62,13 +65,13 @@ configuration: enable_database_access: true teams_api: enable_teams_api: false - team_api_role_configuration: + team_api_role_configuration: log_statement: all enable_team_superuser: false team_admin_role: admin pam_role_name: zalandos # pam_configuration: "" - protected_role_names: + protected_role_names: - admin # teams_api_url: "" # postgres_superuser_teams: "postgres_superusers" diff --git a/mkdocs.yml b/mkdocs.yml index e50107eed..635f08816 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ site_name: Postgres Operator -repo_url: https://github.com/zalando-incubator/postgres-operator +repo_url: https://github.com/zalando/postgres-operator theme: readthedocs pages: diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 5f1704527..a77f490f0 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -1,7 +1,7 @@ package v1 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" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index d4654d9c8..3c406d2e3 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -1,11 +1,11 @@ package v1 import ( - "github.com/zalando-incubator/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/config" "time" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/spec" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -52,6 +52,7 @@ type KubernetesMetaConfiguration struct { InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"` PodRoleLabel string `json:"pod_role_label,omitempty"` ClusterLabels map[string]string `json:"cluster_labels,omitempty"` + InheritedLabels []string `json:"inherited_labels,omitempty"` ClusterNameLabel string `json:"cluster_name_label,omitempty"` NodeReadinessLabel map[string]string `json:"node_readiness_label,omitempty"` // TODO: use a proper toleration structure? @@ -60,6 +61,8 @@ type KubernetesMetaConfiguration struct { PodEnvironmentConfigMap string `json:"pod_environment_configmap,omitempty"` PodPriorityClassName string `json:"pod_priority_class_name,omitempty"` MasterPodMoveTimeout time.Duration `json:"master_pod_move_timeout,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 diff --git a/pkg/apis/acid.zalan.do/v1/postgresql_type.go b/pkg/apis/acid.zalan.do/v1/postgresql_type.go index 4315faeca..ccd7fe08c 100644 --- a/pkg/apis/acid.zalan.do/v1/postgresql_type.go +++ b/pkg/apis/acid.zalan.do/v1/postgresql_type.go @@ -51,6 +51,7 @@ type PostgresSpec struct { Databases map[string]string `json:"databases,omitempty"` Tolerations []v1.Toleration `json:"tolerations,omitempty"` Sidecars []Sidecar `json:"sidecars,omitempty"` + InitContainers []v1.Container `json:"init_containers,omitempty"` PodPriorityClassName string `json:"pod_priority_class_name,omitempty"` ShmVolume *bool `json:"enableShmVolume,omitempty"` } diff --git a/pkg/apis/acid.zalan.do/v1/register.go b/pkg/apis/acid.zalan.do/v1/register.go index 165981a68..ed0add91d 100644 --- a/pkg/apis/acid.zalan.do/v1/register.go +++ b/pkg/apis/acid.zalan.do/v1/register.go @@ -5,7 +5,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "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 diff --git a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go index 55a5ac075..c396dd493 100644 --- a/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go +++ b/pkg/apis/acid.zalan.do/v1/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ // +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 of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ SOFTWARE. package v1 import ( - corev1 "k8s.io/api/core/v1" + core_v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -75,6 +75,11 @@ func (in *KubernetesMetaConfiguration) DeepCopyInto(out *KubernetesMetaConfigura (*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 { in, out := &in.NodeReadinessLabel, &out.NodeReadinessLabel *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. func (in *LoadBalancerConfiguration) DeepCopyInto(out *LoadBalancerConfiguration) { *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 } @@ -193,7 +205,7 @@ func (in *OperatorConfigurationData) DeepCopyInto(out *OperatorConfigurationData in.Kubernetes.DeepCopyInto(&out.Kubernetes) out.PostgresPodResources = in.PostgresPodResources out.Timeouts = in.Timeouts - out.LoadBalancer = in.LoadBalancer + in.LoadBalancer.DeepCopyInto(&out.LoadBalancer) out.AWSGCP = in.AWSGCP out.OperatorDebug = in.OperatorDebug in.TeamsAPI.DeepCopyInto(&out.TeamsAPI) @@ -324,17 +336,7 @@ func (in *Patroni) DeepCopyInto(out *Patroni) { in, out := &in.Slots, &out.Slots *out = make(map[string]map[string]string, len(*in)) for key, val := range *in { - var outVal map[string]string - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - (*out)[key] = outVal + (*out)[key] = *val.DeepCopy() } } return @@ -375,23 +377,39 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { out.Resources = in.Resources if in.EnableMasterLoadBalancer != nil { in, out := &in.EnableMasterLoadBalancer, &out.EnableMasterLoadBalancer - *out = new(bool) - **out = **in + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } } if in.EnableReplicaLoadBalancer != nil { in, out := &in.EnableReplicaLoadBalancer, &out.EnableReplicaLoadBalancer - *out = new(bool) - **out = **in + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } } if in.UseLoadBalancer != nil { in, out := &in.UseLoadBalancer, &out.UseLoadBalancer - *out = new(bool) - **out = **in + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } } if in.ReplicaLoadBalancer != nil { in, out := &in.ReplicaLoadBalancer, &out.ReplicaLoadBalancer - *out = new(bool) - **out = **in + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } } if in.AllowedSourceRanges != nil { in, out := &in.AllowedSourceRanges, &out.AllowedSourceRanges @@ -402,15 +420,12 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { in, out := &in.Users, &out.Users *out = make(map[string]UserFlags, len(*in)) for key, val := range *in { - var outVal []string if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal - *out = make(UserFlags, len(*in)) - copy(*out, *in) + (*out)[key] = make([]string, len(val)) + copy((*out)[key], val) } - (*out)[key] = outVal } } if in.MaintenanceWindows != nil { @@ -430,7 +445,7 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations - *out = make([]corev1.Toleration, len(*in)) + *out = make([]core_v1.Toleration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -442,6 +457,22 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.InitContainers != nil { + in, out := &in.InitContainers, &out.InitContainers + *out = make([]core_v1.Container, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ShmVolume != nil { + in, out := &in.ShmVolume, &out.ShmVolume + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } + } return } @@ -610,12 +641,12 @@ func (in *Sidecar) DeepCopyInto(out *Sidecar) { out.Resources = in.Resources if in.Ports != nil { in, out := &in.Ports, &out.Ports - *out = make([]corev1.ContainerPort, len(*in)) + *out = make([]core_v1.ContainerPort, len(*in)) copy(*out, *in) } if in.Env != nil { in, out := &in.Env, &out.Env - *out = make([]corev1.EnvVar, len(*in)) + *out = make([]core_v1.EnvVar, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index a6f4e09ce..c0fa1f349 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -13,10 +13,10 @@ import ( "github.com/sirupsen/logrus" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/config" ) const ( diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 93a67226f..d4680cec0 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -21,15 +21,15 @@ import ( "encoding/json" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/patroni" - "github.com/zalando-incubator/postgres-operator/pkg/util/teams" - "github.com/zalando-incubator/postgres-operator/pkg/util/users" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/util/patroni" + "github.com/zalando/postgres-operator/pkg/util/teams" + "github.com/zalando/postgres-operator/pkg/util/users" rbacv1beta1 "k8s.io/api/rbac/v1beta1" ) @@ -494,7 +494,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error { defer func() { if updateFailed { c.setStatus(acidv1.ClusterStatusUpdateFailed) - } else if c.Status != acidv1.ClusterStatusRunning { + } else { c.setStatus(acidv1.ClusterStatusRunning) } }() diff --git a/pkg/cluster/cluster_test.go b/pkg/cluster/cluster_test.go index acf17ace6..5ff00c7b3 100644 --- a/pkg/cluster/cluster_test.go +++ b/pkg/cluster/cluster_test.go @@ -6,11 +6,11 @@ import ( "testing" "github.com/sirupsen/logrus" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/teams" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/util/teams" "k8s.io/api/core/v1" ) diff --git a/pkg/cluster/database.go b/pkg/cluster/database.go index 9441a4933..a4633537d 100644 --- a/pkg/cluster/database.go +++ b/pkg/cluster/database.go @@ -9,9 +9,9 @@ import ( "github.com/lib/pq" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/retryutil" ) const ( diff --git a/pkg/cluster/exec.go b/pkg/cluster/exec.go index ef1ad0795..8dd6bd91d 100644 --- a/pkg/cluster/exec.go +++ b/pkg/cluster/exec.go @@ -10,8 +10,8 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/remotecommand" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/constants" ) //ExecCommand executes arbitrary command inside the pod diff --git a/pkg/cluster/filesystems.go b/pkg/cluster/filesystems.go index 65e7048c7..a34e5a90e 100644 --- a/pkg/cluster/filesystems.go +++ b/pkg/cluster/filesystems.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/filesystems" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/filesystems" ) func (c *Cluster) getPostgresFilesystemInfo(podName *spec.NamespacedName) (device, fstype string, err error) { diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 681795d2f..0540dcf90 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -15,11 +15,11 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/constants" "k8s.io/apimachinery/pkg/labels" ) @@ -290,6 +290,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 { // allow to override tolerations by postgresql manifest if len(*tolerationsSpec) > 0 { @@ -410,6 +430,7 @@ func generatePodTemplate( namespace string, labels labels.Set, spiloContainer *v1.Container, + initContainers []v1.Container, sidecarContainers []v1.Container, tolerationsSpec *[]v1.Toleration, nodeAffinity *v1.Affinity, @@ -418,6 +439,8 @@ func generatePodTemplate( kubeIAMRole string, priorityClassName string, shmVolume bool, + podAntiAffinity bool, + podAntiAffinityTopologyKey string, ) (*v1.PodTemplateSpec, error) { terminateGracePeriodSeconds := terminateGracePeriod @@ -428,6 +451,7 @@ func generatePodTemplate( ServiceAccountName: podServiceAccountName, TerminationGracePeriodSeconds: &terminateGracePeriodSeconds, Containers: containers, + InitContainers: initContainers, Tolerations: *tolerationsSpec, } @@ -435,7 +459,9 @@ func generatePodTemplate( addShmVolume(&podSpec) } - if nodeAffinity != nil { + if podAntiAffinity { + podSpec.Affinity = generatePodAffinity(labels, podAntiAffinityTopologyKey, nodeAffinity) + } else if nodeAffinity != nil { podSpec.Affinity = nodeAffinity } @@ -803,6 +829,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*v1beta1.State c.Namespace, c.labelsSet(true), spiloContainer, + spec.InitContainers, sidecarContainers, &tolerationSpec, nodeAffinity(c.OpConfig.NodeReadinessLabel), @@ -810,7 +837,9 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*v1beta1.State c.OpConfig.PodServiceAccountName, c.OpConfig.KubeIAMRole, 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) } @@ -1070,7 +1099,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec) } if role == Replica { - serviceSpec.Selector = c.roleLabelsSet(role) + serviceSpec.Selector = c.roleLabelsSet(false, role) } var annotations map[string]string @@ -1110,7 +1139,7 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec) ObjectMeta: metav1.ObjectMeta{ Name: c.serviceName(role), Namespace: c.Namespace, - Labels: c.roleLabelsSet(role), + Labels: c.roleLabelsSet(true, role), Annotations: annotations, }, Spec: serviceSpec, @@ -1124,7 +1153,7 @@ func (c *Cluster) generateEndpoint(role PostgresRole, subsets []v1.EndpointSubse ObjectMeta: metav1.ObjectMeta{ Name: c.endpointName(role), Namespace: c.Namespace, - Labels: c.roleLabelsSet(role), + Labels: c.roleLabelsSet(true, role), }, } if len(subsets) > 0 { @@ -1188,7 +1217,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policybeta1.PodDisruptionBudget Spec: policybeta1.PodDisruptionBudgetSpec{ MinAvailable: &minAvailable, Selector: &metav1.LabelSelector{ - MatchLabels: c.roleLabelsSet(Master), + MatchLabels: c.roleLabelsSet(false, Master), }, }, } diff --git a/pkg/cluster/k8sres_test.go b/pkg/cluster/k8sres_test.go index 92946ab2b..73af5a3d3 100644 --- a/pkg/cluster/k8sres_test.go +++ b/pkg/cluster/k8sres_test.go @@ -3,10 +3,10 @@ package cluster import ( "k8s.io/api/core/v1" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" "testing" ) diff --git a/pkg/cluster/pod.go b/pkg/cluster/pod.go index 7fc068bf2..8beb561ec 100644 --- a/pkg/cluster/pod.go +++ b/pkg/cluster/pod.go @@ -7,8 +7,8 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" "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) { listOptions := metav1.ListOptions{ - LabelSelector: c.roleLabelsSet(role).String(), + LabelSelector: c.roleLabelsSet(false, role).String(), } pods, err := c.KubeClient.Pods(c.Namespace).List(listOptions) diff --git a/pkg/cluster/resources.go b/pkg/cluster/resources.go index 886a4bac9..18c295804 100644 --- a/pkg/cluster/resources.go +++ b/pkg/cluster/resources.go @@ -11,10 +11,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/util/retryutil" ) const ( diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 4744faf9c..d2157c8a2 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -7,12 +7,12 @@ import ( policybeta1 "k8s.io/api/policy/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/volumes" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "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. diff --git a/pkg/cluster/types.go b/pkg/cluster/types.go index 681f99e1f..5fd5029db 100644 --- a/pkg/cluster/types.go +++ b/pkg/cluster/types.go @@ -3,7 +3,7 @@ package cluster import ( "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" "k8s.io/api/apps/v1beta1" "k8s.io/api/core/v1" policybeta1 "k8s.io/api/policy/v1beta1" diff --git a/pkg/cluster/util.go b/pkg/cluster/util.go index f6e2ff096..93268cb93 100644 --- a/pkg/cluster/util.go +++ b/pkg/cluster/util.go @@ -17,13 +17,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" - acidzalando "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" + acidzalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/util/retryutil" ) // OAuthTokenGetter provides the method for fetching OAuth tokens @@ -389,6 +389,19 @@ func (c *Cluster) labelsSet(shouldAddExtraLabels bool) labels.Set { if shouldAddExtraLabels { // enables filtering resources owned by a team 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) @@ -398,8 +411,8 @@ func (c *Cluster) labelsSelector() *metav1.LabelSelector { return &metav1.LabelSelector{MatchLabels: c.labelsSet(false), MatchExpressions: nil} } -func (c *Cluster) roleLabelsSet(role PostgresRole) labels.Set { - lbls := c.labelsSet(false) +func (c *Cluster) roleLabelsSet(shouldAddExtraLabels bool, role PostgresRole) labels.Set { + lbls := c.labelsSet(shouldAddExtraLabels) lbls[c.OpConfig.PodRoleLabel] = string(role) return lbls } diff --git a/pkg/cluster/volumes.go b/pkg/cluster/volumes.go index 9816116c2..57f8ca7e3 100644 --- a/pkg/cluster/volumes.go +++ b/pkg/cluster/volumes.go @@ -9,12 +9,12 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/filesystems" - "github.com/zalando-incubator/postgres-operator/pkg/util/volumes" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/filesystems" + "github.com/zalando/postgres-operator/pkg/util/volumes" ) func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) { diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index fd1c099de..9b30f89a1 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -13,16 +13,16 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/cache" - "github.com/zalando-incubator/postgres-operator/pkg/apiserver" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/ringlog" + "github.com/zalando/postgres-operator/pkg/apiserver" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "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 diff --git a/pkg/controller/logs_and_api.go b/pkg/controller/logs_and_api.go index 3e5f20759..24e73fabe 100644 --- a/pkg/controller/logs_and_api.go +++ b/pkg/controller/logs_and_api.go @@ -7,10 +7,10 @@ import ( "github.com/sirupsen/logrus" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/config" "k8s.io/apimachinery/pkg/types" ) diff --git a/pkg/controller/node.go b/pkg/controller/node.go index 59310dd14..406741a17 100644 --- a/pkg/controller/node.go +++ b/pkg/controller/node.go @@ -11,8 +11,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/util" ) func (c *Controller) nodeListFunc(options metav1.ListOptions) (runtime.Object, error) { diff --git a/pkg/controller/node_test.go b/pkg/controller/node_test.go index 06e20093b..c0ec78aa8 100644 --- a/pkg/controller/node_test.go +++ b/pkg/controller/node_test.go @@ -3,7 +3,7 @@ package controller import ( "testing" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/spec" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index e89a782c4..85535fa32 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -5,8 +5,8 @@ import ( "time" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/util/config" 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.PodServiceAccountDefinition = fromCRD.Kubernetes.PodServiceAccountDefinition result.PodServiceAccountRoleBindingDefinition = fromCRD.Kubernetes.PodServiceAccountRoleBindingDefinition + result.PodEnvironmentConfigMap = fromCRD.Kubernetes.PodEnvironmentConfigMap result.PodTerminateGracePeriod = time.Duration(fromCRD.Kubernetes.PodTerminateGracePeriod) result.WatchedNamespace = fromCRD.Kubernetes.WatchedNamespace result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat @@ -47,11 +48,15 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.InfrastructureRolesSecretName = fromCRD.Kubernetes.InfrastructureRolesSecretName result.PodRoleLabel = fromCRD.Kubernetes.PodRoleLabel result.ClusterLabels = fromCRD.Kubernetes.ClusterLabels + result.InheritedLabels = fromCRD.Kubernetes.InheritedLabels result.ClusterNameLabel = fromCRD.Kubernetes.ClusterNameLabel result.NodeReadinessLabel = fromCRD.Kubernetes.NodeReadinessLabel result.PodPriorityClassName = fromCRD.Kubernetes.PodPriorityClassName result.MasterPodMoveTimeout = fromCRD.Kubernetes.MasterPodMoveTimeout + result.EnablePodAntiAffinity = fromCRD.Kubernetes.EnablePodAntiAffinity; + result.PodAntiAffinityTopologyKey = fromCRD.Kubernetes.PodAntiAffinityTopologyKey; + result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest result.DefaultMemoryRequest = fromCRD.PostgresPodResources.DefaultMemoryRequest result.DefaultCPULimit = fromCRD.PostgresPodResources.DefaultCPULimit diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index d2e12eb30..27fd6c956 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -6,9 +6,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" "k8s.io/apimachinery/pkg/types" ) diff --git a/pkg/controller/postgresql.go b/pkg/controller/postgresql.go index e551930bd..dc082ffab 100644 --- a/pkg/controller/postgresql.go +++ b/pkg/controller/postgresql.go @@ -14,12 +14,12 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/cache" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" - "github.com/zalando-incubator/postgres-operator/pkg/util/ringlog" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/util/ringlog" ) func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) { diff --git a/pkg/controller/postgresql_test.go b/pkg/controller/postgresql_test.go index c3a74be74..3d7785f92 100644 --- a/pkg/controller/postgresql_test.go +++ b/pkg/controller/postgresql_test.go @@ -1,8 +1,8 @@ package controller import ( - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/spec" "reflect" "testing" ) diff --git a/pkg/controller/types.go b/pkg/controller/types.go index c412eb66e..0d86abec8 100644 --- a/pkg/controller/types.go +++ b/pkg/controller/types.go @@ -4,7 +4,7 @@ import ( "k8s.io/apimachinery/pkg/types" "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 diff --git a/pkg/controller/util.go b/pkg/controller/util.go index 525fb2d30..57633ae82 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -8,11 +8,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" - acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/cluster" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/config" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" + acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/cluster" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/config" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" "gopkg.in/yaml.v2" ) diff --git a/pkg/controller/util_test.go b/pkg/controller/util_test.go index 58253633b..cb782904c 100644 --- a/pkg/controller/util_test.go +++ b/pkg/controller/util_test.go @@ -10,8 +10,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1core "k8s.io/client-go/kubernetes/typed/core/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util/k8sutil" ) const ( diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index d42fa3b21..6969f794c 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package versioned 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" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" diff --git a/pkg/generated/clientset/versioned/doc.go b/pkg/generated/clientset/versioned/doc.go index 4ef8c1bb8..d514b90a4 100644 --- a/pkg/generated/clientset/versioned/doc.go +++ b/pkg/generated/clientset/versioned/doc.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 19d9ab805..861059b11 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,9 +25,9 @@ SOFTWARE. package fake import ( - clientset "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" - acidv1 "github.com/zalando-incubator/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" + clientset "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned" + acidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1" + 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/watch" "k8s.io/client-go/discovery" diff --git a/pkg/generated/clientset/versioned/fake/doc.go b/pkg/generated/clientset/versioned/fake/doc.go index c249c43fa..960df4951 100644 --- a/pkg/generated/clientset/versioned/fake/doc.go +++ b/pkg/generated/clientset/versioned/fake/doc.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 5269b757a..8e6179239 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package fake 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" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/clientset/versioned/scheme/doc.go b/pkg/generated/clientset/versioned/scheme/doc.go index d17209947..ea0df2783 100644 --- a/pkg/generated/clientset/versioned/scheme/doc.go +++ b/pkg/generated/clientset/versioned/scheme/doc.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 346cd4b16..eec31f1c7 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package scheme 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" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/acid.zalan.do_client.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/acid.zalan.do_client.go index 4e73a425f..cf324cc2d 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/acid.zalan.do_client.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/acid.zalan.do_client.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,8 @@ SOFTWARE. package v1 import ( - v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" + v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/doc.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/doc.go index 97d91a36a..8bff3bf2d 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/doc.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/doc.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/doc.go index 58640649f..c9373b6d8 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/doc.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/doc.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_acid.zalan.do_client.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_acid.zalan.do_client.go index 9d401ef7c..31f2ec817 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_acid.zalan.do_client.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_acid.zalan.do_client.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package fake 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" testing "k8s.io/client-go/testing" ) diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_operatorconfiguration.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_operatorconfiguration.go index b2fada626..a5c15cf9d 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_operatorconfiguration.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_operatorconfiguration.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package fake import ( - acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" + acid_zalan_do_v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" schema "k8s.io/apimachinery/pkg/runtime/schema" testing "k8s.io/client-go/testing" @@ -42,12 +42,12 @@ var operatorconfigurationsResource = schema.GroupVersionResource{Group: "acid.za var operatorconfigurationsKind = schema.GroupVersionKind{Group: "acid.zalan.do", Version: "v1", Kind: "OperatorConfiguration"} // Get takes name of the operatorConfiguration, and returns the corresponding operatorConfiguration object, and an error if there is any. -func (c *FakeOperatorConfigurations) Get(name string, options v1.GetOptions) (result *acidzalandov1.OperatorConfiguration, err error) { +func (c *FakeOperatorConfigurations) Get(name string, options v1.GetOptions) (result *acid_zalan_do_v1.OperatorConfiguration, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(operatorconfigurationsResource, c.ns, name), &acidzalandov1.OperatorConfiguration{}) + Invokes(testing.NewGetAction(operatorconfigurationsResource, c.ns, name), &acid_zalan_do_v1.OperatorConfiguration{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.OperatorConfiguration), err + return obj.(*acid_zalan_do_v1.OperatorConfiguration), err } diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_postgresql.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_postgresql.go index 6feb72eb8..e8d434e55 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_postgresql.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/fake/fake_postgresql.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package fake import ( - acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" + acid_zalan_do_v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -45,20 +45,20 @@ var postgresqlsResource = schema.GroupVersionResource{Group: "acid.zalan.do", Ve var postgresqlsKind = schema.GroupVersionKind{Group: "acid.zalan.do", Version: "v1", Kind: "Postgresql"} // Get takes name of the postgresql, and returns the corresponding postgresql object, and an error if there is any. -func (c *FakePostgresqls) Get(name string, options v1.GetOptions) (result *acidzalandov1.Postgresql, err error) { +func (c *FakePostgresqls) Get(name string, options v1.GetOptions) (result *acid_zalan_do_v1.Postgresql, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(postgresqlsResource, c.ns, name), &acidzalandov1.Postgresql{}) + Invokes(testing.NewGetAction(postgresqlsResource, c.ns, name), &acid_zalan_do_v1.Postgresql{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.Postgresql), err + return obj.(*acid_zalan_do_v1.Postgresql), err } // List takes label and field selectors, and returns the list of Postgresqls that match those selectors. -func (c *FakePostgresqls) List(opts v1.ListOptions) (result *acidzalandov1.PostgresqlList, err error) { +func (c *FakePostgresqls) List(opts v1.ListOptions) (result *acid_zalan_do_v1.PostgresqlList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(postgresqlsResource, postgresqlsKind, c.ns, opts), &acidzalandov1.PostgresqlList{}) + Invokes(testing.NewListAction(postgresqlsResource, postgresqlsKind, c.ns, opts), &acid_zalan_do_v1.PostgresqlList{}) if obj == nil { return nil, err @@ -68,8 +68,8 @@ func (c *FakePostgresqls) List(opts v1.ListOptions) (result *acidzalandov1.Postg if label == nil { label = labels.Everything() } - list := &acidzalandov1.PostgresqlList{ListMeta: obj.(*acidzalandov1.PostgresqlList).ListMeta} - for _, item := range obj.(*acidzalandov1.PostgresqlList).Items { + list := &acid_zalan_do_v1.PostgresqlList{ListMeta: obj.(*acid_zalan_do_v1.PostgresqlList).ListMeta} + for _, item := range obj.(*acid_zalan_do_v1.PostgresqlList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -85,43 +85,43 @@ func (c *FakePostgresqls) Watch(opts v1.ListOptions) (watch.Interface, error) { } // Create takes the representation of a postgresql and creates it. Returns the server's representation of the postgresql, and an error, if there is any. -func (c *FakePostgresqls) Create(postgresql *acidzalandov1.Postgresql) (result *acidzalandov1.Postgresql, err error) { +func (c *FakePostgresqls) Create(postgresql *acid_zalan_do_v1.Postgresql) (result *acid_zalan_do_v1.Postgresql, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(postgresqlsResource, c.ns, postgresql), &acidzalandov1.Postgresql{}) + Invokes(testing.NewCreateAction(postgresqlsResource, c.ns, postgresql), &acid_zalan_do_v1.Postgresql{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.Postgresql), err + return obj.(*acid_zalan_do_v1.Postgresql), err } // Update takes the representation of a postgresql and updates it. Returns the server's representation of the postgresql, and an error, if there is any. -func (c *FakePostgresqls) Update(postgresql *acidzalandov1.Postgresql) (result *acidzalandov1.Postgresql, err error) { +func (c *FakePostgresqls) Update(postgresql *acid_zalan_do_v1.Postgresql) (result *acid_zalan_do_v1.Postgresql, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(postgresqlsResource, c.ns, postgresql), &acidzalandov1.Postgresql{}) + Invokes(testing.NewUpdateAction(postgresqlsResource, c.ns, postgresql), &acid_zalan_do_v1.Postgresql{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.Postgresql), err + return obj.(*acid_zalan_do_v1.Postgresql), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakePostgresqls) UpdateStatus(postgresql *acidzalandov1.Postgresql) (*acidzalandov1.Postgresql, error) { +func (c *FakePostgresqls) UpdateStatus(postgresql *acid_zalan_do_v1.Postgresql) (*acid_zalan_do_v1.Postgresql, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(postgresqlsResource, "status", c.ns, postgresql), &acidzalandov1.Postgresql{}) + Invokes(testing.NewUpdateSubresourceAction(postgresqlsResource, "status", c.ns, postgresql), &acid_zalan_do_v1.Postgresql{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.Postgresql), err + return obj.(*acid_zalan_do_v1.Postgresql), err } // Delete takes name of the postgresql and deletes it. Returns an error if one occurs. func (c *FakePostgresqls) Delete(name string, options *v1.DeleteOptions) error { _, err := c.Fake. - Invokes(testing.NewDeleteAction(postgresqlsResource, c.ns, name), &acidzalandov1.Postgresql{}) + Invokes(testing.NewDeleteAction(postgresqlsResource, c.ns, name), &acid_zalan_do_v1.Postgresql{}) return err } @@ -130,17 +130,17 @@ func (c *FakePostgresqls) Delete(name string, options *v1.DeleteOptions) error { func (c *FakePostgresqls) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { action := testing.NewDeleteCollectionAction(postgresqlsResource, c.ns, listOptions) - _, err := c.Fake.Invokes(action, &acidzalandov1.PostgresqlList{}) + _, err := c.Fake.Invokes(action, &acid_zalan_do_v1.PostgresqlList{}) return err } // Patch applies the patch and returns the patched postgresql. -func (c *FakePostgresqls) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *acidzalandov1.Postgresql, err error) { +func (c *FakePostgresqls) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *acid_zalan_do_v1.Postgresql, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(postgresqlsResource, c.ns, name, data, subresources...), &acidzalandov1.Postgresql{}) + Invokes(testing.NewPatchSubresourceAction(postgresqlsResource, c.ns, name, data, subresources...), &acid_zalan_do_v1.Postgresql{}) if obj == nil { return nil, err } - return obj.(*acidzalandov1.Postgresql), err + return obj.(*acid_zalan_do_v1.Postgresql), err } diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/generated_expansion.go index 775a4b21f..e1d824486 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/generated_expansion.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/operatorconfiguration.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/operatorconfiguration.go index 2541f0e3f..4d885f98b 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/operatorconfiguration.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/operatorconfiguration.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,8 @@ SOFTWARE. package v1 import ( - acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - scheme "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" + acid_zalan_do_v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + scheme "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" rest "k8s.io/client-go/rest" ) @@ -39,7 +39,7 @@ type OperatorConfigurationsGetter interface { // OperatorConfigurationInterface has methods to work with OperatorConfiguration resources. type OperatorConfigurationInterface interface { - Get(name string, options v1.GetOptions) (*acidzalandov1.OperatorConfiguration, error) + Get(name string, options v1.GetOptions) (*acid_zalan_do_v1.OperatorConfiguration, error) OperatorConfigurationExpansion } @@ -58,8 +58,8 @@ func newOperatorConfigurations(c *AcidV1Client, namespace string) *operatorConfi } // Get takes name of the operatorConfiguration, and returns the corresponding operatorConfiguration object, and an error if there is any. -func (c *operatorConfigurations) Get(name string, options v1.GetOptions) (result *acidzalandov1.OperatorConfiguration, err error) { - result = &acidzalandov1.OperatorConfiguration{} +func (c *operatorConfigurations) Get(name string, options v1.GetOptions) (result *acid_zalan_do_v1.OperatorConfiguration, err error) { + result = &acid_zalan_do_v1.OperatorConfiguration{} err = c.client.Get(). Namespace(c.ns). Resource("operatorconfigurations"). diff --git a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/postgresql.go b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/postgresql.go index df1045ee3..f580af916 100644 --- a/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/postgresql.go +++ b/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1/postgresql.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,9 +25,9 @@ SOFTWARE. package v1 import ( - v1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - scheme "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + scheme "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/scheme" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" @@ -44,11 +44,11 @@ type PostgresqlInterface interface { Create(*v1.Postgresql) (*v1.Postgresql, error) Update(*v1.Postgresql) (*v1.Postgresql, error) UpdateStatus(*v1.Postgresql) (*v1.Postgresql, error) - Delete(name string, options *metav1.DeleteOptions) error - DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error - Get(name string, options metav1.GetOptions) (*v1.Postgresql, error) - List(opts metav1.ListOptions) (*v1.PostgresqlList, error) - Watch(opts metav1.ListOptions) (watch.Interface, error) + Delete(name string, options *meta_v1.DeleteOptions) error + DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error + Get(name string, options meta_v1.GetOptions) (*v1.Postgresql, error) + List(opts meta_v1.ListOptions) (*v1.PostgresqlList, error) + Watch(opts meta_v1.ListOptions) (watch.Interface, error) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Postgresql, err error) PostgresqlExpansion } @@ -68,7 +68,7 @@ func newPostgresqls(c *AcidV1Client, namespace string) *postgresqls { } // Get takes name of the postgresql, and returns the corresponding postgresql object, and an error if there is any. -func (c *postgresqls) Get(name string, options metav1.GetOptions) (result *v1.Postgresql, err error) { +func (c *postgresqls) Get(name string, options meta_v1.GetOptions) (result *v1.Postgresql, err error) { result = &v1.Postgresql{} err = c.client.Get(). Namespace(c.ns). @@ -81,7 +81,7 @@ func (c *postgresqls) Get(name string, options metav1.GetOptions) (result *v1.Po } // List takes label and field selectors, and returns the list of Postgresqls that match those selectors. -func (c *postgresqls) List(opts metav1.ListOptions) (result *v1.PostgresqlList, err error) { +func (c *postgresqls) List(opts meta_v1.ListOptions) (result *v1.PostgresqlList, err error) { result = &v1.PostgresqlList{} err = c.client.Get(). Namespace(c.ns). @@ -93,7 +93,7 @@ func (c *postgresqls) List(opts metav1.ListOptions) (result *v1.PostgresqlList, } // Watch returns a watch.Interface that watches the requested postgresqls. -func (c *postgresqls) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (c *postgresqls) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { opts.Watch = true return c.client.Get(). Namespace(c.ns). @@ -144,7 +144,7 @@ func (c *postgresqls) UpdateStatus(postgresql *v1.Postgresql) (result *v1.Postgr } // Delete takes name of the postgresql and deletes it. Returns an error if one occurs. -func (c *postgresqls) Delete(name string, options *metav1.DeleteOptions) error { +func (c *postgresqls) Delete(name string, options *meta_v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("postgresqls"). @@ -155,7 +155,7 @@ func (c *postgresqls) Delete(name string, options *metav1.DeleteOptions) error { } // DeleteCollection deletes a collection of objects. -func (c *postgresqls) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { +func (c *postgresqls) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("postgresqls"). diff --git a/pkg/generated/informers/externalversions/acid.zalan.do/interface.go b/pkg/generated/informers/externalversions/acid.zalan.do/interface.go index 9dfa60021..edf03dce7 100644 --- a/pkg/generated/informers/externalversions/acid.zalan.do/interface.go +++ b/pkg/generated/informers/externalversions/acid.zalan.do/interface.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,8 @@ SOFTWARE. package acid import ( - v1 "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1" - internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do/v1" + internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" ) // Interface provides access to each of this group's versions. diff --git a/pkg/generated/informers/externalversions/acid.zalan.do/v1/interface.go b/pkg/generated/informers/externalversions/acid.zalan.do/v1/interface.go index f0f35b65c..77e7c9b34 100644 --- a/pkg/generated/informers/externalversions/acid.zalan.do/v1/interface.go +++ b/pkg/generated/informers/externalversions/acid.zalan.do/v1/interface.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package v1 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. diff --git a/pkg/generated/informers/externalversions/acid.zalan.do/v1/postgresql.go b/pkg/generated/informers/externalversions/acid.zalan.do/v1/postgresql.go index 50f3126cf..cb0dfa348 100644 --- a/pkg/generated/informers/externalversions/acid.zalan.do/v1/postgresql.go +++ b/pkg/generated/informers/externalversions/acid.zalan.do/v1/postgresql.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -27,11 +27,11 @@ package v1 import ( time "time" - acidzalandov1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" - versioned "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" - internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "github.com/zalando-incubator/postgres-operator/pkg/generated/listers/acid.zalan.do/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + acid_zalan_do_v1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" + versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned" + internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/zalando/postgres-operator/pkg/generated/listers/acid.zalan.do/v1" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" @@ -63,20 +63,20 @@ func NewPostgresqlInformer(client versioned.Interface, namespace string, resyncP func NewFilteredPostgresqlInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } return client.AcidV1().Postgresqls(namespace).List(options) }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } return client.AcidV1().Postgresqls(namespace).Watch(options) }, }, - &acidzalandov1.Postgresql{}, + &acid_zalan_do_v1.Postgresql{}, resyncPeriod, indexers, ) @@ -87,7 +87,7 @@ func (f *postgresqlInformer) defaultInformer(client versioned.Interface, resyncP } func (f *postgresqlInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&acidzalandov1.Postgresql{}, f.defaultInformer) + return f.factory.InformerFor(&acid_zalan_do_v1.Postgresql{}, f.defaultInformer) } func (f *postgresqlInformer) Lister() v1.PostgresqlLister { diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index 395bc25b5..cd51a69d6 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,9 @@ import ( sync "sync" time "time" - versioned "github.com/zalando-incubator/postgres-operator/pkg/generated/clientset/versioned" - acidzalando "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do" - internalinterfaces "github.com/zalando-incubator/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" + versioned "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned" + acid_zalan_do "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/acid.zalan.do" + internalinterfaces "github.com/zalando/postgres-operator/pkg/generated/informers/externalversions/internalinterfaces" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -178,9 +178,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - Acid() acidzalando.Interface + Acid() acid_zalan_do.Interface } -func (f *sharedInformerFactory) Acid() acidzalando.Interface { - return acidzalando.New(f, f.namespace, f.tweakListOptions) +func (f *sharedInformerFactory) Acid() acid_zalan_do.Interface { + return acid_zalan_do.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index 1b1988212..3af7bb7ec 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ package externalversions import ( "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" cache "k8s.io/client-go/tools/cache" ) diff --git a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go index f3b4ab9fa..bdd892f35 100644 --- a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ package internalinterfaces import ( 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" runtime "k8s.io/apimachinery/pkg/runtime" cache "k8s.io/client-go/tools/cache" diff --git a/pkg/generated/listers/acid.zalan.do/v1/expansion_generated.go b/pkg/generated/listers/acid.zalan.do/v1/expansion_generated.go index 071a413d6..4c353bec3 100644 --- a/pkg/generated/listers/acid.zalan.do/v1/expansion_generated.go +++ b/pkg/generated/listers/acid.zalan.do/v1/expansion_generated.go @@ -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 of this software and associated documentation files (the "Software"), to deal diff --git a/pkg/generated/listers/acid.zalan.do/v1/postgresql.go b/pkg/generated/listers/acid.zalan.do/v1/postgresql.go index c8603bc79..da41e1358 100644 --- a/pkg/generated/listers/acid.zalan.do/v1/postgresql.go +++ b/pkg/generated/listers/acid.zalan.do/v1/postgresql.go @@ -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 of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ SOFTWARE. package v1 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/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index a8b3dd6bd..a60c8e673 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -7,7 +7,7 @@ import ( "fmt" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/spec" ) // CRD describes CustomResourceDefinition specific configuration parameters @@ -27,6 +27,7 @@ type Resources struct { PodTerminateGracePeriod time.Duration `name:"pod_terminate_grace_period" default:"5m"` PodPriorityClassName string `name:"pod_priority_class_name"` 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"` PodRoleLabel string `name:"pod_role_label" default:"spilo-role"` PodToleration map[string]string `name:"toleration" default:""` @@ -95,6 +96,8 @@ type Config struct { EnableMasterLoadBalancer bool `name:"enable_master_load_balancer" default:"true"` 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 EnableLoadBalancer *bool `name:"enable_load_balancer"` MasterDNSNameFormat StringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"` diff --git a/pkg/util/k8sutil/k8sutil.go b/pkg/util/k8sutil/k8sutil.go index 9ab5cb876..6f5b15085 100644 --- a/pkg/util/k8sutil/k8sutil.go +++ b/pkg/util/k8sutil/k8sutil.go @@ -2,7 +2,7 @@ package k8sutil import ( "fmt" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/constants" "k8s.io/api/core/v1" policybeta1 "k8s.io/api/policy/v1beta1" apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" @@ -17,7 +17,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "reflect" - 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 diff --git a/pkg/util/users/users.go b/pkg/util/users/users.go index b436595ef..112f89b43 100644 --- a/pkg/util/users/users.go +++ b/pkg/util/users/users.go @@ -7,8 +7,8 @@ import ( "reflect" - "github.com/zalando-incubator/postgres-operator/pkg/spec" - "github.com/zalando-incubator/postgres-operator/pkg/util" + "github.com/zalando/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/util" ) const ( diff --git a/pkg/util/util.go b/pkg/util/util.go index 99e670af9..60d8159a9 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -13,7 +13,7 @@ import ( resource "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/spec" ) const ( diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 3a02149b4..a34e57e23 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -8,7 +8,7 @@ import ( "regexp" - "github.com/zalando-incubator/postgres-operator/pkg/spec" + "github.com/zalando/postgres-operator/pkg/spec" ) var pgUsers = []struct { diff --git a/pkg/util/volumes/ebs.go b/pkg/util/volumes/ebs.go index 00801fa9c..666436a06 100644 --- a/pkg/util/volumes/ebs.go +++ b/pkg/util/volumes/ebs.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "k8s.io/api/core/v1" - "github.com/zalando-incubator/postgres-operator/pkg/util/constants" - "github.com/zalando-incubator/postgres-operator/pkg/util/retryutil" + "github.com/zalando/postgres-operator/pkg/util/constants" + "github.com/zalando/postgres-operator/pkg/util/retryutil" ) // EBSVolumeResizer implements volume resizing interface for AWS EBS volumes. diff --git a/run_operator_locally.sh b/run_operator_locally.sh index 8601f4fbc..2594097b2 100755 --- a/run_operator_locally.sh +++ b/run_operator_locally.sh @@ -3,6 +3,11 @@ # Deploy a Postgres operator to a minikube aka local Kubernetes cluster # Optionally re-build the operator binary beforehand to test local changes +# Known limitations: +# 1) minikube provides a single node k8s cluster. That is, you will not be able test functions like pod +# migration between multiple nodes locally +# 2) this script configures the operator via configmap, not the operator CRD + # enable unofficial bash strict mode set -o errexit @@ -13,6 +18,7 @@ IFS=$'\n\t' readonly PATH_TO_LOCAL_OPERATOR_MANIFEST="/tmp/local-postgres-operator-manifest.yaml" readonly PATH_TO_PORT_FORWARED_KUBECTL_PID="/tmp/kubectl-port-forward.pid" +readonly PATH_TO_THE_PG_CLUSTER_MANIFEST="/tmp/minimal-postgres-manifest.yaml" readonly LOCAL_PORT="8080" readonly OPERATOR_PORT="8080" @@ -37,18 +43,16 @@ function retry(){ return 1 } - function display_help(){ - echo "Usage: $0 [ -r | --rebuild-operator ] [ -h | --help ]" + echo "Usage: $0 [ -r | --rebuild-operator ] [ -h | --help ] [ -n | --deploy-new-operator-image ] [ -t | --deploy-pg-to-namespace-test ]" } - function clean_up(){ echo "==== CLEAN UP PREVIOUS RUN ==== " local status - status=$(minikube status --format "{{.MinikubeStatus}}" || true) + status=$(minikube status --format "{{.Host}}" || true) if [[ "$status" = "Running" ]] || [[ "$status" = "Stopped" ]]; then echo "Delete the existing local cluster so that we can cleanly apply resources from scratch..." @@ -123,7 +127,7 @@ function deploy_self_built_image() { # docker should not attempt to fetch it from the registry due to imagePullPolicy sed -e "s/\(image\:.*\:\).*$/\1$TAG/; s/smoke-tested-//" manifests/postgres-operator.yaml > "$PATH_TO_LOCAL_OPERATOR_MANIFEST" - retry "kubectl create -f \"$PATH_TO_LOCAL_OPERATOR_MANIFEST\"" "attempt to create $PATH_TO_LOCAL_OPERATOR_MANIFEST resource" + retry "kubectl apply -f \"$PATH_TO_LOCAL_OPERATOR_MANIFEST\"" "attempt to create $PATH_TO_LOCAL_OPERATOR_MANIFEST resource" } @@ -139,17 +143,18 @@ function start_operator(){ retry "kubectl create -f manifests/\"$file\"" "attempt to create $file resource" done + cp manifests/postgres-operator.yaml $PATH_TO_LOCAL_OPERATOR_MANIFEST + if [[ "$should_build_custom_operator" = true ]]; then # set in main() deploy_self_built_image else - retry "kubectl create -f manifests/postgres-operator.yaml" "attempt to create /postgres-operator.yaml resource" + retry "kubectl create -f ${PATH_TO_LOCAL_OPERATOR_MANIFEST}" "attempt to create ${PATH_TO_LOCAL_OPERATOR_MANIFEST} resource" fi local -r msg="Wait for the postgresql custom resource definition to register..." local -r cmd="kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'" retry "$cmd" "$msg " - kubectl create -f manifests/minimal-postgres-manifest.yaml } @@ -186,16 +191,38 @@ function check_health(){ } +function submit_postgresql_manifest(){ + + echo "==== SUBMIT MINIMAL POSTGRES MANIFEST ==== " + + local namespace="default" + cp manifests/minimal-postgres-manifest.yaml $PATH_TO_THE_PG_CLUSTER_MANIFEST + + if $should_deploy_pg_to_namespace_test; then + kubectl create namespace test + namespace="test" + sed --in-place 's/namespace: default/namespace: test/' $PATH_TO_THE_PG_CLUSTER_MANIFEST + fi + + kubectl create -f $PATH_TO_THE_PG_CLUSTER_MANIFEST + echo "The operator will create the PG cluster with minimal manifest $PATH_TO_THE_PG_CLUSTER_MANIFEST in the ${namespace} namespace" + +} + + function main(){ if ! [[ $(basename "$PWD") == "postgres-operator" ]]; then - echo "Please execute the script only from the root directory of the Postgres opepator repo." + echo "Please execute the script only from the root directory of the Postgres operator repo." exit 1 fi trap "echo 'If you observe issues with minikube VM not starting/not proceeding, consider deleting the .minikube dir and/or rebooting before re-running the script'" EXIT - local should_build_custom_operator=false # used in start_operator() + local should_build_custom_operator=false + local should_deploy_pg_to_namespace_test=false + local should_replace_operator_image=false + while true do # if the 1st param is unset, use the empty string as a default value @@ -204,19 +231,32 @@ function main(){ display_help exit 0 ;; - -r | --rebuild-operator) + -r | --rebuild-operator) # with minikube restart should_build_custom_operator=true break ;; + -n | --deploy-new-operator-image) # without minikube restart that takes minutes + should_replace_operator_image=true + break + ;; + -t | --deploy-pg-to-namespace-test) # to test multi-namespace support locally + should_deploy_pg_to_namespace_test=true + break + ;; *) break ;; esac done + if ${should_replace_operator_image}; then + deploy_self_built_image + exit 0 + fi + clean_up start_minikube - kubectl create namespace test start_operator + submit_postgresql_manifest forward_ports check_health