@@ -15,6 +15,9 @@ providing the essential features you need to keep your PostgreSQL clusters up an
1515 Set how long you want your backups retained for. Works great with very large databases!
1616- ** Monitoring** : Track the health of your PostgreSQL clusters using the open source [ pgMonitor] [ ] library.
1717- ** Clone** : Create new clusters from your existing clusters or backups with a single [ ` pgo create cluster --restore-from ` ] [ pgo-create-cluster ] command.
18+ - ** TLS** : Secure communication between your applications and data servers by [ enabling TLS for your PostgreSQL servers] [ pgo-task-tls ] , including the ability to enforce that all of your connections to use TLS.
19+ - ** Connection Pooling** : Use [ pgBouncer] [ ] for connection pooling
20+ - ** Affinity and Tolerations** : Have your PostgreSQL clusters deployed to [ Kubernetes Nodes] [ k8s-nodes ] of your preference with [ node affinity] [ high-availability-node-affinity ] , or designate which nodes Kubernetes can schedule PostgreSQL instances to with Kubneretes [ tolerations] [ high-availability-tolerations ] .
1821- ** Full Customizability** : Crunchy PostgreSQL for OpenShift makes it easy to get your own PostgreSQL-as-a-Service up and running on
1922 and lets make further enhancements to customize your deployments, including:
2023 - Selecting different storage classes for your primary, replica, and backup storage
@@ -27,16 +30,20 @@ and much more!
2730
2831[ disaster-recovery ] : https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/disaster-recovery/
2932[ high-availability ] : https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/high-availability/
33+ [ high-availability-node-affinity ] : https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/high-availability/#node-affinity
34+ [ high-availability-tolerations ] : https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/high-availability/#tolerations
3035[ pgo-create-cluster ] : https://access.crunchydata.com/documentation/postgres-operator/latest/pgo-client/reference/pgo_create_cluster/
36+ [ pgo-task-tls ] : https://access.crunchydata.com/documentation/postgres-operator/latest/tutorial/tls/
3137[ provisioning ] : https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/provisioning/
3238
3339[ k8s-anti-affinity ] : https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity
40+ [ k8s-nodes ] : https://kubernetes.io/docs/concepts/architecture/nodes/
3441
3542[ pgBackRest ] : https://www.pgbackrest.org
43+ [ pgBouncer ] : https://access.crunchydata.com/documentation/postgres-operator/latest/tutorial/pgbouncer/
3644[ pgMonitor ] : https://github.com/CrunchyData/pgmonitor
3745
38-
39- ## Before You Begin
46+ ## Pre-Installation
4047
4148There are a few manual steps that the cluster administrator must perform prior to installing the PostgreSQL Operator.
4249At the very least, it must be provided with an initial configuration.
@@ -80,8 +87,156 @@ oc -n "$PGO_OPERATOR_NAMESPACE" create secret tls pgo.tls \
8087
8188Once these resources are in place, the PostgreSQL Operator can be installed into the cluster.
8289
90+ ## Installation
91+
92+ You can now go ahead and install the PostgreSQL Operator from OperatorHub.
93+
94+ ### Security
95+
96+ For the PostgreSQL Operator and PostgreSQL clusters to run in the recommended ` restricted ` [ Security Context Constraint] [ ] ,
97+ edit the ConfigMap ` pgo-config ` , find the ` pgo.yaml ` entry, and set ` DisableFSGroup ` to ` true ` .
98+
99+ [ Security Context Constraint ] : https://docs.openshift.com/container-platform/latest/authentication/managing-security-context-constraints.html
100+
101+ You will have to scale the ` postgres-operator ` Deployment down and up for the above change to take effect:
102+
103+ ```
104+ oc -n pgo scale --replicas 0 deployment/postgres-operator
105+ oc -n pgo scale --replicas 1 deployment/postgres-operator
106+ ```
107+
108+ ## Post-Installation
109+
110+ ### Tutorial
111+
112+ For a guide on how to perform many of the daily functions of the PostgreSQL Operator, we recommend that you read the [ Postgres Operator tutorial] [ pgo-tutorial ]
113+
114+ [ pgo-tutorial ] : https://access.crunchydata.com/documentation/postgres-operator/latest/tutorial/create-cluster/
115+
116+ However, the below guide will show you how to create a Postgres cluster from a custom resource or from using the ` pgo-client ` .
117+
118+ ### Create a PostgreSQL Cluster from a Custom Resource
119+
120+ The fundamental workflow for interfacing with a PostgreSQL Operator Custom
121+ Resource Definition is for creating a PostgreSQL cluster. There are several
122+ that a PostgreSQL cluster requires to be deployed, including:
123+
124+ - Secrets
125+ - Information for setting up a pgBackRest repository
126+ - PostgreSQL superuser bootstrap credentials
127+ - PostgreSQL replication user bootstrap credentials
128+ - PostgresQL standard user bootstrap credentials
129+
130+ Additionally, if you want to add some of the other sidecars, you may need to
131+ create additional secrets.
132+
133+ The good news is that if you do not provide these objects, the PostgreSQL
134+ Operator will create them for you to get your Postgres cluster up and running!
135+
136+ The following goes through how to create a PostgreSQL cluster called
137+ ` hippo ` by creating a new custom resource.
138+
139+ ```
140+ # this variable is the name of the cluster being created
141+ export pgo_cluster_name=hippo
142+ # this variable is the namespace the cluster is being deployed into
143+ export cluster_namespace=pgo
144+ # this variable is set to the location of your image repository
145+ export cluster_image_prefix=registry.developers.crunchydata.com/crunchydata
146+
147+ cat <<-EOF > "${pgo_cluster_name}-pgcluster.yaml"
148+ apiVersion: crunchydata.com/v1
149+ kind: Pgcluster
150+ metadata:
151+ annotations:
152+ current-primary: ${pgo_cluster_name}
153+ labels:
154+ crunchy-pgha-scope: ${pgo_cluster_name}
155+ deployment-name: ${pgo_cluster_name}
156+ name: ${pgo_cluster_name}
157+ pg-cluster: ${pgo_cluster_name}
158+ pgo-version: ${PGO_VERSION}
159+ pgouser: admin
160+ name: ${pgo_cluster_name}
161+ namespace: ${cluster_namespace}
162+ spec:
163+ BackrestStorage:
164+ accessmode: ReadWriteMany
165+ matchLabels: ""
166+ name: ""
167+ size: 1G
168+ storageclass: ""
169+ storagetype: create
170+ supplementalgroups: ""
171+ PrimaryStorage:
172+ accessmode: ReadWriteMany
173+ matchLabels: ""
174+ name: ${pgo_cluster_name}
175+ size: 1G
176+ storageclass: ""
177+ storagetype: create
178+ supplementalgroups: ""
179+ ReplicaStorage:
180+ accessmode: ReadWriteMany
181+ matchLabels: ""
182+ name: ""
183+ size: 1G
184+ storageclass: ""
185+ storagetype: create
186+ supplementalgroups: ""
187+ annotations: {}
188+ ccpimage: crunchy-postgres-ha
189+ ccpimageprefix: ${cluster_image_prefix}
190+ ccpimagetag: centos8-13.1-${PGO_VERSION}
191+ clustername: ${pgo_cluster_name}
192+ database: ${pgo_cluster_name}
193+ exporterport: "9187"
194+ limits: {}
195+ name: ${pgo_cluster_name}
196+ namespace: ${cluster_namespace}
197+ pgDataSource:
198+ restoreFrom: ""
199+ restoreOpts: ""
200+ pgbadgerport: "10000"
201+ pgoimageprefix: ${cluster_image_prefix}
202+ podAntiAffinity:
203+ default: preferred
204+ pgBackRest: preferred
205+ pgBouncer: preferred
206+ port: "5432"
207+ tolerations: []
208+ user: hippo
209+ userlabels:
210+ pgo-version: ${PGO_VERSION}
211+ EOF
212+
213+ oc apply -f "${pgo_cluster_name}-pgcluster.yaml"
214+ ```
215+
216+ And that's all! The PostgreSQL Operator will go ahead and create the cluster.
217+
218+ If you have the PostgreSQL client ` psql ` installed on your host machine, you can
219+ test connection to the PostgreSQL cluster using the following command:
83220
84- ## After You Install
221+ ```
222+ # namespace that the cluster is running in
223+ export PGO_OPERATOR_NAMESPACE=pgo
224+ # name of the cluster
225+ export pgo_cluster_name=hippo
226+ # name of the user whose password we want to get
227+ export pgo_cluster_username=hippo
228+
229+ # get the password of the user and set it to a recognized psql environmental variable
230+ export PGPASSWORD=$(oc -n "${PGO_OPERATOR_NAMESPACE}" get secrets \
231+ "${pgo_cluster_name}-${pgo_cluster_username}-secret" -o "jsonpath={.data['password']}" | base64 -d)
232+
233+ # set up a port-forward either in a new terminal, or in the same terminal in the background:
234+ oc -n pgo port-forward svc/hippo 5432:5432 &
235+
236+ psql -h localhost -U "${pgo_cluster_username}" "${pgo_cluster_name}"
237+ ```
238+
239+ ### Create a PostgreSQL Cluster the ` pgo ` Client
85240
86241Once the PostgreSQL Operator is installed in your OpenShift cluster, you will need to do a few things
87242to use the [ PostgreSQL Operator Client] [ pgo-client ] .
@@ -123,3 +278,37 @@ pgo version
123278# pgo client version ${PGO_VERSION}
124279# pgo-apiserver version ${PGO_VERSION}
125280```
281+
282+
283+ You can then create a cluster with the ` pgo ` client as simply as this:
284+
285+ ```
286+ pgo create cluster -n pgo hippo
287+ ```
288+
289+ The cluster may take a few moments to provision. You can verify that the cluster is up and running by using the ` pgo test ` command:
290+
291+ ```
292+ pgo test cluster -n pgo hippo
293+ ```
294+
295+ If you have the PostgreSQL client ` psql ` installed on your host machine, you can
296+ test connection to the PostgreSQL cluster using the following command:
297+
298+ ```
299+ # namespace that the cluster is running in
300+ export PGO_OPERATOR_NAMESPACE=pgo
301+ # name of the cluster
302+ export pgo_cluster_name=hippo
303+ # name of the user whose password we want to get
304+ export pgo_cluster_username=hippo
305+
306+ # get the password of the user and set it to a recognized psql environmental variable
307+ export PGPASSWORD=$(kubectl -n "${PGO_OPERATOR_NAMESPACE}" get secrets \
308+ "${pgo_cluster_name}-${pgo_cluster_username}-secret" -o "jsonpath={.data['password']}" | base64 -d)
309+
310+ # set up a port-forward either in a new terminal, or in the same terminal in the background:
311+ kubectl -n pgo port-forward svc/hippo 5432:5432 &
312+
313+ psql -h localhost -U "${pgo_cluster_username}" "${pgo_cluster_name}"
314+ ```
0 commit comments