From 94e3b6effd49e6d037838ba7dd41a8a53c107b35 Mon Sep 17 00:00:00 2001 From: Sarah Conway Date: Thu, 24 Jan 2019 08:54:59 -0800 Subject: [PATCH 1/8] Alter config.toml, remove some unnecessary files (#556) --- .../manual-installation/index.html | 705 ------------------ generate-docs.sh | 34 - generate-pdf.sh | 28 - hugo/config.toml | 7 +- hugo/themes/crunchy-hugo-theme | 2 +- 5 files changed, 7 insertions(+), 769 deletions(-) delete mode 100644 docs/installation/manual-installation/index.html delete mode 100755 generate-docs.sh delete mode 100755 generate-pdf.sh diff --git a/docs/installation/manual-installation/index.html b/docs/installation/manual-installation/index.html deleted file mode 100644 index f8e088c2cc..0000000000 --- a/docs/installation/manual-installation/index.html +++ /dev/null @@ -1,705 +0,0 @@ - - - - Crunchy Data PostgreSQL Operator Documentation - - - - - -Manual Installation :: Crunchy Data PostgreSQL Operator Documentation - - - - - - - - - - - - - - - - - - -
- - - - -
-
-
- -
- - - - - - - -
-
- -
-
- - -
- - -
- -

Manual Installation

- - - - - - - - -
-

Latest Release: 3.2.0 2018-08-22

-
-
-

Project Structure

-
-
-

First, define the following environment variables in .bashrc:

-
-
-
-
export GOPATH=$HOME/odev
-export GOBIN=$GOPATH/bin
-export PATH=$PATH:$GOBIN
-export CO_NAMESPACE=demo
-export CO_CMD=kubectl
-export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator
-export CO_IMAGE_PREFIX=crunchydata
-export CO_BASEOS=centos7
-export CO_VERSION=3.2.0
-export CO_IMAGE_TAG=centos7-$CO_VERSION
-export PGO_CA_CERT=$COROOT/conf/apiserver/server.crt
-export PGO_CLIENT_CERT=$COROOT/conf/apiserver/server.crt
-export PGO_CLIENT_KEY=$COROOT/conf/apiserver/server.key
-alias setip='export CO_APISERVER_URL=https://`kubectl get service postgres-operator -o=jsonpath="{.spec.clusterIP}"`:8443'
-
-
-
-

When deploying on Openshift Container Platform, the CO_CMD environment -variable should be:

-
-
-
-
export CO_CMD=oc
-
-
-
-

To perform an installation of the operator, first create the project structure as follows on your host, here we assume a local directory called odev -

-
-
-
-
mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg $GOPATH/src/github.com/crunchydata/
-
-
-
-

Next, get a tagged release of the source code -

-
-
-
-
cd $GOPATH/src/github.com/crunchydata
-git clone https://github.com/CrunchyData/postgres-operator.git
-cd postgres-operator
-git checkout 3.2.0
-
-
-
-
-
-

Installation Prerequsites

-
-
-

To run the operator and the pgo client, you will need the following -

-
-
-
    -
  • -

    a running Kubernetes or OpenShift cluster

    -
  • -
  • -

    the kubectl or oc clients installed in your PATH and configured to connect to the cluster (e.g. export KUBECONFIG=/etc/kubernetes/admin.conf)

    -
  • -
  • -

    a Kubernetes namespace created and set to where you want the operator installed. For this install we assume a namespace of demo has been created.

    -
  • -
-
-
-
-
kubectl create -f examples/demo-namespace.json
-kubectl config set-context $(kubectl config current-context) --namespace=demo
-kubectl config view | grep namespace
-
-
-
-

Run the Makefile setup target to install depedencies and also -create the operator CRD resources and RBAC rules.

-
-
- - - - - -
-
Warning
-
-
-

The 'make setup' target is required to be run as a Kubernetes user that has -'cluster-admin' priviledges. This is required to create cluster roles and -clusterrole bindings, along with the CRDs used by the Operator.

-
-
-

The namespace used by the operator is determined by the -CO_NAMESPACE environment variable setting.

-
-
-
-
-
-
make setup
-
-
-
-
-
-

Basic Installation

-
-
-

The basic installation uses the default operator configuration settings. These -settings assume you want to use HostPath storage on your Kubernetes cluster for -database persistence. Other persistent options are available and documented -here.

-
-
-

Create HostPath Directory

-
-

The default Persistent Volume script assumes a default HostPath directory be created called /data:

-
-
-
-
sudo mkdir /data
-sudo chmod 777 /data
-
-
-
-

Create some sample Persistent Volumes using the following script:

-
-
-
-
$COROOT/pv/create-pv.sh
-
-
-
-
-
-
-

Build Images & Deploy

-
-
-
-
- - - - - Packaged Images - - -
- -
-
-
-
-
- - - - - Build from Source - - -
- -
-
-
-
-
-

Makefile Targets

-
-
-

The following table describes the Makefile targets -

-
- - ---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Table 1. Makefile Targets
TargetDescription

all

compile all binaries and build all images

setup

fetch the dependent packages required to build with, and create Kube RBAC resources

bounce

delete the Operator pod only, this is a way to upgrade the operator without a full redeploy, as the operator runs in a Deployment, a new pod will be created to replace the old one, a simple way to bounce the pod

deployoperator

deploy the Operator (apiserver and postgers-operator) to Kubernetes

main

compile the postgres-operator

runmain

locally execute the postgres-operator

pgo

build the pgo binary

runpgo

run the pgo binary

runapiserver

run the apiserver binary outside of Kube

clean

remove binaries and compiled packages, restore dependencies

operatorimage

compile and build the postgres-operator Docker image

apiserverimage

compile and build the apiserver Docker image

lsimage

build the lspvc Docker image

loadimage

build the file load Docker image

rmdataimage

build the data deletion Docker image

pgo-backrest-image

build the pgbackrest interface Docker image

release

build the postgres-operator release

installrbac

build the postgres-operator service account

-
-
-
-

Next Steps

-
-
-

Next, visit the Deployment page to deploy the -Operator, verify the installation, and view various storage configurations.

-
-
-
- - - - -
- -
-
-
- - - -
-
-
-
- - - - - - - - - - - - - - - - - - diff --git a/generate-docs.sh b/generate-docs.sh deleted file mode 100755 index 219a7351e6..0000000000 --- a/generate-docs.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Copyright 2018 Crunchy Data Solutions, Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if [[ $(git status -s) ]] -then - echo "The working directory is dirty. Please commit any pending changes." - exit 1; -fi - -echo "Moving to the Hugo subdirectory..." -# Navigate to directory containing Hugo files -cd ${COROOT?}/hugo/ - -# Generate documents under /docs/ -echo "Generating Hugo webpages..." -hugo - -# Add all changes and commit, push to GitHub -echo "Updating GitHub repository..." -git add --all && git commit -m "Publishing documentation" - -echo "Next Steps: Push your commits to your working repository and submit a pull request." diff --git a/generate-pdf.sh b/generate-pdf.sh deleted file mode 100755 index 39058d6070..0000000000 --- a/generate-pdf.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Copyright 2018 Crunchy Data Solutions, Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cp -R hugo/content/* hugo/static/pdf/ - -for f in $(find hugo/static/pdf -name '*.adoc' ! -name 'postgres-operator.adoc') -do - sed -i "1d" $f - sed -i 's/^[^-]*---//g' $f - sed -i "s/{{%[^%]*%}}//g" $f -done - -a2x --fop -f pdf hugo/static/pdf/postgres-operator.adoc -D hugo/static/pdf/ - -find hugo/static/pdf ! -name "pdf" -type d -exec rm -rf {} + -rm hugo/static/pdf/_index.adoc diff --git a/hugo/config.toml b/hugo/config.toml index 7f4c1fdaea..1ecaa0f69e 100644 --- a/hugo/config.toml +++ b/hugo/config.toml @@ -47,5 +47,10 @@ weight = 30 [[menu.downloads]] name = " " -url = "/pdf/postgres-operator.pdf" +url = "/pdf/postgres_operator.pdf" weight = 20 + +[[menu.downloads]] +name = " " +url = "/epub/postgres_operator.epub" +weight = 30 diff --git a/hugo/themes/crunchy-hugo-theme b/hugo/themes/crunchy-hugo-theme index e6335b90d1..0b914495aa 160000 --- a/hugo/themes/crunchy-hugo-theme +++ b/hugo/themes/crunchy-hugo-theme @@ -1 +1 @@ -Subproject commit e6335b90d123f4e7430410f8bce822ffac445c28 +Subproject commit 0b914495aa3d0b957cf87800e7f7a935057c1346 From 6279f182a5344a9cd36a1efce3efa6212dec2734 Mon Sep 17 00:00:00 2001 From: Sarah Conway Date: Thu, 31 Jan 2019 12:45:54 -0800 Subject: [PATCH 2/8] Update README (#573) --- README.md | 21 ++++++++++----------- hugo/themes/crunchy-hugo-theme | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 838fa879df..443c1ac0dc 100644 --- a/README.md +++ b/README.md @@ -25,21 +25,20 @@ The Operator deploys on Kubernetes and Openshift clusters. Some form of storage The Operator includes various components that get deployed to your Kubernetes cluster as shown in the following diagram and detailed -in the [Design](https://crunchydata.github.io/postgres-operator/latest/design/). +in the [Design](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/design/). -![Reference](https://crunchydata.github.io/postgres-operator/latest/Operator-Architecture.png) +![Reference](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/Operator-Architecture.png) The Operator is developed and tested on CentOS and RHEL linux platforms but is known to run on other Linux variants. ## Documentation The following documentation is provided: - - [pgo CLI Syntax and Examples](https://crunchydata.github.io/postgres-operator/latest/operator-cli/) - - [Installation](https://crunchydata.github.io/postgres-operator/latest/installation/) - - [Configuration](https://crunchydata.github.io/postgres-operator/latest/configuration/configuration/) - - [pgo.yaml Description](https://crunchydata.github.io/postgres-operator/latest/configuration/pgo-yaml-configuration/) - - [Security](https://crunchydata.github.io/postgres-operator/latest/security/) - - [Design Overview](https://crunchydata.github.io/postgres-operator/latest/design/) - - [Developing](https://crunchydata.github.io/postgres-operator/latest/developer-setup/) - - [Upgrading the Operator](https://crunchydata.github.io/postgres-operator/latest/upgrade/) - + - [pgo CLI Syntax and Examples](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/operator-cli/) + - [Installation](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/installation/) + - [Configuration](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/configuration/configuration/) + - [pgo.yaml Description](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/configuration/pgo-yaml-configuration/) + - [Security](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/security/) + - [Design Overview](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/design/) + - [Developing](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/developer-setup/) + - [Upgrading the Operator](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/upgrade/) diff --git a/hugo/themes/crunchy-hugo-theme b/hugo/themes/crunchy-hugo-theme index 0b914495aa..e6335b90d1 160000 --- a/hugo/themes/crunchy-hugo-theme +++ b/hugo/themes/crunchy-hugo-theme @@ -1 +1 @@ -Subproject commit 0b914495aa3d0b957cf87800e7f7a935057c1346 +Subproject commit e6335b90d123f4e7430410f8bce822ffac445c28 From 5dfd4e9dced1b5c12afd939da14b2a9604d52308 Mon Sep 17 00:00:00 2001 From: jmccormick2001 Date: Fri, 22 Feb 2019 16:02:54 -0500 Subject: [PATCH 3/8] add regexp to check usernames passed into create user command to prevent special chars from being passed in --- apiserver/userservice/userimpl.go | 74 ++++++++++++++++++------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/apiserver/userservice/userimpl.go b/apiserver/userservice/userimpl.go index 3b0ab9ca17..68dbb2bd79 100644 --- a/apiserver/userservice/userimpl.go +++ b/apiserver/userservice/userimpl.go @@ -20,6 +20,7 @@ import ( "database/sql" "errors" "fmt" + "regexp" "strconv" "strings" "time" @@ -61,7 +62,7 @@ var defaultPasswordLength = 8 // pgo user --change-password=bob --db=userdb // --expired=7 --selector=env=research --update-passwords=true // --valid-days=30 -func User(request *msgs.UserRequest) msgs.UserResponse { +func User(request *msgs.UserRequest, ns string) msgs.UserResponse { var err error resp := msgs.UserResponse{} resp.Status.Code = msgs.Ok @@ -93,7 +94,7 @@ func User(request *msgs.UserRequest) msgs.UserResponse { //get the clusters list clusterList := crv1.PgclusterList{} err = kubeapi.GetpgclustersBySelector(apiserver.RESTClient, - &clusterList, sel, apiserver.Namespace) + &clusterList, sel, ns) if err != nil { resp.Status.Code = msgs.Error resp.Status.Msg = err.Error() @@ -109,7 +110,7 @@ func User(request *msgs.UserRequest) msgs.UserResponse { for _, cluster := range clusterList.Items { //selector := util.LABEL_PG_CLUSTER + "=" + cluster.Spec.Name + "," + util.LABEL_PRIMARY + "=true" selector := util.LABEL_PG_CLUSTER + "=" + cluster.Spec.Name + "," + util.LABEL_SERVICE_NAME + "=" + cluster.Spec.Name - deployments, err := kubeapi.GetDeployments(apiserver.Clientset, selector, apiserver.Namespace) + deployments, err := kubeapi.GetDeployments(apiserver.Clientset, selector, ns) if err != nil { resp.Status.Code = msgs.Error resp.Status.Msg = err.Error() @@ -117,7 +118,7 @@ func User(request *msgs.UserRequest) msgs.UserResponse { } for _, d := range deployments.Items { - info := getPostgresUserInfo(apiserver.Namespace, d.ObjectMeta.Name) + info := getPostgresUserInfo(ns, d.ObjectMeta.Name) if request.ChangePasswordForUser != "" { msg := "changing password of user " + request.ChangePasswordForUser + " on " + d.ObjectMeta.Name @@ -137,7 +138,7 @@ func User(request *msgs.UserRequest) msgs.UserResponse { pgbouncer := cluster.Spec.UserLabels[util.LABEL_PGBOUNCER] == "true" pgpool := cluster.Spec.UserLabels[util.LABEL_PGPOOL] == "true" - err = updatePassword(cluster.Spec.Name, info, request.ChangePasswordForUser, newPassword, newExpireDate, apiserver.Namespace, pgpool, pgbouncer, request.PasswordLength) + err = updatePassword(cluster.Spec.Name, info, request.ChangePasswordForUser, newPassword, newExpireDate, ns, pgpool, pgbouncer, request.PasswordLength) if err != nil { log.Error(err.Error()) resp.Status.Code = msgs.Error @@ -158,7 +159,7 @@ func User(request *msgs.UserRequest) msgs.UserResponse { newExpireDate := GeneratePasswordExpireDate(request.PasswordAgeDays) pgbouncer := cluster.Spec.UserLabels[util.LABEL_PGBOUNCER] == "true" pgpool := cluster.Spec.UserLabels[util.LABEL_PGPOOL] == "true" - err = updatePassword(cluster.Spec.Name, v.ConnDetails, v.Rolname, newPassword, newExpireDate, apiserver.Namespace, pgpool, pgbouncer, request.PasswordLength) + err = updatePassword(cluster.Spec.Name, v.ConnDetails, v.Rolname, newPassword, newExpireDate, ns, pgpool, pgbouncer, request.PasswordLength) if err != nil { log.Error("error in updating password") } @@ -275,7 +276,7 @@ func updatePassword(clusterName string, p connInfo, username, newPassword, passw } if pgbouncer { - err := reconfigurePgbouncer(clusterName) + err := reconfigurePgbouncer(clusterName, namespace) if err != nil { log.Error(err) return err @@ -283,7 +284,7 @@ func updatePassword(clusterName string, p connInfo, username, newPassword, passw } if pgpool { - err := reconfigurePgpool(clusterName) + err := reconfigurePgpool(clusterName, namespace) if err != nil { log.Error(err) return err @@ -508,7 +509,7 @@ func deleteUser(namespace, clusterName string, info connInfo, user string, manag // CreateUser ... // pgo create user user1 -func CreateUser(request *msgs.CreateUserRequest) msgs.CreateUserResponse { +func CreateUser(request *msgs.CreateUserRequest, ns string) msgs.CreateUserResponse { var err error resp := msgs.CreateUserResponse{} resp.Status.Code = msgs.Ok @@ -529,7 +530,7 @@ func CreateUser(request *msgs.CreateUserRequest) msgs.CreateUserResponse { //get a list of all clusters err = kubeapi.GetpgclustersBySelector(apiserver.RESTClient, - &clusterList, request.Selector, apiserver.Namespace) + &clusterList, request.Selector, ns) if err != nil { resp.Status.Code = msgs.Error resp.Status.Msg = err.Error() @@ -544,10 +545,17 @@ func CreateUser(request *msgs.CreateUserRequest) msgs.CreateUserResponse { log.Debugf("createUser clusters found len is %d", len(clusterList.Items)) + re := regexp.MustCompile("^[a-z0-9.-]*$") + if !re.MatchString(request.Name) { + resp.Status.Code = msgs.Error + resp.Status.Msg = "user name is required to be lowercase letters and numbers only." + return resp + } + for _, c := range clusterList.Items { - info := getPostgresUserInfo(apiserver.Namespace, c.Name) + info := getPostgresUserInfo(ns, c.Name) - err = addUser(request, apiserver.Namespace, c.Name, info) + err = addUser(request, ns, c.Name, info) if err != nil { resp.Status.Code = msgs.Error resp.Status.Msg = err.Error() @@ -570,7 +578,7 @@ func CreateUser(request *msgs.CreateUserRequest) msgs.CreateUserResponse { pgbouncer := c.Spec.UserLabels[util.LABEL_PGBOUNCER] == "true" pgpool := c.Spec.UserLabels[util.LABEL_PGPOOL] == "true" - err = updatePassword(c.Name, info, request.Name, newPassword, newExpireDate, apiserver.Namespace, pgpool, pgbouncer, request.PasswordLength) + err = updatePassword(c.Name, info, request.Name, newPassword, newExpireDate, ns, pgpool, pgbouncer, request.PasswordLength) if err != nil { log.Error(err.Error()) resp.Status.Code = msgs.Error @@ -584,18 +592,19 @@ func CreateUser(request *msgs.CreateUserRequest) msgs.CreateUserResponse { } // DeleteUser ... -func DeleteUser(name, selector string) msgs.DeleteUserResponse { +func DeleteUser(name, selector, ns string) msgs.DeleteUserResponse { var err error response := msgs.DeleteUserResponse{} response.Status = msgs.Status{Code: msgs.Ok, Msg: ""} response.Results = make([]string, 0) + log.Debugf("DeleteUser called name=%s", name) clusterList := crv1.PgclusterList{} //get the clusters list err = kubeapi.GetpgclustersBySelector(apiserver.RESTClient, - &clusterList, selector, apiserver.Namespace) + &clusterList, selector, ns) if err != nil { response.Status.Code = msgs.Error response.Status.Msg = err.Error() @@ -614,18 +623,20 @@ func DeleteUser(name, selector string) msgs.DeleteUserResponse { for _, cluster := range clusterList.Items { clusterName = cluster.Spec.Name - info := getPostgresUserInfo(apiserver.Namespace, clusterName) + info := getPostgresUserInfo(ns, clusterName) secretName := clusterName + "-" + name + "-secret" - managed, err = isManaged(secretName) + managed, err = isManaged(secretName, ns) if err != nil { response.Status.Code = msgs.Error response.Status.Msg = err.Error() return response } - err = deleteUser(apiserver.Namespace, clusterName, info, name, managed) + log.Debugf("DeleteUser %s managed %t", name, managed) + + err = deleteUser(ns, clusterName, info, name, managed) if err != nil { log.Error(err) response.Status.Code = msgs.Error @@ -640,7 +651,7 @@ func DeleteUser(name, selector string) msgs.DeleteUserResponse { //see if any pooler needs to be reconfigured if managed { if cluster.Spec.UserLabels[util.LABEL_PGBOUNCER] == "true" { - err := reconfigurePgbouncer(clusterName) + err := reconfigurePgbouncer(clusterName, ns) if err != nil { log.Error(err) response.Status.Code = msgs.Error @@ -649,7 +660,7 @@ func DeleteUser(name, selector string) msgs.DeleteUserResponse { } } if cluster.Spec.UserLabels[util.LABEL_PGPOOL] == "true" { - err := reconfigurePgpool(clusterName) + err := reconfigurePgpool(clusterName, ns) if err != nil { log.Error(err) response.Status.Code = msgs.Error @@ -665,8 +676,8 @@ func DeleteUser(name, selector string) msgs.DeleteUserResponse { } -func isManaged(secretName string) (bool, error) { - _, found, err := kubeapi.GetSecret(apiserver.Clientset, secretName, apiserver.Namespace) +func isManaged(secretName, ns string) (bool, error) { + _, found, err := kubeapi.GetSecret(apiserver.Clientset, secretName, ns) if !found { return false, nil } @@ -682,7 +693,7 @@ func isManaged(secretName string) (bool, error) { } // ShowUser ... -func ShowUser(name, selector, expired string) msgs.ShowUserResponse { +func ShowUser(name, selector, expired, ns string) msgs.ShowUserResponse { var err error response := msgs.ShowUserResponse{} @@ -700,7 +711,7 @@ func ShowUser(name, selector, expired string) msgs.ShowUserResponse { //get a list of all clusters err = kubeapi.GetpgclustersBySelector(apiserver.RESTClient, - &clusterList, selector, apiserver.Namespace) + &clusterList, selector, ns) if err != nil { response.Status.Code = msgs.Error response.Status.Msg = err.Error() @@ -732,7 +743,7 @@ func ShowUser(name, selector, expired string) msgs.ShowUserResponse { if expired != "" { //selector := util.LABEL_PG_CLUSTER + "=" + c.Spec.Name + "," + util.LABEL_PRIMARY + "=true" selector := util.LABEL_PG_CLUSTER + "=" + c.Spec.Name + "," + util.LABEL_SERVICE_NAME + "=" + c.Spec.Name - deployments, err := kubeapi.GetDeployments(apiserver.Clientset, selector, apiserver.Namespace) + deployments, err := kubeapi.GetDeployments(apiserver.Clientset, selector, ns) if err != nil { response.Status.Code = msgs.Error response.Status.Msg = err.Error() @@ -740,7 +751,7 @@ func ShowUser(name, selector, expired string) msgs.ShowUserResponse { } for _, d := range deployments.Items { - info := getPostgresUserInfo(apiserver.Namespace, d.ObjectMeta.Name) + info := getPostgresUserInfo(ns, d.ObjectMeta.Name) if expired != "" { results := callDB(info, d.ObjectMeta.Name, expired) if len(results) > 0 { @@ -777,9 +788,10 @@ func deleteUserSecret(clientset *kubernetes.Clientset, clustername, username, na return err } -func reconfigurePgbouncer(clusterName string) error { +func reconfigurePgbouncer(clusterName, ns string) error { var err error spec := crv1.PgtaskSpec{} + spec.Namespace = ns spec.Name = util.LABEL_PGBOUNCER_TASK_RECONFIGURE + "-" + clusterName spec.TaskType = crv1.PgtaskReconfigurePgbouncer spec.StorageSpec = crv1.PgStorageSpec{} @@ -797,8 +809,7 @@ func reconfigurePgbouncer(clusterName string) error { newInstance.ObjectMeta.Labels[util.LABEL_PG_CLUSTER] = clusterName newInstance.ObjectMeta.Labels[util.LABEL_PGBOUNCER_TASK_RECONFIGURE] = "true" - err = kubeapi.Createpgtask(apiserver.RESTClient, - newInstance, apiserver.Namespace) + err = kubeapi.Createpgtask(apiserver.RESTClient, newInstance, ns) if err != nil { log.Error(err) return err @@ -806,9 +817,10 @@ func reconfigurePgbouncer(clusterName string) error { return err } -func reconfigurePgpool(clusterName string) error { +func reconfigurePgpool(clusterName, ns string) error { var err error spec := crv1.PgtaskSpec{} + spec.Namespace = ns spec.Name = util.LABEL_PGPOOL_TASK_RECONFIGURE + "-" + clusterName spec.TaskType = crv1.PgtaskReconfigurePgpool spec.StorageSpec = crv1.PgStorageSpec{} @@ -827,7 +839,7 @@ func reconfigurePgpool(clusterName string) error { newInstance.ObjectMeta.Labels[util.LABEL_PGPOOL_TASK_RECONFIGURE] = "true" err = kubeapi.Createpgtask(apiserver.RESTClient, - newInstance, apiserver.Namespace) + newInstance, ns) if err != nil { log.Error(err) return err From 55e6be12baefcc6c7589b224e342fb6c2ed83732 Mon Sep 17 00:00:00 2001 From: Paul Cahoon Date: Mon, 25 Feb 2019 13:53:34 -0500 Subject: [PATCH 4/8] updating README links for documentation --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 443c1ac0dc..bf5dc94a3d 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,20 @@ The Operator deploys on Kubernetes and Openshift clusters. Some form of storage The Operator includes various components that get deployed to your Kubernetes cluster as shown in the following diagram and detailed -in the [Design](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/design/). +in the [Design](https://crunchydata.github.io/postgres-operator/stable/design/). -![Reference](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/Operator-Architecture.png) +![Reference](https://crunchydata.github.io/postgres-operator/stable/Operator-Architecture.png) The Operator is developed and tested on CentOS and RHEL linux platforms but is known to run on other Linux variants. ## Documentation The following documentation is provided: - - [pgo CLI Syntax and Examples](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/operator-cli/) - - [Installation](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/installation/) - - [Configuration](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/configuration/configuration/) - - [pgo.yaml Description](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/configuration/pgo-yaml-configuration/) - - [Security](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/security/) - - [Design Overview](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/design/) - - [Developing](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/developer-setup/) - - [Upgrading the Operator](https://access.crunchydata.com/documentation/postgres-operator/3.5.0/upgrade/) + - [pgo CLI Syntax and Examples](https://crunchydata.github.io/postgres-operator/stable/operator-cli/) + - [Installation](https://crunchydata.github.io/postgres-operator/stable/installation/) + - [Configuration](https://crunchydata.github.io/postgres-operator/stable/configuration/configuration/) + - [pgo.yaml Description](https://crunchydata.github.io/postgres-operator/stable/configuration/pgo-yaml-configuration/) + - [Security](https://crunchydata.github.io/postgres-operator/stable/security/) + - [Design Overview](https://crunchydata.github.io/postgres-operator/stable/design/) + - [Developing](https://crunchydata.github.io/postgres-operator/stable/developer-setup/) + - [Upgrading the Operator](https://crunchydata.github.io/postgres-operator/stable/upgrade/) From 4acdb93cb6f57fb07239bf3a4d3df2777cc61850 Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 4 Mar 2019 15:26:11 +0100 Subject: [PATCH 5/8] fix example/envs.sh: use CO_NAMESPACE (#613) Signed-off-by: Mathis Raguin --- examples/envs.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/envs.sh b/examples/envs.sh index b85201d520..217b629b7d 100644 --- a/examples/envs.sh +++ b/examples/envs.sh @@ -6,7 +6,7 @@ export CO_CMD=kubectl export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator export CO_IMAGE_PREFIX=crunchydata export CO_BASEOS=centos7 -export CO_VERSION=3.5.0 +export CO_VERSION=3.5.1 export CO_IMAGE_TAG=$CO_BASEOS-$CO_VERSION # for the pgo CLI auth @@ -14,9 +14,19 @@ export PGO_CA_CERT=$COROOT/conf/postgres-operator/server.crt export PGO_CLIENT_CERT=$COROOT/conf/postgres-operator/server.crt export PGO_CLIENT_KEY=$COROOT/conf/postgres-operator/server.key -# useful aliases -alias setip='export CO_APISERVER_URL=https://`kubectl get service postgres-operator -o=jsonpath="{.spec.clusterIP}"`:8443' -alias alog='kubectl logs `kubectl get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c apiserver' -alias olog='kubectl logs `kubectl get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c operator' -alias slog='kubectl logs `kubectl get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c scheduler' +# useful functions +setip() { + export CO_APISERVER_URL=https://`kubectl -n "$CO_NAMESPACE" get service postgres-operator -o=jsonpath="{.spec.clusterIP}"`:8443 +} +alog() { + kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c apiserver +} + +olog() { + kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c operator +} + +slog() { + kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c scheduler +} From e7ca00766f99fddc2e2bf1bb64db2271abfd6d4d Mon Sep 17 00:00:00 2001 From: Paul Cahoon Date: Mon, 4 Mar 2019 13:57:33 -0500 Subject: [PATCH 6/8] create stale.yml --- .github/stale.yml | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000000..c7e328933c --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,58 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 60 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 7 + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - pinned + - security + - "[Status] Maybe Later" + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: wontfix + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +# closeComment: > +# Your comment here. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +# only: issues + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +# pulls: +# daysUntilStale: 30 +# markComment: > +# This pull request has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. + +# issues: +# exemptLabels: +# - confirmed From fa5092962dd0e3d95bea2c3ded60a5132c7f88ce Mon Sep 17 00:00:00 2001 From: Carvel Baus Date: Mon, 17 Jun 2019 14:35:23 -0400 Subject: [PATCH 7/8] Fix label used during delete of pgpool resources --- apiserver/clusterservice/clusterimpl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/clusterservice/clusterimpl.go b/apiserver/clusterservice/clusterimpl.go index 94c97d38a5..eea6ec700e 100644 --- a/apiserver/clusterservice/clusterimpl.go +++ b/apiserver/clusterservice/clusterimpl.go @@ -990,7 +990,7 @@ func createDeleteDataTasks(clusterName string, storageSpec crv1.PgStorageSpec, d var err error //dont include pgpool or pgbouncer deployments - selector := config.LABEL_PG_CLUSTER + "=" + clusterName + "," + config.LABEL_PGBACKUP + "!=true," + config.LABEL_PGPOOL + "!=true," + config.LABEL_PGBOUNCER + "!=true" + selector := config.LABEL_PG_CLUSTER + "=" + clusterName + "," + config.LABEL_PGBACKUP + "!=true," + config.LABEL_PGPOOL_POD + "!=true," + config.LABEL_PGBOUNCER + "!=true" log.Debugf("selector for delete is %s", selector) deployments, err := kubeapi.GetDeployments(apiserver.Clientset, selector, ns) if err != nil { From 5105ee632497e83bb56cbd87a75f022b3a9c2586 Mon Sep 17 00:00:00 2001 From: Carvel Baus Date: Mon, 17 Jun 2019 14:52:02 -0400 Subject: [PATCH 8/8] Fix previous merge issue with file --- examples/envs.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/envs.sh b/examples/envs.sh index 682c7eaa82..c76c70d975 100644 --- a/examples/envs.sh +++ b/examples/envs.sh @@ -32,13 +32,13 @@ setip() } alog() { - kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c apiserver +$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" logs `$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c apiserver } -olog() { - kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c operator +olog () { +$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" logs `$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c operator } -slog() { - kubectl -n "$CO_NAMESPACE" logs `kubectl -n "$CO_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c scheduler +slog () { +$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" logs `$PGO_CMD -n "$PGO_OPERATOR_NAMESPACE" get pod --selector=name=postgres-operator -o jsonpath="{.items[0].metadata.name}"` -c scheduler }