Skip to content
Snippets Groups Projects
Commit 92359886 authored by Julien Leduc's avatar Julien Leduc
Browse files

Everything needed to run a standalong postgres instance inside the cI

namespace. More in README_postgres.md
parent 87f48032
No related branches found
No related tags found
No related merge requests found
Pipeline #13744 failed
# Running with `postgres`
## External postgres instance:
Modify `database-postgres-sample.yaml` file to suit your configuration and submit it to `./run_systemtest.sh` using the `-d` option for example:
```
[root@ctadevjulien orchestration]# (postgres_CI) ./run_systemtest.sh -S -O -d database_postgres_dbod.yaml -s tests/archive_retrieve.sh -n toto -k
```
## Internal postgres instance:
In this case the postgres instance is launched in a `postgres` pod in the namespace.
This configuration allows developers to launch a standalone offline instance that does not require any externally configured database.
`internal_postgres.yaml` contains everything needed to launch an internal postgres instance, contact it with namespace DNS and configure CTA accordingly.
Here is an instanciation example of a standalone postgres DB instance with a local objectstore:
```
[root@ctadevjulien orchestration]# (postgres_CI) ./run_systemtest.sh -S -d internal_postgres.yaml -s tests/archive_retrieve.sh -n toto -k
```
apiVersion: v1
kind: ConfigMap
metadata:
name: database-config
labels:
config: database
type: postgres
data:
database.type: postgres
database.postgres.username: cta
database.postgres.password: cta
database.postgres.database: cta
# postgres server points to the postgres external server
database.postgres.server: postgres1234.cern.ch
###
# Internal postgres server
# implements:
# - a postgres server relying on official docker images
# - a postgres service
# - a configmap for pod configuration and CTA configuration
###
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
k8s-app: postgres
spec:
selector:
k8s-app: postgres
clusterIP: None
ports:
- name: postgres
port: 5432
protocol: TCP
---
apiVersion: v1
kind: ConfigMap
metadata:
name: database-config
labels:
config: database
type: postgres
data:
database.type: postgres
database.postgres.username: cta
database.postgres.password: cta
database.postgres.database: cta
database.postgres.path: /var/lib/postgresql/data/pgdata
# postgres service points to the postgresql container in namespace
database.postgres.server: postgres
---
apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
k8s-app: postgres
spec:
restartPolicy: Never
containers:
- name: postgres
image: postgres:9.6
stdin: true
env:
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: database-config
key: database.postgres.username
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
name: database-config
key: database.postgres.password
- name: PGDATA
valueFrom:
configMapKeyRef:
name: database-config
key: database.postgres.path
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: database-config
key: database.postgres.database
......@@ -27,7 +27,7 @@ SYSTEMTEST_TIMEOUT=3600
die() { echo "$@" 1>&2 ; exit 1; }
usage() { cat <<EOF 1>&2
Usage: $0 -n <namespace> -s <systemtest_script> [-p <gitlab pipeline ID> | -b <build tree base> -B <build tree subdir> ] [-t <systemtest timeout in seconds>] [-e <eos_configmap>] [-a <additional_k8_resources>] [-k] [-O] [-D] [-S]
Usage: $0 -n <namespace> -s <systemtest_script> [-p <gitlab pipeline ID> | -b <build tree base> -B <build tree subdir> ] [-t <systemtest timeout in seconds>] [-e <eos_configmap>] [-a <additional_k8_resources>] [-k] [-O] [-D | -d <database_configmap>] [-S]
Options:
-b The directory containing both the source and the build tree for CTA. It will be mounted RO in the
......@@ -51,7 +51,7 @@ exit 1
# always delete DB and OBJECTSTORE for tests
CREATE_OPTS="-D -O"
while getopts "n:s:p:b:e:a:B:t:kDOS" o; do
while getopts "n:d:s:p:b:e:a:B:t:kDOS" o; do
case "${o}" in
s)
systemtest_script=${OPTARG}
......@@ -60,6 +60,9 @@ while getopts "n:s:p:b:e:a:B:t:kDOS" o; do
n)
namespace=${OPTARG}
;;
d)
CREATE_OPTS="${CREATE_OPTS} -d ${OPTARG}"
;;
p)
CREATE_OPTS="${CREATE_OPTS} -p ${OPTARG}"
;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment