|
| 1 | + |
| 2 | +This directory contains the files needed to offer the Operator as a |
| 3 | +[Google Cloud Platform Marketplace Kubernetes application][gcp-k8s]. |
| 4 | + |
| 5 | +The integration centers around a container [image](./Dockerfile) that contains an installation |
| 6 | +[schema](./schema.yaml) and an [Application][k8s-app] [manifest](./application.yaml). |
| 7 | +Consult the [technical requirements][gcp-k8s-requirements] when making changes. |
| 8 | + |
| 9 | +[k8s-app]: https://github.com/kubernetes-sigs/application/ |
| 10 | +[gcp-k8s]: https://cloud.google.com/marketplace/docs/kubernetes-apps/ |
| 11 | +[gcp-k8s-requirements]: https://cloud.google.com/marketplace/docs/partners/kubernetes-solutions/create-app-package |
| 12 | +[gcp-k8s-tool-images]: https://console.cloud.google.com/gcr/images/cloud-marketplace-tools |
| 13 | +[gcp-k8s-tool-repository]: https://github.com/GoogleCloudPlatform/marketplace-k8s-app-tools |
| 14 | + |
| 15 | + |
| 16 | +# Installation |
| 17 | + |
| 18 | +## Quick install with Google Cloud Marketplace |
| 19 | + |
| 20 | +Install this application to a Google Kubernetes Engine cluster using Google Cloud Marketplace. |
| 21 | + |
| 22 | +## Command line instructions |
| 23 | + |
| 24 | +### Prepare |
| 25 | + |
| 26 | +1. You'll need the following tools in your development environment. If you are using Cloud Shell, |
| 27 | + everything is already installed. |
| 28 | + |
| 29 | + - envsubst |
| 30 | + - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| 31 | + - [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) |
| 32 | + |
| 33 | +2. Clone this repository. |
| 34 | + |
| 35 | + ```shell |
| 36 | + git clone https://github.com/CrunchyData/postgres-operator.git |
| 37 | + ``` |
| 38 | + |
| 39 | +3. Install the [Application][k8s-app] Custom Resource Definition. |
| 40 | + |
| 41 | + ```shell |
| 42 | + kubectl apply -f 'https://raw.githubusercontent.com/GoogleCloudPlatform/marketplace-k8s-app-tools/master/crd/app-crd.yaml' |
| 43 | + ``` |
| 44 | + |
| 45 | +4. At least one Storage Class is required. Google Kubernetes Engine is preconfigured with a default. |
| 46 | + |
| 47 | + ```shell |
| 48 | + kubectl get storageclasses |
| 49 | + ``` |
| 50 | + |
| 51 | +### Install the PostgreSQL Operator |
| 52 | + |
| 53 | +1. Configure the installation by setting environment variables. |
| 54 | + |
| 55 | + 1. Choose a version to install. |
| 56 | + |
| 57 | + ```shell |
| 58 | + IMAGE_REPOSITORY=gcr.io/crunchydata-public/postgres-operator |
| 59 | + |
| 60 | + export PGO_VERSION=4.1.1 |
| 61 | + export INSTALLER_IMAGE=${IMAGE_REPOSITORY}/deployer:${PGO_VERSION} |
| 62 | + export OPERATOR_IMAGE=${IMAGE_REPOSITORY}:${PGO_VERSION} |
| 63 | + export OPERATOR_IMAGE_API=${IMAGE_REPOSITORY}/pgo-apiserver:${PGO_VERSION} |
| 64 | + export OPERATOR_IMAGE_EVENT=${IMAGE_REPOSITORY}/pgo-event:${PGO_VERSION} |
| 65 | + export OPERATOR_IMAGE_SCHEDULER=${IMAGE_REPOSITORY}/pgo-scheduler:${PGO_VERSION} |
| 66 | + ``` |
| 67 | + |
| 68 | + 2. Choose a namespace and name for the application. |
| 69 | + |
| 70 | + ```shell |
| 71 | + export OPERATOR_NAMESPACE=pgo OPERATOR_NAME=pgo |
| 72 | + ``` |
| 73 | + |
| 74 | + 2. Choose a password for the application admin. |
| 75 | + |
| 76 | + ```shell |
| 77 | + export OPERATOR_ADMIN_PASSWORD=changethis |
| 78 | + ``` |
| 79 | + |
| 80 | + 4. Choose default values for new PostgreSQL clusters. |
| 81 | + |
| 82 | + ```shell |
| 83 | + export POSTGRES_METRICS=false |
| 84 | + export POSTGRES_SERVICE_TYPE=ClusterIP |
| 85 | + export POSTGRES_CPU=1000 # mCPU |
| 86 | + export POSTGRES_MEM=2 # GiB |
| 87 | + export POSTGRES_STORAGE_CAPACITY=1 # GiB |
| 88 | + export POSTGRES_STORAGE_CLASS=ssd |
| 89 | + export PGBACKREST_STORAGE_CAPACITY=2 # GiB |
| 90 | + export PGBACKREST_STORAGE_CLASS=ssd |
| 91 | + export BACKUP_STORAGE_CAPACITY=1 # GiB |
| 92 | + export BACKUP_STORAGE_CLASS=ssd |
| 93 | + ``` |
| 94 | + |
| 95 | +2. Prepare the Kubernetes namespace. |
| 96 | + |
| 97 | + ```shell |
| 98 | + export INSTALLER_SERVICE_ACCOUNT=postgres-operator-installer |
| 99 | +
|
| 100 | + kubectl create namespace "$OPERATOR_NAMESPACE" |
| 101 | + kubectl create serviceaccount -n "$OPERATOR_NAMESPACE" "$INSTALLER_SERVICE_ACCOUNT" |
| 102 | + kubectl create clusterrolebinding \ |
| 103 | + "$OPERATOR_NAMESPACE:$INSTALLER_SERVICE_ACCOUNT:cluster-admin" \ |
| 104 | + --serviceaccount="$OPERATOR_NAMESPACE:$INSTALLER_SERVICE_ACCOUNT" \ |
| 105 | + --clusterrole=cluster-admin |
| 106 | + ``` |
| 107 | + |
| 108 | +3. Generate and apply Kubernetes manifests. |
| 109 | + |
| 110 | + ```shell |
| 111 | + envsubst < application.yaml > "${OPERATOR_NAME}_application.yaml" |
| 112 | + envsubst < install-job.yaml > "${OPERATOR_NAME}_install-job.yaml" |
| 113 | + envsubst < inventory.ini > "${OPERATOR_NAME}_inventory.ini" |
| 114 | +
|
| 115 | + kubectl create -n "$OPERATOR_NAMESPACE" secret generic install-postgres-operator \ |
| 116 | + --from-file=inventory="${OPERATOR_NAME}_inventory.ini" |
| 117 | +
|
| 118 | + kubectl create -n "$OPERATOR_NAMESPACE" -f "${OPERATOR_NAME}_application.yaml" |
| 119 | + kubectl create -n "$OPERATOR_NAMESPACE" -f "${OPERATOR_NAME}_install-job.yaml" |
| 120 | + ``` |
| 121 | + |
| 122 | +The application can be seen in Google Cloud Platform Console at [Kubernetes Applications][]. |
| 123 | + |
| 124 | +[Kubernetes Applications]: https://console.cloud.google.com/kubernetes/application |
| 125 | + |
| 126 | + |
| 127 | +# Uninstallation |
| 128 | + |
| 129 | +## Using Google Cloud Platform Console |
| 130 | + |
| 131 | +1. In the Console, open [Kubernetes Applications][]. |
| 132 | +2. From the list of applications, select _Crunchy PostgreSQL Operator_ then click _Delete_. |
| 133 | + |
| 134 | +## Command line instructions |
| 135 | + |
| 136 | +Delete the Kubernetes resources created during install. |
| 137 | + |
| 138 | +```shell |
| 139 | +export OPERATOR_NAMESPACE=pgo OPERATOR_NAME=pgo |
| 140 | +
|
| 141 | +kubectl delete -n "$OPERATOR_NAMESPACE" job install-postgres-operator |
| 142 | +kubectl delete -n "$OPERATOR_NAMESPACE" secret install-postgres-operator |
| 143 | +kubectl delete -n "$OPERATOR_NAMESPACE" application "$OPERATOR_NAME" |
| 144 | +``` |
0 commit comments