OpenShift PostgreSQL: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 32: Line 32:
==Activate the Readiness Probe==
==Activate the Readiness Probe==


Modify the specification of the "postgresql" container and add the following readiness probe:
Modify the specification of the "postgresql" container with
 
oc edit dc/<''dc-name''>
 
Add the following readiness probe, under the liveness probe:


           readinessProbe:
           readinessProbe:

Revision as of 03:20, 26 November 2017

Internal

Installation

Create OpenShift Infrastructure

You can use the following generic Postgresql template: https://github.com/NovaOrdis/playground/blob/master/openshift/auxiliary-tools/generic-postgresql.yaml

Copy it locally. Normally, you should not need to modify it manually, unless you want to use newer versions.

Make sure that a persistent volume 1Gi or larger is available for binding.

oc process -f ./generic-postgresql.yaml \
 --param APPLICATION_NAME=... \
 --param POSTGRESQL_USER=... \
 --param POSTGRESQL_PASSWORD=... \
 --param POSTGRESQL_DATABASE=... \
| oc create -f -

Create the User and the Database

Log into the pod:

oc rsh <postgres-pod-name>
createdb <dbname>

The user is already created.

Activate the Readiness Probe

Modify the specification of the "postgresql" container with

oc edit dc/<dc-name>

Add the following readiness probe, under the liveness probe:

         readinessProbe:
           exec:
             command:
             - /bin/sh
             - -i
             - -c
             - psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'
           failureThreshold: 3
           initialDelaySeconds: 5
           periodSeconds: 10
           successThreshold: 1
           timeoutSeconds: 1