postgres operator fixes

This commit is contained in:
Edward Viaene
2020-06-10 12:19:20 +02:00
parent 1229e4073d
commit 4499cf9ef2
7 changed files with 716 additions and 161 deletions

View File

@@ -1,5 +1,5 @@
# Files
quickstart-for-gke.sh. Tested version available in directory, or latest from: https://github.com/CrunchyData/postgres-operator/blob/master/examples/quickstart-for-gke.sh
There is no quickstart-for-gke.sh anymore. This has been replaced by quickstart.sh.
# setup storage
```
@@ -8,7 +8,7 @@ kubectl create -f storage.yml
# setup Operator
```
./quickstart-for-gke.sh
./quickstart.sh
./set-path.sh
```
@@ -17,7 +17,8 @@ After these commands you'll need to logout and login again.
# port forwarding
```
kubectl port-forward postgres-operator-xxx-yyy 18443:8443
kubectl get pods -n pgo
kubectl port-forward -n pgo postgres-operator-xxx-yyy 8443:8443
```
# Test command
@@ -30,17 +31,17 @@ pgo version
```
pgo create cluster mycluster
pgo show cluster all
```
# show secrets
```
pgo show cluster mycluster --show-secrets=true
pgo show cluster mycluster
```
# connect to psql
```
kubectl run -it --rm --image=postgres:10.4 psql -- psql -h mycluster -U postgres -W
pgo show user mycluster
kubectl run -it --rm --image=postgres:10.4 psql-client -- psql -h mycluster.pgo -U testuser -W postgres
```

View File

@@ -0,0 +1,80 @@
#!/bin/bash
# Copyright 2020 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.
# This script should be run after the operator has been deployed
PGO_OPERATOR_NAMESPACE="${PGO_OPERATOR_NAMESPACE:-pgo}"
PGO_USER_ADMIN="${PGO_USER_ADMIN:-pgouser-admin}"
PGO_CLIENT_VERSION="${PGO_CLIENT_VERSION:-v4.3.2}"
PGO_CLIENT_URL="https://github.com/CrunchyData/postgres-operator/releases/download/${PGO_CLIENT_VERSION}"
PGO_CMD="${PGO_CMD-kubectl}"
# Checks operating system and determines which binary to download
UNAME_RESULT=$(uname)
if [[ "${UNAME_RESULT}" == "Linux" ]]
then
BIN_NAME="pgo"
elif [[ "${UNAME_RESULT}" == "Darwin" ]]
then
BIN_NAME="pgo-mac"
else
echo "${UNAME_RESULT} is not supported, valid operating systems are: Linux, Darwin"
echo "Exiting..."
exit 1
fi
# Creates the output directory for files
OUTPUT_DIR="${HOME}/.pgo/${PGO_OPERATOR_NAMESPACE}"
install -d -m a-rwx,u+rwx "${OUTPUT_DIR}"
echo "Operating System found is ${UNAME_RESULT}. Downloading ${BIN_NAME} client binary..."
curl -C - -Lo "${OUTPUT_DIR}/pgo" "${PGO_CLIENT_URL}/${BIN_NAME}"
chmod +x "${OUTPUT_DIR}/pgo"
# Check that the pgouser-admin secret exists
if [ -z "$($PGO_CMD get secret -n ${PGO_OPERATOR_NAMESPACE} ${PGO_USER_ADMIN})" ]
then
echo "${PGO_USER_ADMIN} Secret not found in namespace: ${PGO_OPERATOR_NAMESPACE}"
echo "Please ensure that the PostgreSQL Operator has been installed."
echo "Exiting..."
exit 1
fi
# Check that the pgo.tls secret exists
if [ -z "$($PGO_CMD get secret -n ${PGO_OPERATOR_NAMESPACE} pgo.tls)" ]
then
echo "pgo.tls Secret not found in namespace: ${PGO_OPERATOR_NAMESPACE}"
echo "Please ensure that the PostgreSQL Operator has been installed."
echo "Exiting..."
exit 1
fi
# Restrict access to the target file before writing
kubectl_get_private() { touch "$1" && chmod a-rwx,u+rw "$1" && $PGO_CMD get > "$1" "${@:2}"; }
# Use the pgouser-admin secret to generate pgouser file
kubectl_get_private "${OUTPUT_DIR}/pgouser" secret -n "${PGO_OPERATOR_NAMESPACE}" "${PGO_USER_ADMIN}" \
-o 'go-template={{ .data.username | base64decode }}:{{ .data.password | base64decode }}'
# Use the pgo.tls secret to generate the client cert files
kubectl_get_private "${OUTPUT_DIR}/client.crt" secret -n "${PGO_OPERATOR_NAMESPACE}" pgo.tls -o 'go-template={{ index .data "tls.crt" | base64decode }}'
kubectl_get_private "${OUTPUT_DIR}/client.key" secret -n "${PGO_OPERATOR_NAMESPACE}" pgo.tls -o 'go-template={{ index .data "tls.key" | base64decode }}'
echo "pgo client files have been generated, please add the following to your bashrc"
echo "export PATH=${OUTPUT_DIR}:\$PATH"
echo "export PGOUSER=${OUTPUT_DIR}/pgouser"
echo "export PGO_CA_CERT=${OUTPUT_DIR}/client.crt"
echo "export PGO_CLIENT_CERT=${OUTPUT_DIR}/client.crt"
echo "export PGO_CLIENT_KEY=${OUTPUT_DIR}/client.key"

View File

@@ -0,0 +1,305 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: pgo-deployer-sa
namespace: pgo
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pgo-deployer-cr
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- list
- create
- patch
- delete
- apiGroups:
- ''
resources:
- pods
verbs:
- list
- apiGroups:
- ''
resources:
- secrets
verbs:
- get
- create
- delete
- apiGroups:
- ''
resources:
- configmaps
- services
- persistentvolumeclaims
verbs:
- get
- create
- delete
- apiGroups:
- ''
resources:
- serviceaccounts
verbs:
- get
- create
- delete
- patch
- apiGroups:
- apps
- extensions
resources:
- deployments
verbs:
- get
- list
- create
- delete
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- create
- delete
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
verbs:
- get
- create
- delete
- bind
- escalate
- apiGroups:
- rbac.authorization.k8s.io
resources:
- roles
verbs:
- create
- delete
- apiGroups:
- batch
resources:
- jobs
verbs:
- delete
- apiGroups:
- crunchydata.com
resources:
- pgclusters
- pgreplicas
- pgpolicies
- pgtasks
verbs:
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: pgo-deployer-crb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: pgo-deployer-cr
subjects:
- kind: ServiceAccount
name: pgo-deployer-sa
namespace: pgo
---
apiVersion: batch/v1
kind: Job
metadata:
name: pgo-deploy
namespace: pgo
spec:
backoffLimit: 0
template:
metadata:
name: pgo-deploy
spec:
serviceAccountName: pgo-deployer-sa
restartPolicy: Never
containers:
- name: pgo-deploy
image: registry.developers.crunchydata.com/crunchydata/pgo-deployer:centos7-4.3.2
imagePullPolicy: IfNotPresent
env:
- name: ARCHIVE_MODE
value: "true"
- name: ARCHIVE_TIMEOUT
value: "60"
- name: BACKREST
value: "true"
- name: BADGER
value: "false"
- name: CRUNCHY_DEBUG
value: "false"
- name: CREATE_RBAC
value: "true"
- name: CCP_IMAGE_PREFIX
value: "registry.developers.crunchydata.com/crunchydata"
- name: CCP_IMAGE_TAG
value: "centos7-12.3-4.3.2"
- name: DB_PASSWORD_LENGTH
value: "24"
- name: DB_PORT
value: "5432"
- name: DB_REPLICAS
value: "0"
- name: DB_USER
value: "testuser"
- name: DEFAULT_INSTANCE_MEMORY
value: "128Mi"
- name: DEFAULT_PGBACKREST_MEMORY
value: ""
- name: DEFAULT_PGBOUNCER_MEMORY
value: ""
- name: DEPLOY_ACTION
value: "install"
- name: DISABLE_AUTO_FAILOVER
value: "false"
- name: DISABLE_FSGROUP
value: "false"
- name: DYNAMIC_RBAC
value: "false"
- name: EXPORTERPORT
value: "9187"
- name: METRICS
value: "false"
- name: NAMESPACE
value: "pgo"
- name: NAMESPACE_MODE
value: "dynamic"
- name: PGBADGERPORT
value: "10000"
- name: PGO_ADMIN_PASSWORD
value: "password"
- name: PGO_ADMIN_PERMS
value: "*"
- name: PGO_ADMIN_ROLE_NAME
value: "pgoadmin"
- name: PGO_ADMIN_USERNAME
value: "admin"
- name: PGO_CLIENT_VERSION
value: "v4.3.2"
- name: PGO_IMAGE_PREFIX
value: "registry.developers.crunchydata.com/crunchydata"
- name: PGO_IMAGE_TAG
value: "centos7-4.3.2"
- name: PGO_INSTALLATION_NAME
value: "devtest"
- name: PGO_OPERATOR_NAMESPACE
value: "pgo"
- name: SCHEDULER_TIMEOUT
value: "3600"
- name: BACKREST_STORAGE
value: "hostpathstorage"
- name: BACKUP_STORAGE
value: "hostpathstorage"
- name: PRIMARY_STORAGE
value: "hostpathstorage"
- name: REPLICA_STORAGE
value: "hostpathstorage"
- name: WAL_STORAGE
value: ""
- name: STORAGE1_NAME
value: "hostpathstorage"
- name: STORAGE1_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE1_SIZE
value: "1G"
- name: STORAGE1_TYPE
value: "create"
- name: STORAGE2_NAME
value: "replicastorage"
- name: STORAGE2_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE2_SIZE
value: "700M"
- name: STORAGE2_TYPE
value: "create"
- name: STORAGE3_NAME
value: "nfsstorage"
- name: STORAGE3_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE3_SIZE
value: "1G"
- name: STORAGE3_TYPE
value: "create"
- name: STORAGE3_SUPPLEMENTAL_GROUPS
value: "65534"
- name: STORAGE4_NAME
value: "nfsstoragered"
- name: STORAGE4_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE4_SIZE
value: "1G"
- name: STORAGE4_MATCH_LABEL
value: "crunchyzone=red"
- name: STORAGE4_TYPE
value: "create"
- name: STORAGE4_SUPPLEMENTAL_GROUPS
value: "65534"
- name: STORAGE5_NAME
value: "storageos"
- name: STORAGE5_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE5_SIZE
value: "5Gi"
- name: STORAGE5_TYPE
value: "dynamic"
- name: STORAGE5_CLASS
value: "fast"
- name: STORAGE6_NAME
value: "primarysite"
- name: STORAGE6_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE6_SIZE
value: "4G"
- name: STORAGE6_TYPE
value: "dynamic"
- name: STORAGE6_CLASS
value: "primarysite"
- name: STORAGE7_NAME
value: "alternatesite"
- name: STORAGE7_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE7_SIZE
value: "4G"
- name: STORAGE7_TYPE
value: "dynamic"
- name: STORAGE7_CLASS
value: "alternatesite"
- name: STORAGE8_NAME
value: "gce"
- name: STORAGE8_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE8_SIZE
value: "300M"
- name: STORAGE8_TYPE
value: "dynamic"
- name: STORAGE8_CLASS
value: "standard"
- name: STORAGE9_NAME
value: "rook"
- name: STORAGE9_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE9_SIZE
value: "1Gi"
- name: STORAGE9_TYPE
value: "dynamic"
- name: STORAGE9_CLASS
value: "rook-ceph-block"

View File

@@ -0,0 +1,305 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: pgo-deployer-sa
namespace: pgo
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pgo-deployer-cr
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- list
- create
- patch
- delete
- apiGroups:
- ''
resources:
- pods
verbs:
- list
- apiGroups:
- ''
resources:
- secrets
verbs:
- get
- create
- delete
- apiGroups:
- ''
resources:
- configmaps
- services
- persistentvolumeclaims
verbs:
- get
- create
- delete
- apiGroups:
- ''
resources:
- serviceaccounts
verbs:
- get
- create
- delete
- patch
- apiGroups:
- apps
- extensions
resources:
- deployments
verbs:
- get
- list
- create
- delete
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- create
- delete
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
verbs:
- get
- create
- delete
- bind
- escalate
- apiGroups:
- rbac.authorization.k8s.io
resources:
- roles
verbs:
- create
- delete
- apiGroups:
- batch
resources:
- jobs
verbs:
- delete
- apiGroups:
- crunchydata.com
resources:
- pgclusters
- pgreplicas
- pgpolicies
- pgtasks
verbs:
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: pgo-deployer-crb
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: pgo-deployer-cr
subjects:
- kind: ServiceAccount
name: pgo-deployer-sa
namespace: pgo
---
apiVersion: batch/v1
kind: Job
metadata:
name: pgo-deploy
namespace: pgo
spec:
backoffLimit: 0
template:
metadata:
name: pgo-deploy
spec:
serviceAccountName: pgo-deployer-sa
restartPolicy: Never
containers:
- name: pgo-deploy
image: registry.developers.crunchydata.com/crunchydata/pgo-deployer:centos7-4.3.2
imagePullPolicy: IfNotPresent
env:
- name: ARCHIVE_MODE
value: "true"
- name: ARCHIVE_TIMEOUT
value: "60"
- name: BACKREST
value: "true"
- name: BADGER
value: "false"
- name: CRUNCHY_DEBUG
value: "false"
- name: CREATE_RBAC
value: "true"
- name: CCP_IMAGE_PREFIX
value: "registry.developers.crunchydata.com/crunchydata"
- name: CCP_IMAGE_TAG
value: "centos7-12.3-4.3.2"
- name: DB_PASSWORD_LENGTH
value: "24"
- name: DB_PORT
value: "5432"
- name: DB_REPLICAS
value: "0"
- name: DB_USER
value: "testuser"
- name: DEFAULT_INSTANCE_MEMORY
value: "128Mi"
- name: DEFAULT_PGBACKREST_MEMORY
value: ""
- name: DEFAULT_PGBOUNCER_MEMORY
value: ""
- name: DEPLOY_ACTION
value: "install"
- name: DISABLE_AUTO_FAILOVER
value: "false"
- name: DISABLE_FSGROUP
value: "false"
- name: DYNAMIC_RBAC
value: "false"
- name: EXPORTERPORT
value: "9187"
- name: METRICS
value: "false"
- name: NAMESPACE
value: "pgo"
- name: NAMESPACE_MODE
value: "dynamic"
- name: PGBADGERPORT
value: "10000"
- name: PGO_ADMIN_PASSWORD
value: "password"
- name: PGO_ADMIN_PERMS
value: "*"
- name: PGO_ADMIN_ROLE_NAME
value: "pgoadmin"
- name: PGO_ADMIN_USERNAME
value: "admin"
- name: PGO_CLIENT_VERSION
value: "v4.3.2"
- name: PGO_IMAGE_PREFIX
value: "registry.developers.crunchydata.com/crunchydata"
- name: PGO_IMAGE_TAG
value: "centos7-4.3.2"
- name: PGO_INSTALLATION_NAME
value: "devtest"
- name: PGO_OPERATOR_NAMESPACE
value: "pgo"
- name: SCHEDULER_TIMEOUT
value: "3600"
- name: BACKREST_STORAGE
value: "standard"
- name: BACKUP_STORAGE
value: "standard"
- name: PRIMARY_STORAGE
value: "standard"
- name: REPLICA_STORAGE
value: "standard"
- name: WAL_STORAGE
value: ""
- name: STORAGE1_NAME
value: "standard"
- name: STORAGE1_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE1_SIZE
value: "1G"
- name: STORAGE1_TYPE
value: "create"
- name: STORAGE2_NAME
value: "replicastorage"
- name: STORAGE2_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE2_SIZE
value: "700M"
- name: STORAGE2_TYPE
value: "create"
- name: STORAGE3_NAME
value: "nfsstorage"
- name: STORAGE3_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE3_SIZE
value: "1G"
- name: STORAGE3_TYPE
value: "create"
- name: STORAGE3_SUPPLEMENTAL_GROUPS
value: "65534"
- name: STORAGE4_NAME
value: "nfsstoragered"
- name: STORAGE4_ACCESS_MODE
value: "ReadWriteMany"
- name: STORAGE4_SIZE
value: "1G"
- name: STORAGE4_MATCH_LABEL
value: "crunchyzone=red"
- name: STORAGE4_TYPE
value: "create"
- name: STORAGE4_SUPPLEMENTAL_GROUPS
value: "65534"
- name: STORAGE5_NAME
value: "storageos"
- name: STORAGE5_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE5_SIZE
value: "5Gi"
- name: STORAGE5_TYPE
value: "dynamic"
- name: STORAGE5_CLASS
value: "fast"
- name: STORAGE6_NAME
value: "primarysite"
- name: STORAGE6_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE6_SIZE
value: "4G"
- name: STORAGE6_TYPE
value: "dynamic"
- name: STORAGE6_CLASS
value: "primarysite"
- name: STORAGE7_NAME
value: "alternatesite"
- name: STORAGE7_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE7_SIZE
value: "4G"
- name: STORAGE7_TYPE
value: "dynamic"
- name: STORAGE7_CLASS
value: "alternatesite"
- name: STORAGE8_NAME
value: "gce"
- name: STORAGE8_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE8_SIZE
value: "300M"
- name: STORAGE8_TYPE
value: "dynamic"
- name: STORAGE8_CLASS
value: "standard"
- name: STORAGE9_NAME
value: "rook"
- name: STORAGE9_ACCESS_MODE
value: "ReadWriteOnce"
- name: STORAGE9_SIZE
value: "1Gi"
- name: STORAGE9_TYPE
value: "dynamic"
- name: STORAGE9_CLASS
value: "rook-ceph-block"

View File

@@ -1,154 +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.
LOG="pgo-installer.log"
export PGORELEASE=3.1
PGO_RELEASE_REMOTE_URL="https://github.com/CrunchyData/postgres-operator/releases/download/$PGORELEASE/postgres-operator.$PGORELEASE.tar.gz"
PGO_RELEASE_LOCAL_PATH="/tmp/postgres-operator.$PGORELEASE.tar.gz"
echo "Testing for dependencies..." | tee -a $LOG
which wget > /dev/null 2> /dev/null
if [[ $? -ne 0 ]]; then
which curl > /dev/null 2> /dev/null
if [[ $? -ne 0 ]]; then
echo "The required dependency wget and/or curl is missing on your system." | tee -a $LOG
exit 1
else
PGO_HTTP_CMD="curl -L -s -o ${PGO_RELEASE_LOCAL_PATH} ${PGO_RELEASE_REMOTE_URL}"
fi
else
PGO_HTTP_CMD="wget --quiet ${PGO_RELEASE_REMOTE_URL} -O ${PGO_RELEASE_LOCAL_PATH}"
fi
which kubectl > /dev/null 2> /dev/null
if [[ $? -ne 0 ]]; then
echo "The required dependency kubectl is missing on your system." | tee -a $LOG
exit 1
fi
echo ""
echo "Testing kubectl connection..." | tee -a $LOG
echo ""
kubectl get namespaces
if [[ $? -ne 0 ]]; then
echo "kubectl is not connecting to your Kubernetes Cluster. A successful connection is required to proceed." | tee -a $LOG
exit 1
fi
echo "Connected to Kubernetes." | tee -a $LOG
echo ""
NAMESPACE=`kubectl config current-context`
echo "The postgres-operator will be installed into the current namespace which is ["$NAMESPACE"]."
echo -n "Do you want to continue the installation? [yes no] "
read REPLY
if [[ "$REPLY" != "yes" ]]; then
echo "Aborting installation."
exit 1
fi
export CO_CMD=kubectl
export GOPATH=$HOME/odev
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH/bin
export CO_IMAGE_PREFIX=crunchydata
export CO_IMAGE_TAG=centos7-3.1
export COROOT=$GOPATH/src/github.com/crunchydata/postgres-operator
export CO_APISERVER_URL=https://127.0.0.1:18443
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
echo "Setting environment variables in $HOME/.bashrc..." | tee -a $LOG
cat <<'EOF' >> $HOME/.bashrc
# operator env vars
export CO_APISERVER_URL=https://127.0.0.1:18443
export PGO_CA_CERT=$HOME/odev/src/github.com/crunchydata/postgres-operator/conf/apiserver/server.crt
export PGO_CLIENT_CERT=$HOME/odev/src/github.com/crunchydata/postgres-operator/conf/apiserver/server.crt
export PGO_CLIENT_KEY=$HOME/odev/src/github.com/crunchydata/postgres-operator/conf/apiserver/server.key
#
EOF
echo "Setting up installation directory..." | tee -a $LOG
mkdir -p $HOME/odev/src $HOME/odev/bin $HOME/odev/pkg
mkdir -p $GOPATH/src/github.com/crunchydata/postgres-operator
echo ""
echo "Installing pgo server configuration..." | tee -a $LOG
`${PGO_HTTP_CMD}`
cd $COROOT
tar xzf /tmp/postgres-operator.$PGORELEASE.tar.gz
if [[ $? -ne 0 ]]; then
echo "ERROR: Problem unpackaging the $PGORELEASE release."
exit 1
fi
echo ""
echo "Installing pgo client..." | tee -a $LOG
mv pgo $GOBIN
mv pgo-mac $GOBIN
mv pgo.exe $GOBIN
mv expenv.exe $GOBIN
mv expenv-mac $GOBIN
mv expenv $GOBIN
echo "The available storage classes on your system:"
kubectl get sc
echo ""
echo -n "Enter the name of the storage class to use: "
read STORAGE_CLASS
echo ""
echo "Setting up pgo storage configuration for the selected storageclass..." | tee -a $LOG
cp $COROOT/examples/pgo.yaml.storageclass $COROOT/conf/apiserver/pgo.yaml
sed -i .bak 's/standard/'"$STORAGE_CLASS"'/' $COROOT/conf/apiserver/pgo.yaml
sed -i .bak 's/demo/'"$NAMESPACE"'/' $COROOT/deploy/service-account.yaml
sed -i .bak 's/demo/'"$NAMESPACE"'/' $COROOT/deploy/rbac.yaml
echo ""
echo "Setting up pgo client authentication..." | tee -a $LOG
echo "username:password" > $HOME/.pgouser
echo "For pgo bash completion you will need to install the bash-completion package." | tee -a $LOG
cp $COROOT/examples/pgo-bash-completion $HOME/.bash_completion
echo -n "Do you want to deploy the operator? [yes no] "
read REPLY
if [[ "$REPLY" == "yes" ]]; then
echo "Deploying the operator to the Kubernetes cluster..." | tee -a $LOG
$COROOT/deploy/deploy.sh | tee -a $LOG
fi
echo "Installation complete." | tee -a $LOG
echo ""
echo "At this point you can access the operator by using a port-forward command similar to:"
podname=`kubectl get pod --selector=name=postgres-operator -o jsonpath={..metadata.name}`
echo "kubectl port-forward " $podname " 18443:8443"
echo "Run this in another terminal or in the background."
echo ""
echo "WARNING: For the postgres-operator settings to take effect, it is necessary to log out of your session and back in or reload your .bashrc file."
echo ""
echo "NOTE: In order to access the pgo CLI, place it within your PATH from its default location in $HOME/odev/bin/pgo."

11
postgres-operator/quickstart.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
echo "This script replaces quickstart-for-gke.sh"
echo ""
echo "This script will:"
echo "- Create the pgo namespace"
echo "- Apply postgres-operator.yml"
echo "- install the client"
echo ""
kubectl create namespace pgo
kubectl apply -f postgres-operator.yml
./client-setup.sh

View File

@@ -1,2 +1,9 @@
#!/bin/bash
echo 'export PATH=$PATH:~/odev/bin/' >> ~/.bashrc
echo 'export PATH=$PATH:~/.pgo/pgo/' >> ~/.bashrc
echo 'export PGOUSER="${HOME?}/.pgo/pgo/pgouser"' >> ~/.bashrc
echo 'export PGO_CA_CERT="${HOME?}/.pgo/pgo/client.crt"' >> ~/.bashrc
echo 'export PGO_CLIENT_CERT="${HOME?}/.pgo/pgo/client.crt"' >> ~/.bashrc
echo 'export PGO_CLIENT_KEY="${HOME?}/.pgo/pgo/client.key"' >> ~/.bashrc
echo 'export PGO_APISERVER_URL='https://127.0.0.1:8443'' >> ~/.bashrc
echo 'export PGO_NAMESPACE=pgo' >> ~/.bashrc