Unverified Commit 8aa9be6d authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

read mariadb connection details from cm and secret


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent 8cbc9c67
......@@ -4,4 +4,13 @@ metadata:
name: mediametadatatodb-config
namespace: memobase
data:
INPUT_TOPIC: 'fedora-output-json-records'
KAFKA_CONNECTION_RETRIES: '2'
KAFKA_GROUP_ID: 'medienserverMetadataService'
LOG_LEVEL: 'INFO'
MARIADB_CONNECTION_RETRIES: '2'
MARIADB_DATABASE: 'medienserver'
MARIADB_HOST: 'mb-db1.swissbib.unibas.ch'
MARIADB_PORT: '3306'
REPORTING_TOPIC: 'postprocessing-reporting'
URI_BASE: 'file:///data/'
......@@ -19,28 +19,11 @@ spec:
containers:
- name: mediametadatatodb-container
image: cr.gitlab.switch.ch/memoriav/memobase-2020/services/postprocessing/mediametadatatodb:latest
env:
- name: KAFKA_GROUP_ID
value: "medienserverMetadataService"
- name: KAFKA_CONNECTION_RETRIES
value: "3"
- name: MARIADB_CONNECTION_RETRIES
value: "3"
- name: INPUT_TOPIC
value: "fedora-output-json-records"
- name: REPORTING_TOPIC
value: "postprocessing-reporting"
- name: LOG_LEVEL
value: "INFO"
envFrom:
- configMapRef:
name: "prod-kafka-bootstrap-servers"
- configMapRef:
name: "mediametadatatodb-config"
- secretRef:
name: mariadb-secret
ports:
- containerPort: 5000
name: http
protocol: TCP
name: mariadb-mb-db1-medienserver
imagePullPolicy: Always
......@@ -59,13 +59,12 @@ def _connect_to_kafka(retries=0):
def _connect_to_mariadb(retries=0):
password = os.environ["mediaserver"].split(':')[1].split('@tcp(')[0]
try:
mariadb_connection = mariadb.connect(user='medienserver',
password=password,
host='mb-db1.memobase.unibas.ch',
port=3306,
database='medienserver')
mariadb_connection = mariadb.connect(user=os.environ['MARIADB_USER'],
password=os.environ['MARIADB_PASSWORD'],
host=os.environ['MARIADB_HOST'],
port=int(os.environ['MARIADB_PORT']),
database=os.environ['MARIADB_DATABASE'])
mariadb_connection.autocommit = False
mariadb_cursor = mariadb_connection.cursor()
return mariadb_connection, mariadb_cursor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment