diff --git a/manifests/interdomainservice.yaml b/manifests/interdomainservice.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6a107eec2503ae604168382280a57341ef3387d4 --- /dev/null +++ b/manifests/interdomainservice.yaml @@ -0,0 +1,64 @@ +# 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 diff --git a/src/interdomain/Config.py b/src/interdomain/Config.py index b2e558ac1fc367bffcc414ebddb2ec737e16f672..2e236fa9f7b8974e2c7add60af3ef7f1a47724aa 100644 --- a/src/interdomain/Config.py +++ b/src/interdomain/Config.py @@ -1,10 +1,24 @@ +# 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 # General settings LOG_LEVEL = logging.WARNING # gRPC settings -GRPC_INTERDOMAIN_PORT = 9090 +GRPC_SERVICE_PORT = 10010 GRPC_MAX_WORKERS = 10 GRPC_GRACE_PERIOD = 60 @@ -13,6 +27,6 @@ METRICS_PORT = 9192 # Dependency micro-service connection settings SLICE_SERVICE_HOST = '127.0.0.1' -SLICE_SERVICE_PORT = 1010 +SLICE_SERVICE_PORT = 4040 diff --git a/src/interdomain/Dockerfile b/src/interdomain/Dockerfile index 26438173cffefcf6da40fe971167b6749928a2d0..7ae62928e0a09ade5fdec781187cf54279b880c8 100644 --- a/src/interdomain/Dockerfile +++ b/src/interdomain/Dockerfile @@ -1,3 +1,17 @@ +# 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 # Install dependencies @@ -25,7 +39,7 @@ RUN mkdir -p /var/teraflow/interdomain # Get Python packages per module COPY interdomain/requirements.in 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 COPY common/. common @@ -35,5 +49,5 @@ COPY monitoring/. monitoring COPY service/. service COPY interdomain/. interdomain -# Start service interdomain -ENTRYPOINT ["python", "-m", "service.interdomain"] +# Start interdomain service +ENTRYPOINT ["python", "-m", "interdomain.service"] diff --git a/src/interdomain/client/__init__.py b/src/interdomain/client/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/interdomain/client/__init__.py +++ b/src/interdomain/client/__init__.py @@ -0,0 +1,14 @@ +# 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. + diff --git a/src/interdomain/proto/__init__.py b/src/interdomain/proto/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/interdomain/proto/__init__.py +++ b/src/interdomain/proto/__init__.py @@ -0,0 +1,14 @@ +# 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. + diff --git a/src/interdomain/service/__main__.py b/src/interdomain/service/__main__.py index 4864516823341bc385ba33b27e6875b9ab160c32..8fbe01770371446289b93b965dac92f1faba6713 100644 --- a/src/interdomain/service/__main__.py +++ b/src/interdomain/service/__main__.py @@ -1,3 +1,17 @@ +# 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 from prometheus_client import start_http_server from common.Settings import get_setting @@ -10,7 +24,7 @@ from .InterdomainService import InterdomainService terminate = threading.Event() -LOGGER = None +LOGGER : logging.Logger = None def signal_handler(signal, frame): # pylint: disable=redefined-outer-name LOGGER.warning('Terminate signal received') @@ -19,18 +33,23 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name def main(): global LOGGER # pylint: disable=global-statement - grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_INTERDOMAIN_PORT ) - max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) - grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) - log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) - 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) - + grpc_service_port = get_setting('INTERDOMAINSERVICE_SERVICE_PORT_GRPC', default=GRPC_SERVICE_PORT ) + max_workers = get_setting('MAX_WORKERS', default=GRPC_MAX_WORKERS ) + grace_period = get_setting('GRACE_PERIOD', default=GRPC_GRACE_PERIOD ) + log_level = get_setting('LOG_LEVEL', default=LOG_LEVEL ) + metrics_port = get_setting('METRICS_PORT', default=METRICS_PORT ) logging.basicConfig(level=log_level) 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.SIGTERM, signal_handler) @@ -41,12 +60,14 @@ def main(): # Initialize Slice Client 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))) slice_client = SliceClient(slice_service_host, slice_service_port) - # Starting service service - grpc_interdomain = InterdomainService( slice_client=slice_client, port=grpc_interdomain_port, max_workers=max_workers, grace_period=grace_period) + # Starting Interdomain service + grpc_interdomain = InterdomainService( + slice_client=slice_client, port=grpc_interdomain_port, max_workers=max_workers, + grace_period=grace_period) grpc_interdomain.start() # Wait for Ctrl+C or termination signal diff --git a/src/interdomain/tests/__init__.py b/src/interdomain/tests/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..70a33251242c51f49140e596b8208a19dd5245f7 100644 --- a/src/interdomain/tests/__init__.py +++ b/src/interdomain/tests/__init__.py @@ -0,0 +1,14 @@ +# 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. +