OpenShift PostgreSQL: Difference between revisions
No edit summary |
|||
(13 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[OpenShift Auxiliary Tools Operations#Operations|OpenShift Auxiliary Tools Operations]] | * [[OpenShift Auxiliary Tools Operations#Operations|OpenShift Auxiliary Tools Operations]] | ||
* [[ | * [[PostgreSQL]] | ||
=Installation= | =Installation= | ||
==PostgreSQL Image Notes== | |||
The Posgresql container image contains a README.md in usr/share/container-scripts/postgresql and a setup script in usr/share/container-scripts/postgresql/common.sh. | |||
The [[Docker_Concepts#Entrypoint|entrypoint script]] will first run [[PostgreSQL_DDL_Operations#initdb|initdb]] which will create the user (POSTGRESQL_USER) and the database (POSTGRESQL_DATABASE). | |||
==Create OpenShift Infrastructure== | ==Create OpenShift Infrastructure== | ||
You can use the following generic | 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. | Copy it locally. Normally, you should not need to modify it manually, unless you want to use newer versions. | ||
Line 15: | Line 21: | ||
[[oc process]] -f ./generic-postgresql.yaml \ | [[oc process]] -f ./generic-postgresql.yaml \ | ||
- | -p APPLICATION_NAME=... \ | ||
- | -p POSTGRESQL_USER=... \ | ||
- | -p POSTGRESQL_PASSWORD=... \ | ||
- | -p POSTGRESQL_DATABASE=... \ | ||
| [[oc create]] -f - | | [[oc create]] -f - | ||
==Create | ==Create the Database== | ||
Log into the pod: | Log into the pod: | ||
Line 29: | Line 35: | ||
The user is already created. | The user is already created. | ||
<font color=red>'''TODO''': Investigate why the a custom user ('gogs') is created automatically, but the database is not.</font> | |||
==Activate the Readiness Probe== | ==Activate the Readiness Probe== |
Latest revision as of 06:53, 19 October 2018
Internal
Installation
PostgreSQL Image Notes
The Posgresql container image contains a README.md in usr/share/container-scripts/postgresql and a setup script in usr/share/container-scripts/postgresql/common.sh.
The entrypoint script will first run initdb which will create the user (POSTGRESQL_USER) and the database (POSTGRESQL_DATABASE).
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 \ -p APPLICATION_NAME=... \ -p POSTGRESQL_USER=... \ -p POSTGRESQL_PASSWORD=... \ -p POSTGRESQL_DATABASE=... \ | oc create -f -
Create the Database
Log into the pod:
oc rsh <postgres-pod-name> createdb <dbname>
The user is already created.
TODO: Investigate why the a custom user ('gogs') is created automatically, but the database is not.
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