1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/sbo-creating-a-postgresql-database-instance.adoc
2022-03-01 00:47:18 +00:00

86 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 enable 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 the `my-petclinic` namespace are running:
+
[source,terminal]
----
$ oc get pods -n my-petclinic
----
+
The output, which takes a few minutes to display, 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.