Skip to content
Snippets Groups Projects
Commit 078b1976 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Created skeleton files for Interdomain component

parent d64ecf04
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!42Interdomain Component
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: interdomainservice
spec:
selector:
matchLabels:
app: interdomainservice
template:
metadata:
labels:
app: interdomainservice
spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: registry.gitlab.com/teraflow-h2020/controller/interdomain:latest
imagePullPolicy: Always
ports:
- containerPort: 10010
env:
- name: LOG_LEVEL
value: "INFO"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:10010"]
livenessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:10010"]
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 700m
memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
name: interdomainservice
spec:
type: ClusterIP
selector:
app: interdomainservice
ports:
- name: grpc
protocol: TCP
port: 10010
targetPort: 10010
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging import logging
# General settings # General settings
LOG_LEVEL = logging.WARNING LOG_LEVEL = logging.WARNING
# gRPC settings # gRPC settings
GRPC_INTERDOMAIN_PORT = 9090 GRPC_SERVICE_PORT = 10010
GRPC_MAX_WORKERS = 10 GRPC_MAX_WORKERS = 10
GRPC_GRACE_PERIOD = 60 GRPC_GRACE_PERIOD = 60
...@@ -13,6 +27,6 @@ METRICS_PORT = 9192 ...@@ -13,6 +27,6 @@ METRICS_PORT = 9192
# Dependency micro-service connection settings # Dependency micro-service connection settings
SLICE_SERVICE_HOST = '127.0.0.1' SLICE_SERVICE_HOST = '127.0.0.1'
SLICE_SERVICE_PORT = 1010 SLICE_SERVICE_PORT = 4040
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3-slim FROM python:3-slim
# Install dependencies # Install dependencies
...@@ -25,7 +39,7 @@ RUN mkdir -p /var/teraflow/interdomain ...@@ -25,7 +39,7 @@ RUN mkdir -p /var/teraflow/interdomain
# Get Python packages per module # Get Python packages per module
COPY interdomain/requirements.in interdomain/requirements.in COPY interdomain/requirements.in interdomain/requirements.in
RUN pip-compile --output-file=interdomain/requirements.txt interdomain/requirements.in RUN pip-compile --output-file=interdomain/requirements.txt interdomain/requirements.in
RUN python3 -m pip install -r interdomain/requirements.in RUN python3 -m pip install -r interdomain/requirements.txt
# Add files into working directory # Add files into working directory
COPY common/. common COPY common/. common
...@@ -35,5 +49,5 @@ COPY monitoring/. monitoring ...@@ -35,5 +49,5 @@ COPY monitoring/. monitoring
COPY service/. service COPY service/. service
COPY interdomain/. interdomain COPY interdomain/. interdomain
# Start service interdomain # Start interdomain service
ENTRYPOINT ["python", "-m", "service.interdomain"] ENTRYPOINT ["python", "-m", "interdomain.service"]
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging, signal, sys, threading import logging, signal, sys, threading
from prometheus_client import start_http_server from prometheus_client import start_http_server
from common.Settings import get_setting from common.Settings import get_setting
...@@ -10,7 +24,7 @@ from .InterdomainService import InterdomainService ...@@ -10,7 +24,7 @@ from .InterdomainService import InterdomainService
terminate = threading.Event() terminate = threading.Event()
LOGGER = None LOGGER : logging.Logger = None
def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def signal_handler(signal, frame): # pylint: disable=redefined-outer-name
LOGGER.warning('Terminate signal received') LOGGER.warning('Terminate signal received')
...@@ -19,18 +33,23 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name ...@@ -19,18 +33,23 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name
def main(): def main():
global LOGGER # pylint: disable=global-statement global LOGGER # pylint: disable=global-statement
grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_INTERDOMAIN_PORT ) grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT )
max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS )
grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD )
log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL )
metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT )
slice_service_host = get_setting('SLICESERVICE_SERVICE_HOST', default=SLICE_SERVICE_HOST)
slice_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=SLICE_SERVICE_PORT)
logging.basicConfig(level=log_level) logging.basicConfig(level=log_level)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
wait_for_environment_variables([
'CONTEXTSERVICE_SERVICE_HOST', 'CONTEXTSERVICE_SERVICE_PORT_GRPC',
'MONITORINGSERVICE_SERVICE_HOST', 'MONITORINGSERVICE_SERVICE_PORT_GRPC'
])
slice_service_host = get_setting('SLICESERVICE_SERVICE_HOST', default=SLICE_SERVICE_HOST )
slice_service_port = get_setting('SLICESERVICE_SERVICE_PORT_GRPC', default=SLICE_SERVICE_PORT )
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)
...@@ -41,12 +60,14 @@ def main(): ...@@ -41,12 +60,14 @@ def main():
# Initialize Slice Client # Initialize Slice Client
if slice_service_host is None or slice_service_port is None: if slice_service_host is None or slice_service_port is None:
raise Exception('Wrong address({:s}):port({:s}) of Device component'.format( raise Exception('Wrong address({:s}):port({:s}) of Slice component'.format(
str(slice_service_host), str(slice_service_port))) str(slice_service_host), str(slice_service_port)))
slice_client = SliceClient(slice_service_host, slice_service_port) slice_client = SliceClient(slice_service_host, slice_service_port)
# Starting service service # Starting Interdomain service
grpc_interdomain = InterdomainService( slice_client=slice_client, port=grpc_interdomain_port, max_workers=max_workers, grace_period=grace_period) grpc_interdomain = InterdomainService(
slice_client=slice_client, port=grpc_interdomain_port, max_workers=max_workers,
grace_period=grace_period)
grpc_interdomain.start() grpc_interdomain.start()
# Wait for Ctrl+C or termination signal # Wait for Ctrl+C or termination signal
......
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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