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: ...@@ -4,4 +4,13 @@ metadata:
name: mediametadatatodb-config name: mediametadatatodb-config
namespace: memobase namespace: memobase
data: 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/' URI_BASE: 'file:///data/'
...@@ -19,28 +19,11 @@ spec: ...@@ -19,28 +19,11 @@ spec:
containers: containers:
- name: mediametadatatodb-container - name: mediametadatatodb-container
image: cr.gitlab.switch.ch/memoriav/memobase-2020/services/postprocessing/mediametadatatodb:latest 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: envFrom:
- configMapRef: - configMapRef:
name: "prod-kafka-bootstrap-servers" name: "prod-kafka-bootstrap-servers"
- configMapRef: - configMapRef:
name: "mediametadatatodb-config" name: "mediametadatatodb-config"
- secretRef: - secretRef:
name: mariadb-secret name: mariadb-mb-db1-medienserver
ports:
- containerPort: 5000
name: http
protocol: TCP
imagePullPolicy: Always imagePullPolicy: Always
...@@ -59,13 +59,12 @@ def _connect_to_kafka(retries=0): ...@@ -59,13 +59,12 @@ def _connect_to_kafka(retries=0):
def _connect_to_mariadb(retries=0): def _connect_to_mariadb(retries=0):
password = os.environ["mediaserver"].split(':')[1].split('@tcp(')[0]
try: try:
mariadb_connection = mariadb.connect(user='medienserver', mariadb_connection = mariadb.connect(user=os.environ['MARIADB_USER'],
password=password, password=os.environ['MARIADB_PASSWORD'],
host='mb-db1.memobase.unibas.ch', host=os.environ['MARIADB_HOST'],
port=3306, port=int(os.environ['MARIADB_PORT']),
database='medienserver') database=os.environ['MARIADB_DATABASE'])
mariadb_connection.autocommit = False mariadb_connection.autocommit = False
mariadb_cursor = mariadb_connection.cursor() mariadb_cursor = mariadb_connection.cursor()
return mariadb_connection, mariadb_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