Commit 325a5941 authored by Alexander Lercher's avatar Alexander Lercher

Using K8s for message-broker connection

parent 09289708
import os import os
import shutil
docker_reg = 'localhost:5000' docker_reg = 'localhost:5000'
DOCKER_COMPOSE_NAME = "Dockerfile"
paths = [] paths = []
for r, _, f in os.walk('./'): for r, _, f in os.walk('./'):
for file in f: for file in f:
if 'Dockerfile' == file: if DOCKER_COMPOSE_NAME == file:
paths.append(os.path.join(r, '')) paths.append(os.path.join(r, ''))
command_args = [{'path': path, command_args = [{'path': path,
# ./transaction-hub-out/tokenized-decision-making-microservice/Dockerfile 'name': str(path).split('/')[2]}
# -> tokenized-decision-making for path
#'name': '-'.join(str(path).split('/')[2].split('-')[:-1])} in paths]
'name': str(path).split('/')[2]}
for path
in paths]
for command_arg in command_args: for command_arg in command_args:
path = command_arg['path']
image_name = f"{docker_reg}/{command_arg['name']}" image_name = f"{docker_reg}/{command_arg['name']}"
os.system(f"docker image build -t {image_name} {command_arg['path']}")
# copy Dockerfile into root dir to have access to modules folder
shutil.copy2(os.path.join(path, DOCKER_COMPOSE_NAME), './')
os.system(f"docker image build -t {image_name} .")
os.remove(DOCKER_COMPOSE_NAME)
os.system(f"docker push {image_name}") os.system(f"docker push {image_name}")
print(f"Finished {image_name}") print(f"Finished {image_name}")
\ No newline at end of file
...@@ -2,7 +2,7 @@ apiVersion: v1 ...@@ -2,7 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: rabbit-mq-endpoint name: rabbit-mq
spec: spec:
type: LoadBalancer type: LoadBalancer
......
...@@ -7,11 +7,13 @@ ENV https_proxy http://proxy.uni-klu.ac.at:3128/ ...@@ -7,11 +7,13 @@ ENV https_proxy http://proxy.uni-klu.ac.at:3128/
RUN apt-get update RUN apt-get update
RUN pip install flask RUN pip install flask
RUN pip install connexion[swagger-ui] RUN pip install connexion[swagger-ui]
RUN pip install pika
EXPOSE 5000 EXPOSE 5000
WORKDIR /app WORKDIR /app
COPY app/ /app/ COPY transaction-hub-in/trace-retrieval-microservice/app/ /app/
COPY modules/ /app/
RUN chmod a+x main.py RUN chmod a+x main.py
CMD ["python", "./main.py"] CMD ["python", "./main.py"]
\ No newline at end of file
...@@ -10,6 +10,9 @@ import connexion ...@@ -10,6 +10,9 @@ import connexion
from messaging.MessageReceiver import MessageReceiver from messaging.MessageReceiver import MessageReceiver
from messaging.MessageSender import MessageSender from messaging.MessageSender import MessageSender
RABBIT_MQ_DNS_NAME = 'rabbit-mq'
RABBIT_MQ_PORT = '5672'
message_sender = None message_sender = None
# init message handler # init message handler
...@@ -28,10 +31,10 @@ def api_root(): ...@@ -28,10 +31,10 @@ def api_root():
# start app # start app
if __name__ == '__main__': if __name__ == '__main__':
message_rec = MessageReceiver(exchange_name='inhub', exchange_type='direct', queue_name='trace-retrieval', auto_ack=True) message_rec = MessageReceiver(rabbit_mq_ip=RABBIT_MQ_DNS_NAME, rabbit_mq_port=RABBIT_MQ_PORT, exchange_name='inhub', exchange_type='direct', queue_name='trace-retrieval', auto_ack=True)
message_rec.start(message_received_callback) message_rec.start(message_received_callback)
message_sender = MessageSender() message_sender = MessageSender(rabbit_mq_ip=RABBIT_MQ_DNS_NAME, rabbit_mq_port=RABBIT_MQ_PORT)
message_sender.connect() message_sender.connect()
message_sender.create_exchange('rest-gateway', 'direct') message_sender.create_exchange('rest-gateway', 'direct')
......
...@@ -2,7 +2,7 @@ apiVersion: v1 ...@@ -2,7 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: trace-retrieval-endpoint name: trace-retrieval
spec: spec:
type: LoadBalancer type: LoadBalancer
......
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