mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
Fixing review comments Fixing some more review comments Fixed the RBAC requirements topic Updated note section Fixing the note section Fixing the output in the note section Fix QE review comments
87 lines
2.5 KiB
Plaintext
87 lines
2.5 KiB
Plaintext
:_content-type: PROCEDURE
|
|
[id="sbo-creating-a-postgresql-database-instance_{context}"]
|
|
= Creating a PostgreSQL database instance
|
|
|
|
To create a PostgreSQL database instance, you must create a `PostgresCluster` custom resource (CR) and configure the database.
|
|
|
|
[discrete]
|
|
.Procedure
|
|
|
|
. Create the `PostgresCluster` CR in the `my-petclinic` namespace by running the following command in shell:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc apply -n my-petclinic -f - << EOD
|
|
---
|
|
apiVersion: postgres-operator.crunchydata.com/v1beta1
|
|
kind: PostgresCluster
|
|
metadata:
|
|
name: hippo
|
|
spec:
|
|
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.4-0
|
|
postgresVersion: 13
|
|
instances:
|
|
- name: instance1
|
|
dataVolumeClaimSpec:
|
|
accessModes:
|
|
- "ReadWriteOnce"
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
backups:
|
|
pgbackrest:
|
|
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-2
|
|
repos:
|
|
- name: repo1
|
|
volume:
|
|
volumeClaimSpec:
|
|
accessModes:
|
|
- "ReadWriteOnce"
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
- name: repo2
|
|
volume:
|
|
volumeClaimSpec:
|
|
accessModes:
|
|
- "ReadWriteOnce"
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
proxy:
|
|
pgBouncer:
|
|
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-2
|
|
EOD
|
|
----
|
|
+
|
|
The annotations added in this `PostgresCluster` CR help in enabling the service binding connection and trigger the Operator reconciliation.
|
|
+
|
|
The output verifies that the database instance is created:
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
postgrescluster.postgres-operator.crunchydata.com/hippo created
|
|
----
|
|
|
|
. After you have created the database instance, ensure that all the pods in `my-petclinic` namespace are running (it will take a few minutes):
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc get pods -n my-petclinic
|
|
----
|
|
+
|
|
The output verifies that the database is created and configured:
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
NAME READY STATUS RESTARTS AGE
|
|
hippo-backup-nqjg-2rq94 1/1 Running 0 35s
|
|
hippo-instance1-nw92-0 3/3 Running 0 112s
|
|
hippo-pgbouncer-57b98f4476-znsk5 2/2 Running 0 112s
|
|
hippo-repo-host-0 1/1 Running 0 112s
|
|
----
|
|
+
|
|
After the database is configured, you can deploy the sample application and connect it to the database service.
|