From: Michal Chabiera Date: Tue, 30 Nov 2021 11:34:22 +0000 (+0100) Subject: xNF-5G Tutorial X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F83%2F125983%2F2;p=demo.git xNF-5G Tutorial Initial commit for xNF-5G Tutorial. Service composed of free5gc and ueransim. Issue-ID: INT-2011 Signed-off-by: Michal Chabiera Change-Id: Icf47cf877e541d9bbdf0d84afa8ce5e9237edfe9 --- diff --git a/tutorials/xNF_5G/ONES.pdf b/tutorials/xNF_5G/ONES.pdf new file mode 100644 index 00000000..7660895a Binary files /dev/null and b/tutorials/xNF_5G/ONES.pdf differ diff --git a/tutorials/xNF_5G/free5gc/README.txt b/tutorials/xNF_5G/free5gc/README.txt new file mode 100644 index 00000000..d1130908 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/README.txt @@ -0,0 +1,13 @@ +Demo directory structure: + +/templates/ #Base directory containing vFW resources + |- /base_dummy #Directory containing base payload of VSP package in OpenStack VSP format, doesn't need further proceeding + |- /base_native #Directory containing base payload of VSP package in Helm VSP, doesn't need further proceeding + |- /helm #Directory containing helm charts that need to be packaged and attached to VSP package + \- /cba #Directory containing CBA content to be included to csar package. It is prepared for +/examples/ #Directory with context-specific overrides over general resources +/automation/ #Directory with automation scripts. For more details read README file inside. + +Note: Makefile script generates two VSP packages, one in Frankfurt format with helm associated with dummy heat templates and second +with native Helm VSP format where helm packages are standalone. CBA folder contains CBA Definition for native VSP format but +make is coverting the definition into Frankfurt format for Frankfurt VSP. Frankfurt VSP is still supported in Guilin. diff --git a/tutorials/xNF_5G/free5gc/automation/Pipfile b/tutorials/xNF_5G/free5gc/automation/Pipfile new file mode 100644 index 00000000..e038fbed --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/Pipfile @@ -0,0 +1,13 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +onapsdk = "9.0.0" +kubernetes = "*" + +[requires] +python_version = "3.8" diff --git a/tutorials/xNF_5G/free5gc/automation/README.md b/tutorials/xNF_5G/free5gc/automation/README.md new file mode 100644 index 00000000..41eb4f06 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/README.md @@ -0,0 +1,33 @@ +# CNF automation + +0. Make sure you have python 3.8.x installed and default interpreter, what is required by onap-pythonsdk +1. Install required packages with pipenv `pipenv install` +2. Run virtual environment `pipenv shell`. In case of problems use `--fancy` option + + **In case of problems with pipenv:** `venv` can be used as well. In that case, please install all required python packages in correct version according the list in `Pipfile` +3. Add kubeconfig file for k8s cluster that will host your CNF + - `artifacts/cluster_kubeconfig` +4. Prepare onboarding packages `cd ../templates/ && make && cd ../automation/` +5. Modify `config.py`: + - NATIVE - enables native helm orchestration path in SO + - SKIP_POST_INSTANTIATION - whether post instantiation configuration should be run + - MACRO_INSTANTIATION - instantiation method used: macro or a'la carte + - K8S_NAMESPACE - k8s namespace to use for deployment of CNF + - K8S_VERSION - version of the k8s cluster + - K8S_REGION - name of the k8s region from the CLOUD_REGIONS + - CLOUD_REGIONS - configuration of k8s or Openstack regions + - GLOBAL_CUSTOMER_ID + - VENDOR + - SERVICENAME + - VNF_PARAM_LIST - list of parameters to pass for VNF creation process + - VF_MODULE_PARAM_LIST - list of parameters to pass for VF Module creation +6. __Important:__ Before running python scripts, some settings for `onapsdk` with information about ONAP endpoints (and socks) have to be exported. + All settings for ONAP instance are located in `automation/onap_settings.py` file. To export that settings please run command inside `pipenv` or `venv` shell + ```shell + (automation) ubuntu@onap:~/automation$ export ONAP_PYTHON_SDK_SETTINGS="onap_settings" + ``` +7. Run script `python create_cloud_regions.py` in order to create **k8s or openstack cloud region** +8. Onboard CNF `python onboard.py` +9. Instantiate CNF `python instantiate.py` +10. Once test is done, CNF service instance can be deleted with `python delete.py` command + diff --git a/tutorials/xNF_5G/free5gc/automation/__init__.py b/tutorials/xNF_5G/free5gc/automation/__init__.py new file mode 100644 index 00000000..9525040e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/__init__.py @@ -0,0 +1,19 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +from .config import Config +from .k8s_client import K8sClient diff --git a/tutorials/xNF_5G/free5gc/automation/artifacts/cluster_kubeconfig b/tutorials/xNF_5G/free5gc/automation/artifacts/cluster_kubeconfig new file mode 100644 index 00000000..e69de29b diff --git a/tutorials/xNF_5G/free5gc/automation/config.py b/tutorials/xNF_5G/free5gc/automation/config.py new file mode 100644 index 00000000..dc15582d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/config.py @@ -0,0 +1,113 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= +from typing import Dict, Union, List +import oyaml as yaml +import os +from jinja2 import Template + + +class VariablesDict: + env_variable = { + "CI_PIPELINE_ID": os.getenv("CI_PIPELINE_ID", "2000000"), + "USER": os.getenv("USER", "default"), + "NAME_SUFFIX": os.getenv("TEST", os.getenv("CI_PIPELINE_ID")) + } + + +class Config: + def __init__(self, filename: str = "service_config.yaml", env_dict=None): + if env_dict is None: + env_dict = {} + self.filepath = os.path.join(os.path.dirname(os.path.dirname( + os.path.realpath(__file__))), filename) + # self.filepath = os.path.join(os.path.dirname( + # os.path.realpath(__file__)), '..', filename) + self.content_env: Dict = {**self._load_file(), **env_dict} + self.service_instance: Union[None, Dict] = None + self.service_model: Union[None, Dict] = None + self.user_params: Union[None, Dict] = None + self.cloud_regions: Union[None, List] = None + self.so_input: Union[None, Dict] = None + self.render() + self.so_input = self.create_so_input() + + def _load_file(self) -> dict: + with open(self.filepath) as file: + file_content = yaml.safe_load(file) + return file_content + + @staticmethod + def templating(rend_dict: dict, render_keys: dict): + for k, v in rend_dict.items(): + if isinstance(v, str): + t = Template(v) + rend_dict[k] = t.render(**render_keys) + elif isinstance(v, dict): + Config.templating(rend_dict=v, render_keys=render_keys) + elif isinstance(v, list): + for i in v: + Config.templating(rend_dict=i, render_keys=render_keys) + else: + pass + return rend_dict + + def render(self): + raw_file = self._load_file() + config_dict = self.templating( + rend_dict=raw_file, + render_keys=self.content_env) + + self.__dict__.update(**config_dict) + + def create_so_input(self) -> dict: + so_input_dict = dict() + so_input_dict["subscription_service_type"] = self.service_instance.get("model_name") + _vnfs = self.service_instance.get("vnfs") + vnfs = list() + + for vnf in _vnfs: + _vnf_raw = dict() + _vnf_raw["model_name"] = vnf.get("model_name") + if vnf.get("vnf_name_suffix"): + _vnf_raw["vnf_name"] = "Instance_" + vnf.get("model_name") + "_" + vnf.get("vnf_name_suffix") + else: + _vnf_raw["vnf_name"] = "Instance_" + vnf.get("model_name") + "_" + str(_vnfs.index(vnf)) + if vnf.get("processing_priority"): + _vnf_raw["processing_priority"] = vnf.get("processing_priority") + _vnf_raw["parameters"] = vnf.get("parameters") + _vnf_raw["vf_modules"] = list() + _vf_modules = vnf.get("vf_modules") + for vf_module in _vf_modules: + _vf_module_raw = dict() + _vf_module_raw["model_name"] = vf_module.get("model_name") + if vf_module.get("vf_module_name_suffix"): + _vf_module_raw["vf_module_name"] = \ + "Instance_" + vf_module.get("model_name") + "_" + vf_module.get("vf_module_name_suffix") + else: + _vf_module_raw["vf_module_name"] = \ + "Instance_" + vf_module.get("model_name") + "_" + str(_vf_modules.index(vf_module)) + if _vf_module_raw.get("processing_priority"): + _vf_module_raw["processing_priority"] = vf_module["processing_priority"] + _vf_module_raw["parameters"] = vf_module.get("parameters") + _vnf_raw["vf_modules"].append(_vf_module_raw) + vnfs.append(_vnf_raw) + so_input_dict["vnfs"] = vnfs + + return so_input_dict + + +config = Config(env_dict=VariablesDict.env_variable) diff --git a/tutorials/xNF_5G/free5gc/automation/create_cloud_regions.py b/tutorials/xNF_5G/free5gc/automation/create_cloud_regions.py new file mode 100644 index 00000000..461ce863 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/create_cloud_regions.py @@ -0,0 +1,202 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import os +from uuid import uuid4 + +from onapsdk.so.so_db_adapter import SoDbAdapter, IdentityService + +from config import Config +from onapsdk.exceptions import ResourceNotFound, APIError +from onapsdk.aai.cloud_infrastructure import Complex, CloudRegion +from onapsdk.msb.k8s import ConnectivityInfo + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def create_complex(complex_id): + logger.info("******** Complex *******") + try: + region_complex = next(Complex.get_all(physical_location_id=complex_id)) + logger.info("Complex exists") + return region_complex + except ResourceNotFound: + logger.info("Complex does not exist") + region_complex = Complex.create(physical_location_id=complex_id, + name=complex_id, + physical_location_type="office", + street1="DummyStreet 1", + city="DummyCity", + postal_code="00-000", + country="DummyCountry", + region="DummyRegion") + logger.info("Complex created") + return region_complex + + +def create_cloud_region(cloud_region): + logger.info("******** Cloud Region *******") + region_id = cloud_region["name"] + cloud_owner = cloud_region["cloud_owner"] + cloud_type = cloud_region["cloud_type"] + complex_id = cloud_region["complex_id"] + cloud_region_version = "1.0" if cloud_type == "k8s" else "v2.5" + try: + region = next(CloudRegion.get_all(cloud_owner=cloud_owner, cloud_region_id=region_id)) + logger.info("Cloud region exists") + return region + except ResourceNotFound: + logger.info("Cloud region does not exist") + region = CloudRegion.create(cloud_owner=cloud_owner, + cloud_region_id=region_id, + cloud_type=cloud_type, + owner_defined_type="t1", + cloud_region_version=cloud_region_version, + complex_name=complex_id, + cloud_zone="CloudZone", + sriov_automation="false", + orchestration_disabled=False, + in_maint=False) + logger.info("Cloud region created") + return region + + +def link_region_to_complex(cloud_region, complx): + logger.info("******** Cloud region <-> Complex *******") + cloud_region.link_to_complex(complex_object=complx) + + +def add_tenant(cloud_region, tenant_id, tenant_name): + logger.info("Tenant does not exist") + cloud_region.add_tenant(tenant_id=tenant_id, + tenant_name=tenant_name) + logger.info(f"Tenant {tenant_name} added to region") + + +def add_tenants(cloud_region, k8s_region, tenants): + logger.info("******** Tenants *******") + for tenant in tenants: + tenant_name = tenant["name"] + if k8s_region: + try: + next(_tenant for _tenant in cloud_region.tenants if _tenant.name == tenant_name) + logger.info("Tenant exists") + except (StopIteration, ResourceNotFound): + tenant_id = str(uuid4()) + add_tenant(cloud_region=cloud_region, tenant_id=tenant_id, tenant_name=tenant_name) + else: + tenant_id = tenant["id"] + try: + cloud_region.get_tenant(tenant_id) + logger.info("Tenant exists") + except ResourceNotFound: + add_tenant(cloud_region=cloud_region, tenant_id=tenant_id, tenant_name=tenant_name) + + +def update_connectivity_info(region): + logger.info("******** Connectivity Info *******") + kubeconfig_path = region["kubeconfig_file"] + cloud_owner = region["cloud_owner"] + region_id = region["name"] + try: + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), kubeconfig_path), 'rb') as kubeconfig_file: + kubeconfig = kubeconfig_file.read() + + connectivity_info = ConnectivityInfo.get_connectivity_info_by_region_id(cloud_region_id=region_id) + logger.info("Connectivity Info exists ") + logger.info("Delete Connectivity Info ") + connectivity_info.delete() + ConnectivityInfo.create(cloud_region_id=region_id, + cloud_owner=cloud_owner, + kubeconfig=kubeconfig) + logger.info("Connectivity Info created ") + except (APIError, ResourceNotFound): + logger.info("Connectivity Info does not exists ") + ConnectivityInfo.create(cloud_region_id=region_id, + cloud_owner=cloud_owner, + kubeconfig=kubeconfig) + logger.info("Connectivity Info created ") + except FileNotFoundError: + logger.error("Error - File Not Found") + logger.info("Please check if kubeconfig file exists") + exit(1) + + +def add_region_to_so_db(region): + logger.info("******** SO Database *******") + if is_k8s_region(region): + identity_service = IdentityService(identity_id="Keystone_K8s", + url="http://test:5000/v3", + mso_id="onapsdk_user", + mso_pass="mso_pass_onapsdk", + project_domain_name="NULL", + user_domain_name="NULL", + identity_server_type="KEYSTONE") + + SoDbAdapter.add_cloud_site(cloud_region_id=region["name"], + complex_id=region["complex_id"], + identity_service=identity_service, + orchestrator="multicloud") + else: + identity_url = region["identity_url"] + mso_id = region["mso_id"] + mso_pass = region["mso_pass"] + identity_server_type = region["identity_server_type"] + identity_service = IdentityService(identity_id=region["name"] + "_KEYSTONE", + url=identity_url, + mso_id=mso_id, + mso_pass=mso_pass, + project_domain_name="Default", + user_domain_name="Default", + identity_server_type=identity_server_type) + + SoDbAdapter.add_cloud_site(cloud_region_id=region["name"], + complex_id=region["complex_id"], + identity_service=identity_service, + orchestrator="NULL") + + +def is_k8s_region(region): + is_k8s = False + if region["cloud_type"] == "k8s": + is_k8s = True + return is_k8s + + +######################################################################################################################## +def main(): + config = Config() + + for region in config.cloud_regions: + complx = create_complex(region["complex_id"]) + cloud_region = create_cloud_region(region) + link_region_to_complex(cloud_region, complx) + add_tenants(cloud_region, is_k8s_region(region), region.get("tenants")) + if is_k8s_region(region): + update_connectivity_info(region) + add_region_to_so_db(region) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/delete.py b/tutorials/xNF_5G/free5gc/automation/delete.py new file mode 100644 index 00000000..817ba786 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/delete.py @@ -0,0 +1,96 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +from config import Config + +from instantiate import get_customer, check_orchestration_status + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def get_service_subscription(customer, service_type): + try: + service_subscription = next( + service_sub for service_sub in customer.service_subscriptions if service_sub.service_type == service_type) + return service_subscription + except StopIteration: + logger.error("Service Subscription not found") + exit(1) + + +def get_service_instance(service_subscription, service_instance_name): + try: + service_instance = next(instance for instance in service_subscription.service_instances + if instance.instance_name == service_instance_name) + return service_instance + except StopIteration: + logger.error("Service Instance not found") + exit(1) + + +def delete_service_macro(service_instance): + service_deletion = service_instance.delete(a_la_carte=False) + check_orchestration_status(service_deletion) + + +def delete_service_alacarte(service_instance): + for vnf in service_instance.vnf_instances: + for vf_module in vnf.vf_modules: + vf_module_deletion = vf_module.delete() + check_orchestration_status(vf_module_deletion) + vnf_deletion = vnf.delete() + check_orchestration_status(vnf_deletion) + service_deletion = service_instance.delete(a_la_carte=True) + check_orchestration_status(service_deletion) + + +def main(): + logger.info("*******************************") + logger.info("**** SERVICE DELETION ****") + logger.info("*******************************") + + config = Config() + logger.info("******** GET Customer *******") + customer = get_customer(config.service_instance["customer_id"]) + + logger.info("******** Check Service Subscription *******") + service_subscription = get_service_subscription(customer, config.service_instance["model_name"]) + + logger.info("******** Get Service Instance details *******") + service_instance = get_service_instance(service_subscription, config.service_instance["instance_name"]) + + logger.info("******** Delete Service %s *******", service_instance.instance_name) + if config.service_model["macro_orchestration"]: + delete_service_macro(service_instance) + else: + logger.error("A_la_carte orchestration method not updated") + if config.service_model["pnfs"] is not None: + raise NotImplementedError + else: + delete_service_alacarte(service_instance) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/healthcheck.py b/tutorials/xNF_5G/free5gc/automation/healthcheck.py new file mode 100644 index 00000000..5e95815a --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/healthcheck.py @@ -0,0 +1,91 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Samsung +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import zipfile + +from onapsdk.aai.business import Customer +from onapsdk.cds.blueprint import Workflow, Blueprint + +from config import Config + +#FIXME remove from global scope +logger = logging.getLogger("") +logger.setLevel(logging.INFO) +fh = logging.StreamHandler() +fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') +fh.setFormatter(fh_formatter) +logger.addHandler(fh) + +def resolve_hc_inputs(): + logger.info("******** Check Customer *******") + customer = None + for found_customer in list(Customer.get_all()): + logger.debug("Customer %s found", found_customer.subscriber_name) + if found_customer.subscriber_name == Config.GLOBAL_CUSTOMER_ID: + logger.info("Customer %s found", found_customer.subscriber_name) + customer = found_customer + break + if customer is None: + raise Exception("Customer %s wasn't found in ONAP" % Config.GLOBAL_CUSTOMER_ID) + logger.info("******** Check Service Subscription *******") + service_subscription = None + for service_sub in customer.service_subscriptions: + logger.debug("Service subscription %s is found", service_sub.service_type) + if service_sub.service_type == Config.SERVICENAME: + logger.info("Service %s subscribed", Config.SERVICENAME) + service_subscription = service_sub + break + logger.info("******** Retrieve Service Metadata *******") + service_instance = None + for single_service in service_subscription.service_instances: + if single_service.instance_name == Config.SERVICE_INSTANCE_NAME: + service_instance = single_service + break + service_id = service_instance.instance_id + vnfs = list(service_instance.vnf_instances) + if len(vnfs) > 1: + raise NotImplementedError("Service %s is composed of more than one vnf!" % service_id) + if not vnfs: + raise Exception("Service %s doesn't contain any vnfs" % service_id) + vnf_id = vnfs[0].vnf_id + return service_id, vnf_id + +def main(): + blueprint = None + with zipfile.ZipFile(Config.VSPFILE, 'r') as package: + with package.open("CBA.zip", 'r') as cba: + blueprint = Blueprint(cba.read()) + + healthcheck = Workflow('health-check', None, blueprint) + serv_id, vnf_id = resolve_hc_inputs() + cds_input = {"health-check-properties": + { + "service-instance-id": serv_id, + "vnf-id": vnf_id + } + } + logger.info("Requesting Healthcheck for CBA %s:%s with inputs:\n%s", + blueprint.metadata.template_name, + blueprint.metadata.template_version, + cds_input) + result = healthcheck.execute(cds_input) + logger.info("Healthcheck process completed with result: %s", result) + logger.info("Please check cds-blueprints-processor logs to see exact status") + +if __name__ == "__main__": + main() diff --git a/tutorials/xNF_5G/free5gc/automation/instantiate.py b/tutorials/xNF_5G/free5gc/automation/instantiate.py new file mode 100644 index 00000000..aac82155 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/instantiate.py @@ -0,0 +1,418 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +from time import sleep + +from config import Config +from onapsdk.aai.cloud_infrastructure import ( + CloudRegion +) +from onapsdk.aai.business import ( + Customer, + OwningEntity as AaiOwningEntity +) +from onapsdk.exceptions import ResourceNotFound, APIError +from onapsdk.msb.k8s import Definition + +from onapsdk.so.instantiation import ( + ServiceInstantiation, + InstantiationParameter) +from onapsdk.sdc.service import Service +from onapsdk.so.so_element import OrchestrationRequest +from onapsdk.aai.service_design_and_creation import Service as AaiService + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def get_customer(global_customer_id: str = "customer_cnf"): + logger.info("******** Customer *******") + try: + customer = Customer.get_by_global_customer_id(global_customer_id) + logger.info("Customer exists") + except ResourceNotFound: + logger.info("Customer does not exist") + customer = Customer.create(global_customer_id, global_customer_id, "INFRA") + logger.info("Customer created") + return customer + + +def get_service_model(model_name): + try: + service_model = next(model for model in Service.get_all() if model.name == model_name) + logger.info( + f"Found Service {service_model.name} in SDC, distribution status: {service_model.distribution_status}") + return service_model + except StopIteration: + logger.error(f"Service model {model_name} not found in SDC") + exit(1) + + +def check_service_customer_subscription(customer, service): + try: + next(subscription for subscription in customer.service_subscriptions + if subscription.service_type == service.name) + except StopIteration: + return False + + logger.info(f"Customer {customer.subscriber_name} subscribed for {service.name}") + return True + + +def subscribe_service_customer(customer, service): + if not check_service_customer_subscription(customer, service): + logger.info("******** Subscribe Service *******") + customer.subscribe_service(service) + + +def get_cloud_region(cloud_owner, cloud_region): + return CloudRegion(cloud_owner=cloud_owner, cloud_region_id=cloud_region, + orchestration_disabled=True, in_maint=False) + + +def get_tenant(cloud_region, tenant_name): + try: + tenant = next(tenant for tenant in cloud_region.tenants if tenant.name == tenant_name) + return tenant + except StopIteration: + logger.error(f"Tenant {tenant_name} not found") + exit(1) + + +def add_owning_entity(owning_entity): + logger.info("******** Add Owning Entity to AAI *******") + try: + aai_owning_entity = AaiOwningEntity.get_by_owning_entity_name(owning_entity) + except ResourceNotFound: + logger.info("******** Owning Entity not existing: create *******") + aai_owning_entity = AaiOwningEntity.create(owning_entity) + + return aai_owning_entity + + +def delete_old_profiles(service, service_config): + for vnf in service.vnfs: + vnf_config_details = next(_vnf for _vnf in service_config["vnfs"] if _vnf["model_name"] == vnf.metadata["name"]) + for vf_module in vnf.vf_modules: + vf_module_label = vf_module.properties["vf_module_label"] + if vf_module_label == "base_template_dummy_ignore": + continue + vf_module_config_details = next(_vf_module for _vf_module in vnf_config_details["vf_modules"] if + _vf_module["model_name"] == vf_module_label) + if "k8s-rb-profile-name" not in vf_module_config_details["parameters"]: + continue + try: + definition = Definition.get_definition_by_name_version( + rb_name=vf_module.metadata["vfModuleModelInvariantUUID"], + rb_version=vf_module.metadata["vfModuleModelCustomizationUUID"]) + except APIError: + definition = Definition.get_definition_by_name_version( + rb_name=vf_module.metadata["vfModuleModelInvariantUUID"], + rb_version=vf_module.metadata["vfModuleModelUUID"]) + profile_name = vf_module_config_details["parameters"]["k8s-rb-profile-name"] + try: + profile = definition.get_profile_by_name(profile_name) + namespace = None + if "k8s-rb-profile-namespace" in vnf_config_details["parameters"]: + namespace = vnf_config_details["parameters"]["k8s-rb-profile-namespace"] + if "k8s-rb-profile-namespace" in vf_module_config_details["parameters"]: + namespace = vf_module_config_details["parameters"]["k8s-rb-profile-namespace"] + if namespace is not None and profile.namespace != namespace: + profile.delete() + logger.info("Profile: " + profile_name + " for " + vf_module.name + " deleted") + else: + logger.info("No need to delete Profile " + profile_name + + " for " + vf_module.name + ". Namespace is fine") + except ResourceNotFound: + logger.info("Profile: " + profile_name + " for " + vf_module.name + " not found") + + +def check_service_instance_exists(service_subscription, service_instance_name): + try: + service_instance = next((instance for instance in service_subscription.service_instances + if instance.instance_name == service_instance_name), None) + return service_instance + except ResourceNotFound: + return None + + +def get_instantiation_parameters(properties, vnf_vf_module_config): + instantiation_parameters = [] + for property_name, property_value in properties: + instantiation_parameters.append(InstantiationParameter(name=property_name, value=property_value)) + + for instantiation_parameter_key, instantiation_parameter_value in vnf_vf_module_config["parameters"]: + instantiation_parameters.append(InstantiationParameter(name=instantiation_parameter_key, + value=instantiation_parameter_value)) + + return instantiation_parameters + + +def check_orchestration_status(instantiation): + status = None + while not (status == OrchestrationRequest.StatusEnum.COMPLETED + or status == OrchestrationRequest.StatusEnum.FAILED): + sleep(10) + status = instantiation.status + logger.info(f"Orchestration status is: {status.value}") + + if status == OrchestrationRequest.StatusEnum.FAILED: + logger.error("Orchestration was failed!") + exit(1) + else: + logger.info("Orchestration was succeed") + return + + +def get_aai_service(service_type): + logging.info("******** Retrieve product family for service *******") + try: + aai_service = next(service for service in AaiService.get_all() if service.service_id == service_type) + except (ResourceNotFound, StopIteration): + logging.info("******** Service design and creation in AAI not existing: create *******") + AaiService.create(service_id=service_type, service_description=service_type) + aai_service = next(service for service in AaiService.get_all() if service.service_id == service_type) + + return aai_service + + +def instantiate_service_macro(config, service, cloud_region, tenant, customer, owning_entity, + vid_project, vid_line_of_business, vid_platform): + service_instance_name = config.service_instance["instance_name"] + so_input = config.so_input + for vnf in so_input["vnfs"]: + _vnf = next(nf for nf in service.vnfs if nf.metadata["name"] == vnf["model_name"]) + sdnc_model_name = _vnf.properties["sdnc_model_name"] + sdnc_model_version = _vnf.properties["sdnc_model_version"] + sdnc_artifact_name = _vnf.properties["sdnc_artifact_name"] + vnf["parameters"]["sdnc_model_name"] = sdnc_model_name + vnf["parameters"]["sdnc_model_version"] = sdnc_model_version + vnf["parameters"]["sdnc_artifact_name"] = sdnc_artifact_name + for vf_module in vnf["vf_modules"]: + vf_module_label = vf_module["model_name"] + vf_module["parameters"]["sdnc_model_name"] = sdnc_model_name + vf_module["parameters"]["sdnc_model_version"] = sdnc_model_version + vf_module["parameters"]["vf_module_label"] = vf_module_label + + # TODO: PNF support in so_input -> first ONAPSDK + + aai_service = get_aai_service(service.name) + service_instantiation = ServiceInstantiation.instantiate_macro( + sdc_service=service, + cloud_region=cloud_region, + tenant=tenant, + customer=customer, + owning_entity=owning_entity, + project=vid_project, + line_of_business=vid_line_of_business, + platform=vid_platform, + service_instance_name=service_instance_name, + aai_service=aai_service, + so_service=so_input + ) + check_orchestration_status(service_instantiation) + + +def get_base_vf_module(vf_modules): + base_vf_module = next(vf_module for vf_module in vf_modules if vf_module.properties["isBase"]) + return base_vf_module + + +def is_base(vf_module): + if vf_module.properties["isBase"]: + return True + return False + + +def instantiate_vf_module(vf_module, vf_module_param_list, vnf_instance, sdnc_model_name, sdnc_model_version): + vf_module_label = vf_module.properties["vf_module_label"] + region_id = vf_module_param_list[vf_module_label]["cloud_configuration"] + cloud_region = get_cloud_region( + Config.CLOUD_REGIONS[region_id]["cloud_owner"], + region_id) + tenant = get_tenant(cloud_region, Config.CLOUD_REGIONS[region_id]["tenant"]["name"]) + + vfmodule_instantiation_parameters = vf_module_param_list[vf_module_label]["instantiation_parameters"].items() + + base_parameters = [ + InstantiationParameter(name="sdnc_model_name", value=sdnc_model_name), + InstantiationParameter(name="sdnc_model_version", value=sdnc_model_version), + InstantiationParameter(name="vf_module_label", value=vf_module_label)] + + for instantiation_parameter_key, instantiation_parameter_value in vfmodule_instantiation_parameters: + base_parameters.append(InstantiationParameter(name=instantiation_parameter_key, + value=instantiation_parameter_value)) + + vf_module_instantiation = vnf_instance.add_vf_module( + vf_module=vf_module, + cloud_region=cloud_region, + tenant=tenant, + vnf_parameters=base_parameters, + use_preload=False + ) + check_orchestration_status(vf_module_instantiation) + + +def check_vf_module_list_correct(vf_modules, vf_modules_config_list): + model_labels = set() + config_labels = set() + for vf_module in vf_modules: + model_labels.add(vf_module.properties["vf_module_label"]) + for vf_module in vf_modules_config_list: + config_labels.add(vf_module["model_name"]) + if model_labels == config_labels: + return True + else: + return False + + +def get_properties(vnf): + properties = dict() + + properties["sdnc_model_name"] = vnf["properties"]["sdnc_model_name"] + properties["sdnc_model_version"] = vnf["properties"]["sdnc_model_version"] + properties["sdnc_artifact_name"] = vnf["properties"]["sdnc_artifact_name"] + + return properties + + +def instantiate_service_alacarte(config, service_subscription, service_model, cloud_region, tenant, customer, + owning_entity, + vid_project, vid_line_of_business, vid_platform): + service_instance_name = config.service_instance["instance_name"] + # Service creation + service_instantiation = ServiceInstantiation.instantiate_ala_carte( + sdc_service=service_model, + cloud_region=cloud_region, + tenant=tenant, + customer=customer, + owning_entity=owning_entity, + project=vid_project, + service_instance_name=service_instance_name + ) + check_orchestration_status(service_instantiation) + # End of service creation + + service_instance = service_subscription.get_service_instance_by_name(service_instance_name) + # Add VNFs + for vnf in service_model.vnfs: + # TODO: priority + properties = get_properties(vnf) + vnf_config = next(_vnf for _vnf in config.service_instance["vnfs"] + if config.service_instance["vnfs"]["model_name"] == vnf.name) + vnf_parameters = get_instantiation_parameters(properties, vnf_config) + # TODO: instance name + vnf_instantiation = service_instance.add_vnf( + vnf=vnf, + line_of_business=vid_line_of_business, + platform=vid_platform, + vnf_parameters=vnf_parameters + ) + check_orchestration_status(vnf_instantiation) + + # Add vf_modules + vnf_type = service_model.name + "/" + vnf.name + vnf_instance = next((vnf for vnf in service_instance.vnf_instances if vnf.vnf_type == vnf_type), None) + + if check_vf_module_list_correct(vnf.vf_modules, vnf_config["vf_modules"]): + for vf_module in vnf.vf_modules: + vf_module_config = next(_vf for _vf in vnf_config["vf_modules"] + if _vf["model_name"] == vf_module.properties["vf_module_label"]) + vf_module_parameters = get_instantiation_parameters(properties, vf_module_config) + vf_module_instantiation = vnf_instance.add_vf_module( + vf_module=vf_module, + cloud_region=cloud_region, + tenant=tenant, + vnf_parameters=vf_module_parameters, + use_preload=False + ) + check_orchestration_status(vf_module_instantiation) + else: + logger.error("VF_MODULE_PARAM_LIST error. ") + # End of vf_modules + # End of VNFs + + +def main(): + logger.info("*******************************") + logger.info("**** SERVICE INSTANTIATION ****") + logger.info("*******************************") + + config = Config() + + logger.info("******** GET Customer *******") + customer = get_customer(config.service_instance["customer_id"]) + + logger.info("******** GET Service Model from SDC *******") + service = get_service_model(config.service_instance["model_name"]) + + logger.info("******** Subscribe Customer for Service *******") + subscribe_service_customer(customer, service) + + logger.info("******** Get Tenant *******") + region_details = next( + region for region in config.cloud_regions if region["name"] == config.service_instance["cloud_region"]) + cloud_region = get_cloud_region(region_details["cloud_owner"], region_details["name"]) + tenant = get_tenant(cloud_region, + config.service_instance["tenant_name"]) + + ###### + logger.info("******** Connect Service to Tenant *******") + service_subscription = None + for service_sub in customer.service_subscriptions: + if service_sub.service_type == config.service_instance["model_name"]: + logger.info("Service %s subscribed", config.service_instance["model_name"]) + service_subscription = service_sub + break + if not service_subscription: + logger.error("Service subscription %s is not found", config.service_instance["model_name"]) + exit(1) + + service_subscription.link_to_cloud_region_and_tenant(cloud_region, tenant) + #### + + logger.info("******** Business Objects (OE, P, Pl, LoB) *******") + project = "Project-Demonstration" + platform = "Platform-test" + line_of_business = "Orange-LOB" + owning_entity = add_owning_entity("Orange") + + logger.info("******** Delete old profiles ********") + delete_old_profiles(service, config.service_instance) + + logger.info("******** Instantiate Service *******") + service_instance = check_service_instance_exists(service_subscription, config.service_instance["instance_name"]) + if service_instance: + logger.info("******** Service Instance exists, do not instantiate *******") + else: + logger.info("******** Service Instance not existing: Instantiate *******") + if config.service_model["macro_orchestration"]: + instantiate_service_macro(config, service, cloud_region, tenant, customer, owning_entity, + project, line_of_business, platform) + else: + instantiate_service_alacarte(config, service_subscription, service, cloud_region, tenant, customer, + owning_entity, project, line_of_business, platform) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/k8s_client.py b/tutorials/xNF_5G/free5gc/automation/k8s_client.py new file mode 100644 index 00000000..98b451bc --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/k8s_client.py @@ -0,0 +1,59 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import os +from pprint import pprint + +import oyaml as yaml +from kubernetes import config, client +from kubernetes.client import OpenApiException + + +class K8sClient: + def __init__(self, kubeconfig_path): + self.mypath = os.path.dirname(os.path.realpath(__file__)) + config.load_kube_config(config_file=os.path.join(self.mypath, kubeconfig_path)) + self.api_instance = client.CustomObjectsApi() + + def read_custom_object_file(self, file_path): + with open(file_path) as crd_file: + crd_body = yaml.load(crd_file, Loader=yaml.FullLoader) + return crd_body + + def get_custom_object_details(self, crd_body): + group = crd_body["apiVersion"].split("/")[0] + version = crd_body["apiVersion"].split("/")[1] + plural = crd_body["kind"].lower() + "s" + #name = crd_body["metadata"]["name"] + + return group, version, plural #, name + + def create_custom_object(self, file_path): + crd_body = self.read_custom_object_file(file_path) + #group, version, plural, name = self.get_custom_object_details(crd_body) + group, version, plural = self.get_custom_object_details(crd_body) + api_response = None + try: + api_response = self.api_instance.create_cluster_custom_object(group=group, + version=version, + plural=plural, + body=crd_body, + pretty="true") + except OpenApiException as error: + print(str(error.status) + " " + error.reason) + pprint(error.body) + return api_response diff --git a/tutorials/xNF_5G/free5gc/automation/onap_settings.py b/tutorials/xNF_5G/free5gc/automation/onap_settings.py new file mode 100644 index 00000000..55a246f4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/onap_settings.py @@ -0,0 +1,47 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +"""Global settings module.""" # pylint: disable=bad-whitespace +# uncomment if socks is used +#from onapsdk.onap_service import OnapService + +###################### +# # +# ONAP SERVICES URLS # +# # +###################### + +AAI_URL = "https://aai.api.sparky.simpledemo.onap.org:30233" +AAI_API_VERSION = "v20" +CDS_URL = "http://portal.api.simpledemo.onap.org:30449" +MSB_URL = "https://msb.api.simpledemo.onap.org:30283" +SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204" +SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207" +SDNC_URL = "https://sdnc.api.simpledemo.onap.org:30267" +SO_URL = "http://so.api.simpledemo.onap.org:30277" +SO_API_VERSION = "v7" +VID_URL = "https://vid.api.simpledemo.onap.org:30200" +VID_API_VERSION = "/vid" +CLAMP_URL = "https://clamp.api.simpledemo.onap.org:30258" +VES_URL = "https://ves.api.simpledemo.onap.org:30417" +DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904" + +# uncomment if socks is used +#OnapService.set_proxy({'http': 'socks5h://127.0.0.1:8081', 'https': 'socks5h://127.0.0.1:8081'}) + +# execute in the shell to apply these settings +# export ONAP_PYTHON_SDK_SETTINGS="onap_settings" diff --git a/tutorials/xNF_5G/free5gc/automation/onboard.py b/tutorials/xNF_5G/free5gc/automation/onboard.py new file mode 100644 index 00000000..488c54e6 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/onboard.py @@ -0,0 +1,200 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +import time +import zipfile +from io import BytesIO + +import yaml + +from config import Config +import onapsdk.constants as const + +from onapsdk.sdc.vendor import Vendor +from onapsdk.sdc.vsp import Vsp +from onapsdk.sdc.vf import Vf +from onapsdk.sdc.pnf import Pnf +from onapsdk.sdc.service import Service, ServiceInstantiationType + +import os + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def retrieve_service(service_name: str): + logger.info("Retrieve service from SDC before onboarding") + services = Service.get_all() + + for found_service in services: + if found_service.name == service_name: + logging.info(f"Service {found_service.name} found in SDC, onboarding will not be executed") + exit(0) + return + + +def onboard_vendor(vendor_name: str = "demo_vendor"): + logger.info("******** Onboard Vendor *******") + vendor = Vendor(vendor_name) + vendor.onboard() + return vendor + + +def onboard_vsp(vsp_name, vsp_file, vendor): + logger.info(f"******** Onboard VSP - {vsp_name} *******") + mypath = os.path.dirname(os.path.realpath(__file__)) + vsp_path = os.path.join(mypath, vsp_file) + vsp = None + try: + vsp = Vsp(name=vsp_name, vendor=vendor, package=open(vsp_path, 'rb')) + except FileNotFoundError: + logger.error(f"No vsp file was found for {vsp_name}!") + exit(1) + vsp.onboard() + return vsp + + +def onboard_pnf(pnf_name, vsp_name, vsp_file, vendor_name): + logger.info(f"******** Onboard PNF - {pnf_name} *******") + vendor = onboard_vendor(vendor_name=vendor_name) + pnf_vsp = onboard_vsp(vsp_name=vsp_name, vsp_file=vsp_file, vendor=vendor) + pnf = Pnf(name=pnf_name, vsp=pnf_vsp) + pnf.onboard() + return pnf + + +def onboard_vnf(vnf_name, vsp_name, vsp_file, vendor_name): + logger.info(f"******** Onboard VNF - {vnf_name} *******") + vendor = onboard_vendor(vendor_name=vendor_name) + vnf_vsp = onboard_vsp(vsp_name=vsp_name, vsp_file=vsp_file, vendor=vendor) + vnf = Vf(name=vnf_name, vsp=vnf_vsp) + vnf.create() + vnf.onboard() + return vnf + + +def create_service(service_name, is_macro: bool = True): + logger.info("******** Create Service *******") + if is_macro: + service = Service(name=service_name, + instantiation_type=ServiceInstantiationType.MACRO) + else: + service = Service(name=service_name, + instantiation_type=ServiceInstantiationType.A_LA_CARTE) + service.create() + return service + + +def read_sdnc_model_details(file): + mypath = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(mypath, file) + try: + with zipfile.ZipFile(file_path, 'r') as package: + try: + cba_io = BytesIO(package.read("CBA.zip")) + with zipfile.ZipFile(cba_io) as cba: + with cba.open('TOSCA-Metadata/TOSCA.meta') as meta_file: + tosca_meta = yaml.load(meta_file, Loader=yaml.FullLoader) + sdnc_model_name = tosca_meta.get("Template-Name") + sdnc_model_version = tosca_meta.get("Template-Version") + return sdnc_model_name, sdnc_model_version + except KeyError: + logger.info("No CBA file was found") + return None, None + except FileNotFoundError: + logger.error("No vsp file was found!") + exit(1) + + +def set_properties(service, xnf, vsp_details): + sdnc_model_name, sdnc_model_version = read_sdnc_model_details(vsp_details["vsp_file"]) + if sdnc_model_name and sdnc_model_version: + if service.status == const.DRAFT: + logger.info("******** Set SDNC properties for VF ********") + component = service.get_component(xnf) + prop = component.get_property("sdnc_model_name") + prop.value = sdnc_model_name + prop = component.get_property("sdnc_model_version") + prop.value = sdnc_model_version + prop = component.get_property("controller_actor") + prop.value = "CDS" + prop = component.get_property("sdnc_artifact_name") + prop.value = vsp_details["sdnc_artifact_name"] + prop = component.get_property("skip_post_instantiation_configuration") + prop.value = vsp_details["skip_post_instantiation_configuration"] + + +def check_distribution_status(service): + logger.info("******** Check Service Distribution *******") + distribution_completed = False + nb_try = 0 + nb_try_max = 10 + while distribution_completed is False and nb_try < nb_try_max: + distribution_completed = service.distributed + if distribution_completed is True: + logger.info(f"Service Distribution for {service.name} is successfully finished") + break + logger.info(f"Service Distribution for {service.name} ongoing, Wait for 60 s") + time.sleep(60) + nb_try += 1 + + if distribution_completed is False: + logger.error(f"Service Distribution for {service.name} failed !!", ) + exit(1) + + +def main(): + config = Config() + retrieve_service(service_name=config.service_model["model_name"]) + + logger.info("******** SERVICE DESIGN *******") + service = create_service(service_name=config.service_model["model_name"], + is_macro=config.service_model["macro_orchestration"]) + vnfs = config.service_model.get("vnfs") + if vnfs: + for vnf in vnfs: + new_vnf = onboard_vnf(vnf_name=vnf["model_name"], + vsp_name="VSP" + "_" + vnf["model_name"], + vsp_file=vnf["vsp"]["vsp_file"], + vendor_name=vnf["vsp"]["vendor"]) + service.add_resource(new_vnf) + set_properties(service=service, xnf=new_vnf, vsp_details=vnf["vsp"]) + + pnfs = config.service_model.get("pnfs") + if pnfs: + for pnf in pnfs: + new_pnf = onboard_pnf(pnf_name=pnf["model_name"], + vsp_name="VSP" + "_" + pnf["model_name"], + vsp_file=pnf["vsp"]["vsp_file"], + vendor_name=pnf["vsp"]["vendor"]) + service.add_resource(new_pnf) + set_properties(service=service, xnf=new_pnf, vsp_details=pnf["vsp"]) + + service.checkin() + service.onboard() + check_distribution_status(service) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/update_cba.py b/tutorials/xNF_5G/free5gc/automation/update_cba.py new file mode 100644 index 00000000..316c0d75 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/update_cba.py @@ -0,0 +1,57 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import os +import zipfile +from io import BytesIO + +from onapsdk.cds import Blueprint + +from config import Config + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def update_cba(file): + mypath = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(mypath, file) + try: + with zipfile.ZipFile(file_path, 'r') as package: + cba_io = BytesIO(package.read("CBA.zip")) + + blueprint = Blueprint(cba_io) + blueprint.deploy() + except FileNotFoundError: + logger.error("Error - File Not Found") + exit(1) + + +def main(): + config = Config() + for vnf in config.service_model["vnfs"]: + update_cba(vnf["vsp"]["vsp_file"]) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/update_connectivity_info.py b/tutorials/xNF_5G/free5gc/automation/update_connectivity_info.py new file mode 100644 index 00000000..4b279aba --- /dev/null +++ b/tutorials/xNF_5G/free5gc/automation/update_connectivity_info.py @@ -0,0 +1,40 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +from config import Config +from create_cloud_regions import update_connectivity_info, is_k8s_region + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def main(): + config = Config() + for region in config.cloud_regions: + if is_k8s_region(region): + update_connectivity_info(region) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/free5gc/automation/vsp/.gitkeep b/tutorials/xNF_5G/free5gc/automation/vsp/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tutorials/xNF_5G/free5gc/automation/vsp/pnf_package.csar b/tutorials/xNF_5G/free5gc/automation/vsp/pnf_package.csar new file mode 100644 index 00000000..43f6d9ee Binary files /dev/null and b/tutorials/xNF_5G/free5gc/automation/vsp/pnf_package.csar differ diff --git a/tutorials/xNF_5G/free5gc/service_config.yaml b/tutorials/xNF_5G/free5gc/service_config.yaml new file mode 100644 index 00000000..913e4033 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/service_config.yaml @@ -0,0 +1,59 @@ +user_params: + k8s_namespace: free5gc + profile_name: free5gc-cnf-cds-base-profile + profile_source: free5gc-cnf-cds-base-profile + release_name: rel-1 + name_suffix: _1 + +cloud_regions: + - name: orange_k8s_free5gc + cloud_owner: K8sCloudOwner + cloud_type: k8s + complex_id: complex1 + tenants: + - name: &tenant1 orange-free5gc-tenant + k8s_version: 1.21.1 + kubeconfig_file: artifacts/cluster_kubeconfig + +service_model: + macro_orchestration: True + model_name: &service_model_name free5GC_demo + vnfs: + - model_name: &vnf_1_model_name free5gc + vsp: + vsp_file: vsp/native_free5gc_k8s_demo.zip + vendor: orange + sdnc_artifact_name: vnf + skip_post_instantiation_configuration: False + pnfs: + - model_name: ueransim + vsp: + vsp_file: vsp/pnf_package.csar + vendor: orange + skip_post_instantiation_configuration: True + + +service_instance: + model_name: *service_model_name + instance_name: "{{ service_model.model_name }}_{{ user_params.name_suffix }}" + customer_id: orange + cloud_region: "{{ cloud_regions[0].name }}" + tenant_name: *tenant1 #"{{ cloud_regions[0].tenants[0].name }}" + service_type: free5gc + vnfs: + - model_name: *vnf_1_model_name + vnf_name_suffix: "001" #optional parameter + parameters: + k8s-rb-profile-namespace: "{{ user_params.k8s_namespace }}" + k8s-rb-profile-k8s-version: "{{ cloud_regions[0].tenants[0].k8s_version }}" + processing_priority: 1 + vf_modules: + - model_name: helm_free5gc + vf_module_name_suffix: "001" + processing_priority: 1 + parameters: + k8s-rb-profile-name: "{{ user_params.profile_name }}" + k8s-rb-profile-source: "{{ user_params.profile_source }}" + k8s-rb-instance-release-name: "{{ user_params.release_name }}-free5gc" + pnfs: + - model_name: ueransim diff --git a/tutorials/xNF_5G/free5gc/templates/.gitattributes b/tutorials/xNF_5G/free5gc/templates/.gitattributes new file mode 100644 index 00000000..4ad2a524 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/.gitattributes @@ -0,0 +1 @@ +/cba/Templates/k8s-profiles/*.tar.gz binary diff --git a/tutorials/xNF_5G/free5gc/templates/.gitignore b/tutorials/xNF_5G/free5gc/templates/.gitignore new file mode 100644 index 00000000..f88e099b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/.gitignore @@ -0,0 +1,2 @@ +package/ +vfw_k8s_demo.zip diff --git a/tutorials/xNF_5G/free5gc/templates/Makefile b/tutorials/xNF_5G/free5gc/templates/Makefile new file mode 100644 index 00000000..91255849 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/Makefile @@ -0,0 +1,45 @@ +.PHONY: all clean helm base clean_all package cba jsonlint_cba config +NATIVE_ONBOARDING_PACKAGE_NAME ?= native_free5gc_k8s_demo +CBA_NAME ?= CBA +_type_files = $(wildcard cba/Definitions/*_types.json) + + +clean_all: + $(MAKE) clean + $(MAKE) all + +#Can't use .csar extension or SDC will panic +all: package helm base cba + cd package_native/ && zip -r $(NATIVE_ONBOARDING_PACKAGE_NAME).zip . + mv package_native/$(NATIVE_ONBOARDING_PACKAGE_NAME).zip . + cp $(NATIVE_ONBOARDING_PACKAGE_NAME).zip ../automation/vsp/ + +helm: package + $(MAKE) -C helm + mv helm/helm_*.tgz package_native/ + +base: package + cp base_native/* package_native/ + +cba: package config + cd cba/ && zip -r $(CBA_NAME).zip . -x pom.xml .idea/\* target/\* + mv cba/$(CBA_NAME).zip package_native/ + +config: + $(MAKE) -C cba/Templates/k8s-configs/ue-reconfiguration + +package: + mkdir package_native/ + +clean: + rm -rf package_native/ + rm -f $(NATIVE_ONBOARDING_PACKAGE_NAME).zip + +jsonlint_cba: $(_type_files) + @: + +#This shouldn't be PHONY, but it's easier now to define this way +.PHONY: $(_type_files) +$(_type_files): + @which jq expand unexpand sponge >/dev/null + jq -S . <$@ | unexpand -t 2 | expand -t 4 | sponge $@ diff --git a/tutorials/xNF_5G/free5gc/templates/README.txt b/tutorials/xNF_5G/free5gc/templates/README.txt new file mode 100644 index 00000000..3d7c29cf --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/README.txt @@ -0,0 +1 @@ +cba-dd.json file is Data Dictionary file used to enrich cba model. diff --git a/tutorials/xNF_5G/free5gc/templates/base_native/MANIFEST.json b/tutorials/xNF_5G/free5gc/templates/base_native/MANIFEST.json new file mode 100644 index 00000000..88b8dca8 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/base_native/MANIFEST.json @@ -0,0 +1,15 @@ +{ + "name": "free5gc", + "description": "", + "data": [ + { + "file": "CBA.zip", + "type": "CONTROLLER_BLUEPRINT_ARCHIVE" + }, + { + "file": "helm_free5gc.tgz", + "type": "HELM", + "isBase": "true" + } + ] +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/bootstrap.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/bootstrap.sh new file mode 100644 index 00000000..74ec06a0 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/bootstrap.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/bootstrap' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data '{"loadModelType": true, "loadResourceDictionary": true, "loadCBA": false}' | jq diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/build.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/build.sh new file mode 100644 index 00000000..a7a34061 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/build.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +cd ../cba/ + +mvn clean install + +if [ $? -eq 1 ] +then + echo "----------------" + echo "CBA BUILD FAILED" + echo "----------------" + exit 1 +fi + +CBA_NAME=`ls target/*.zip` +cp $CBA_NAME ../cba-dev/cba.zip + +echo "-----------------" +echo "CBA BUILD SUCCESS" +echo "-----------------" + +cd ../cba-dev diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/deploy.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/deploy.sh new file mode 100644 index 00000000..8ddbe493 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/publish' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form 'file=@cba.zip' | jq diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/enrich.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/enrich.sh new file mode 100644 index 00000000..632cb89f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/enrich.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/enrich' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +-o 'cba.zip' \ +--form 'file=@../package_native/CBA.zip' | jq diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/run-ue-reconfiguration.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-ue-reconfiguration.sh new file mode 100644 index 00000000..447c2fb7 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-ue-reconfiguration.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +ACTION='ran-reconfiguration' + +curl --location --request POST 'http://portal.api.simpledemo.onap.org:30449/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "free5GC", + "blueprintVersion": "1.1.1", + "actionName": "'$ACTION'", + "mode": "sync" + }, + "payload": { + "'$ACTION-request'": { + "resolution-key": "VF_ueransim_CNF", + "'$ACTION-properties'": { + "service-instance-id": "26ac11f6-2371-4e5e-98fc-885363312dff", + "vnf-id": "73ce7403-d667-4804-ab80-eaf801792a47", + "vnf-name": "VF_ueransim_CNF_210803", + "vnf-customization-uuid": "822cbae8-d023-4047-95c3-4f834569e195" + } + } + } +}' | jq '.payload | .["'$ACTION-response'"]' + diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-base-ra.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-base-ra.sh new file mode 100644 index 00000000..3046cfd8 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-base-ra.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="helm_base_template" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "564e55dc-3b90-4c9c-9e97-42f2c97d8f11", + "vf-module-model-version": "3d55e2a6-7634-4ceb-98e9-2852d621a544", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vfw-cnf-cds-base-profile", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-pkg-ra.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-pkg-ra.sh new file mode 100644 index 00000000..a80238db --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vf-pkg-ra.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="helm_vpkg" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "95e56eee-eeef-4a18-a032-8dbd757544b5", + "vf-module-model-version": "de66174a-d401-4b31-9331-3a44ad3ba01b", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vfw-cnf-cds-base-profile", + "k8s-rb-profile-source": "vfw-cnf-cds-base-profile", + "k8s-rb-profile-namespace": "vfirewall", + "k8s-rb-profile-k8s-version": "1.18.9", + "k8s-rb-config-template-name": "ssh-service-config", + "k8s-rb-config-template-source": "ssh-service-config", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-config.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-config.sh new file mode 100644 index 00000000..d37e0e9d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-config.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +ACTION=$1 + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "free5GC", + "blueprintVersion": "1.1.1", + "actionName": "'config-$ACTION'", + "mode": "sync" + }, + "payload": { + "'config-$ACTION-request'": { + "resolution-key": "VF_ueransim_CNF", + "'config-$ACTION-properties'": { + "service-instance-id": "6178e706-fbfc-42c9-a807-79cd8e4a1898", + "vnf-id": "065ee10b-e56e-41bc-ae68-2c2ba8a25e8e", + "vnf-name": "VF_ueransim_CNF", + "vnf-customization-uuid": "5e4fb0a9-e4ff-4c95-859e-4615fee88d3e" + } + } + } +}' | jq '.payload | .["'config-$ACTION-response'"]' + diff --git a/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-ra.sh b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-ra.sh new file mode 100644 index 00000000..2d64bac7 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba-dev/run-vnf-ra.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "vnf" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "51274ece-55ca-4cbc-b7c4-0da0dcc65d38", + "vnf_name": "sample-vnf-name", + "k8s-rb-profile-namespace": "vfw-namespace", + "k8s-rb-profile-k8s-version": "1.18.9", + "int_private1_net_cidr" : "192.168.10.0/24", + "int_private2_net_cidr" : "192.168.20.0/24", + "onap_private_net_cidr" : "10.0.0.0/16", + "private1-prefix-id" : 2, + "private2-prefix-id" : 1 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .vnf | fromjson | .["resource-accumulator-resolved-data"] ' + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/artifact_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/artifact_types.json new file mode 100644 index 00000000..4211156e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/artifact_types.json @@ -0,0 +1,30 @@ +{ + "artifact_types": { + "artifact-mapping-resource": { + "description": "Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Implementation", + "file_ext": [ + "json" + ] + }, + "artifact-template-velocity": { + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Implementation", + "file_ext": [ + "vtl" + ] + }, + "artifact-k8sprofile-content": { + "description": "K8s Profile Folder Artifact", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-k8sconfig-content": { + "description": "K8s Config Folder Artifact", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Implementation" + } + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/data_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/data_types.json new file mode 100644 index 00000000..bf863f12 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/data_types.json @@ -0,0 +1,273 @@ +{ + "data_types": { + "dt-config-assign-properties": { + "description": "Dynamic DataType definition for workflow(config-assign).", + "version": "1.0.0", + "properties": { + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "vf-modules-list": { + "type": "json" + }, + "config-deploy-setup": { + "type": "json" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-config-deploy-properties": { + "description": "Dynamic DataType definition for workflow(config-deploy).", + "version": "1.0.0", + "properties": { + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "vf-modules-list": { + "type": "json" + }, + "config-deploy-setup": { + "type": "json" + }, + "registration-reconfiguration-parameters": { + "type": "json" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-resource-assignment-properties": { + "description": "Dynamic DataType definition for workflow(resource-assignment).", + "version": "1.0.0", + "properties": { + "replica-count": { + "description": "Number of NRF replicas after scaling operation", + "type": "integer", + "default": 0 + }, + "k8s-rb-profile-namespace": { + "description": "K8s namespace to create helm chart for specified profile", + "type": "string" + }, + "k8s-rb-profile-name": { + "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string" + }, + "k8s-rb-instance-release-name": { + "description": "Name of the release for the helm package instance in k8s", + "type": "string" + }, + "k8s-rb-profile-source": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string" + }, + "k8s-rb-profile-k8s-version": { + "description": "Profile k8s version used in multicloud/k8s plugin", + "type": "string" + }, + "k8s-rb-config-template-name": { + "description": "The name of configuration template for config-assign operation", + "type": "string" + }, + "k8s-rb-config-template-source": { + "description": "The source of configuration template for config-assign operation", + "type": "string" + }, + "k8s-rb-config-name": { + "description": "The source of configuration values for config-deploy operation", + "type": "string" + }, + "k8s-rb-config-value-source": { + "description": "The source of configuration values for config-deploy operation", + "type": "string" + }, + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string" + }, + "private2-prefix-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf_name": { + "description": "", + "required": false, + "type": "string" + }, + "demo_artifacts_version": { + "description": "", + "required": false, + "type": "string", + "default": "1.5.0" + }, + "aic-cloud-region": { + "description": "", + "required": false, + "type": "string" + }, + "vf-module-model-customization-uuid": { + "description": "", + "required": false, + "type": "string" + }, + "onap_private_net_cidr": { + "description": "", + "required": false, + "type": "string" + }, + "management-prefix-id": { + "description": "", + "required": false, + "type": "string" + }, + "dcae_collector_ip": { + "description": "", + "required": false, + "type": "string", + "default": "10.0.4.1" + }, + "int_private1_net_cidr": { + "description": "", + "required": false, + "type": "string" + }, + "vf-module-id": { + "description": "", + "required": false, + "type": "string" + }, + "dcae_collector_port": { + "description": "", + "required": false, + "type": "string", + "default": "30235" + }, + "vf-module-name": { + "description": "", + "required": false, + "type": "string" + }, + "vf-module-label": { + "description": "", + "required": false, + "type": "string" + }, + "vf-module-model-invariant-uuid": { + "type": "string" + }, + "vf-naming-policy": { + "description": "", + "required": false, + "type": "string" + }, + "int_private2_net_cidr": { + "description": "", + "required": false, + "type": "string" + }, + "vf-module-model-version": { + "type": "string" + }, + "core-instance-name": { + "description": "Name of 5g core instance that requires PNF registration", + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-ue-subscribe-properties": { + "description": "Dynamic DataType definition for workflow(ue-subscription).", + "version": "1.0.0", + "properties": { + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "vf-modules-list": { + "type": "json" + }, + "config-deploy-setup": { + "type": "json" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-ue-reconfiguration-properties": { + "description": "Dynamic DataType definition for workflow(ue-reconfiguration).", + "version": "1.0.0", + "properties": { + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "vf-modules-list": { + "type": "json" + }, + "config-deploy-setup": { + "type": "json" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-nrf-scaling-properties": { + "description": "Dynamic DataType definition for workflow(unrf-scaling).", + "version": "1.0.0", + "properties": { + "service-instance-id": { + "description": "", + "required": false, + "type": "string" + }, + "vnf-id": { + "description": "", + "required": false, + "type": "string" + }, + "vf-modules-list": { + "type": "json" + }, + "config-deploy-setup": { + "type": "json" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + } + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/free5GC.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/free5GC.json new file mode 100644 index 00000000..5c54d7ea --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/free5GC.json @@ -0,0 +1,827 @@ +{ + "tosca_definitions_version": "controller_blueprint_1_0_0", + "metadata": { + "template_author": "Samuli Silvius ", + "author-email": "lukasz.rajewski@orange.com", + "user-groups": "ADMIN, OPERATION", + "template_name": "free5GC", + "template_version": "1.1.1", + "template_tags": "Samuli Silvius, Lukasz Rajewski, Michal Chabiera, free5GC", + "template_type": "DEFAULT" + }, + "imports": [ + { + "file": "Definitions/data_types.json" + }, + { + "file": "Definitions/relationship_types.json" + }, + { + "file": "Definitions/artifact_types.json" + }, + { + "file": "Definitions/node_types.json" + }, + { + "file": "Definitions/policy_types.json" + } + ], + "dsl_definitions": { + "naming-resolution": { + "type": "basic-auth", + "url": "http://neng-serv:8080/web/service", + "username": "ccsdkapps", + "password": "ccsdkapps" + }, + "vpkg-rest-api": { + "type": "basic-auth", + "url": "http://", + "username": "admin", + "password": "admin" + }, + "config-deploy-properties": { + "resolution-key": { + "get_input": "resolution-key" + } + }, + "simple-status-properties": { + "resolution-key": { + "get_input": "resolution-key" + }, + "config-deploy-setup": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "config-deploy-setup" + ] + }, + "registration-reconfiguration-parameters": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "registration-reconfiguration-parameters" + ] + } + } + }, + "topology_template": { + "workflows": { + "resource-assignment": { + "steps": { + "resource-assignment": { + "description": "Resource Assign Workflow", + "target": "resource-assignment", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ], + "on_success": [ + "profile-upload" + ] + }, + "profile-upload": { + "description": "Generate and upload K8s Profile", + "target": "k8s-profile-upload", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ] + } + }, + "inputs": { + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "resolution-key": { + "required": false, + "type": "string", + "entry_schema": { + "type": "" + } + }, + "resource-assignment-properties": { + "description": "Dynamic PropertyDefinition for workflow(resource-assignment).", + "required": true, + "type": "dt-resource-assignment-properties" + } + }, + "outputs": { + "meshed-template": { + "type": "json", + "value": { + "get_attribute": [ + "resource-assignment", + "assignment-params" + ] + } + } + } + }, + "config-assign": { + "steps": { + "config-setup": { + "description": "Gather necessary input for config template upload", + "target": "config-setup-process", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ] + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "store-result": { + "required": true, + "type": "boolean" + }, + "config-assign-properties": { + "description": "Dynamic PropertyDefinition for workflow(config-assign).", + "required": true, + "type": "dt-config-assign-properties" + } + } + }, + "config-deploy": { + "steps": { + "config-setup": { + "description": "Gather necessary input for config init and status verification", + "target": "config-setup-process", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ], + "on_success": [ + "pnf-registration" + ], + "on_failure": [ + "handle_error" + ] + }, + "pnf-registration": { + "description": "Register UERANSIM as a PNF", + "target": "pnf-registration-request", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "status-verification-script" + ], + "on_failure": [ + "handle_error" + ] + }, + "status-verification-script": { + "description": "Simple status verification script", + "target": "simple-status-check", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "pnf-reconfiguration" + ], + "on_failure": [ + "handle_error" + ] + }, + "pnf-reconfiguration": { + "description": "Reconfigure UERANSIM - call ue-reconfiguration workflow", + "target": "ran-reconfiguration-request", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "collect-results" + ], + "on_failure": [ + "handle_error" + ] + }, + "handle_error": { + "description": "Simple error verification script", + "target": "simple-error-check", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "collect-results" + ] + }, + "collect-results": { + "description": "Final collection of results", + "target": "collect-results" + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "config-deploy-properties": { + "description": "Dynamic PropertyDefinition for workflow(config-deploy).", + "required": true, + "type": "dt-config-deploy-properties" + } + } + }, + "ue-subscribe": { + "steps": { + "config-setup": { + "description": "Gather necessary input for config init and status verification", + "target": "config-setup-process", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ], + "on_success": [ + "ue-subscription" + ], + "on_failure": [ + "handle_error" + ] + }, + "ue-subscription": { + "description": "UE Subscription", + "target": "ue-subscription-request", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "collect-results" + ], + "on_failure": [ + "handle_error" + ] + }, + "handle_error": { + "description": "Simple error verification script", + "target": "simple-error-check", + "activities": [ + { + "call_operation": "ComponentScriptExecutor.process" + } + ], + "on_success": [ + "collect-results" + ] + }, + "collect-results": { + "description": "Final collection of results", + "target": "collect-results" + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "ue-subscribe-properties": { + "description": "Dynamic PropertyDefinition for workflow(ue-subscribe).", + "required": true, + "type": "dt-ue-subscribe-properties" + } + } + }, + "ue-reconfiguration": { + "steps": { + "config-setup": { + "description": "Gather necessary input for config init and status verification", + "target": "config-setup-process", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ], + "on_success": [ + "config-upload" + ], + "on_failure": [ + "handle_error" + ] + }, + "config-upload": { + "description": "Generate and upload UE reconfiguration template", + "target": "k8s-config-template", + "activities": [ + { + "call_operation": "K8sConfigTemplateComponent.process" + } + ], + "on_success": [ + "ue-subscribe" + ], + "on_failure": [ + "handle_error" + ] + }, + "ue-subscribe": { + "description": "Subscribe UE", + "target": "ue-subscription-request", + "activities": [ + { + "call_operation": "K8sConfigTemplateComponent.process" + } + ], + "on_success": [ + "config-apply" + ], + "on_failure": [ + "handle_error" + ] + }, + "config-apply": { + "description": "Activate UE reconfiguration template", + "target": "k8s-config-apply", + "activities": [ + { + "call_operation": "K8sConfigTemplateComponent.process" + } + ], + "on_failure": [ + "handle_error" + ] + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "ue-reconfiguration-properties": { + "description": "Dynamic PropertyDefinition for workflow.", + "required": true, + "type": "dt-ue-reconfiguration-properties" + } + } + }, + "nrf-scaling": { + "steps": { + "config-setup": { + "description": "Gather necessary input for config init and status verification", + "target": "config-setup-process", + "activities": [ + { + "call_operation": "ResourceResolutionComponent.process" + } + ], + "on_success": [ + "config-upload" + ], + "on_failure": [ + "handle_error" + ] + }, + "config-upload": { + "description": "Generate and upload NRF scaling template", + "target": "k8s-config-nrf-scaling-template", + "activities": [ + { + "call_operation": "K8sConfigTemplateComponent.process" + } + ], + "on_success": [ + "config-apply" + ], + "on_failure": [ + "handle_error" + ] + }, + "config-apply": { + "description": "Activate NRF scaling", + "target": "k8s-config-nrf-scaling-apply", + "activities": [ + { + "call_operation": "K8sConfigTemplateComponent.process" + } + ], + "on_failure": [ + "handle_error" + ] + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "nrf-scaling-properties": { + "description": "Dynamic PropertyDefinition for workflow.", + "required": true, + "type": "dt-nrf-scaling-properties" + } + } + } + }, + "node_templates": { + "resource-assignment": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": { + "get_input": "template-prefix" + } + } + } + } + } + }, + "artifacts": { + "helm_free5gc-template": { + "type": "artifact-template-velocity", + "file": "Templates/free5gc-template.vtl" + }, + "helm_free5gc-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/free5gc-mapping.json" + }, + "helm_ueransim-template": { + "type": "artifact-template-velocity", + "file": "Templates/free5gc-template.vtl" + }, + "helm_ueransim-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/free5gc-mapping.json" + }, + "vnf-template": { + "type": "artifact-template-velocity", + "file": "Templates/vnf-template.vtl" + }, + "vnf-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/vnf-mapping.json" + } + } + }, + "k8s-profile-upload": { + "type": "component-k8s-profile-upload", + "interfaces": { + "K8sProfileUploadComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": { + "get_input": "template-prefix" + }, + "resource-assignment-map": { + "get_attribute": [ + "resource-assignment", + "assignment-map" + ] + } + } + } + } + } + }, + "artifacts": { + "free5gc-cnf-cds-base-profile": { + "type": "artifact-k8sprofile-content", + "file": "Templates/k8s-profiles/free5gc-cnf-cds-base-profile.tar.gz" + }, + "ueransim-cnf-cds-base-profile": { + "type": "artifact-k8sprofile-content", + "file": "Templates/k8s-profiles/ueransim-cnf-cds-base-profile.tar.gz" + } + } + }, + "k8s-config-template": { + "type": "component-k8s-config-template", + "interfaces": { + "K8sConfigTemplateComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "helm_ueransim" + ], + "resource-assignment-map": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "config-deploy-setup" + ] + } + } + } + } + } + }, + "artifacts": { + "ue-reconfiguration-template": { + "type": "artifact-k8sconfig-content", + "file": "Templates/k8s-configs/ue-reconfiguration/ueransim.tar.gz" + } + } + }, + "k8s-config-apply": { + "type": "component-k8s-config-value", + "interfaces": { + "K8sConfigValueComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "helm_ueransim" + ], + "k8s-config-operation-type": "create", + "resource-assignment-map": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "config-deploy-setup" + ] + } + } + } + } + } + }, + "artifacts": { + "ue-reconfiguration-template": { + "type": "artifact-k8sconfig-content", + "file": "Templates/k8s-configs/ue-reconfiguration/values.yaml" + } + } + }, + "k8s-config-nrf-scaling-template": { + "type": "component-k8s-config-template", + "interfaces": { + "K8sConfigTemplateComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "helm_free5gc" + ], + "resource-assignment-map": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "config-deploy-setup" + ] + }, + "k8s-rb-config-template-source": "nrf-scaling-config", + "k8s-rb-config-template-name": "nrf-scaling-config-test14" + } + } + } + } + }, + "artifacts": { + "nrf-scaling-config": { + "type": "artifact-k8sconfig-content", + "file": "Templates/k8s-configs/nrf-scaling/free5gc.tar.gz" + } + } + }, + "k8s-config-nrf-scaling-apply": { + "type": "component-k8s-config-value", + "interfaces": { + "K8sConfigValueComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "helm_free5gc" + ], + "k8s-config-operation-type": "create", + "resource-assignment-map": { + "get_attribute": [ + "config-setup-process", + "", + "assignment-map", + "config-deploy", + "config-deploy-setup" + ] + }, + "k8s-rb-config-name": "custom-values-test14", + "k8s-rb-config-value-source": "default-values", + "k8s-rb-config-template-name": "nrf-scaling-config-test14" + } + } + } + } + }, + "artifacts": { + "default-values": { + "type": "artifact-k8sconfig-content", + "file": "Templates/k8s-configs/nrf-scaling/values.yaml" + }, + "custom-values": { + "type": "artifact-k8sconfig-content", + "file": "Templates/k8s-configs/nrf-scaling/values.yaml.vtl" + }, + "custom-values-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/k8s-configs/nrf-scaling/values-mapping.json" + } + } + }, + "simple-status-check": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.SimpleStatusCheck", + "instance-dependencies": [ + "bluePrintPropertiesService" + ], + "dynamic-properties": "*simple-status-properties" + } + } + } + } + } + }, + "pnf-registration-request": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PnfRegistration", + "instance-dependencies": [ + "bluePrintPropertiesService" + ], + "dynamic-properties": "*simple-status-properties" + } + } + } + } + } + }, + "ran-reconfiguration-request": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.RanReconfiguration", + "instance-dependencies": [ + "executionServiceHandler" + ], + "dynamic-properties": "*simple-status-properties" + } + } + } + } + } + }, + "ue-subscription-request": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.UeSubscription", + "instance-dependencies": [ + "bluePrintPropertiesService" + ], + "dynamic-properties": "*simple-status-properties" + } + } + } + } + } + }, + "simple-error-check": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.SimpleErrorCheck", + "instance-dependencies": [ + "bluePrintPropertiesService" + ], + "dynamic-properties": "*simple-status-properties" + } + } + } + } + } + }, + "config-setup-process": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "resolution-key": { + "get_input": "resolution-key" + }, + "store-result": false, + "artifact-prefix-names": [ + "config-deploy" + ] + }, + "outputs": { + "resource-assignment-params": { + "get_attribute": [ + "SELF", + "assignment-params" + ] + }, + "status": "success" + } + } + } + } + }, + "artifacts": { + "config-deploy-template": { + "type": "artifact-template-velocity", + "file": "Templates/config-setup-template.vtl" + }, + "config-deploy-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/config-setup-mapping.json" + } + } + }, + "config-deploy-process": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploy", + "dynamic-properties": "*config-deploy-properties" + } + } + } + } + } + }, + "collect-results": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 180, + "operation_host": "SELF" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.CollectorScript" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/node_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/node_types.json new file mode 100644 index 00000000..c191f164 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/node_types.json @@ -0,0 +1,676 @@ +{ + "node_types": { + "component-resource-resolution": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "attributes": { + "assignment-params": { + "description": "Holds resolved template, resolution-summary or key-value", + "required": true, + "type": "string" + }, + "assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": true, + "type": "map" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "resolution-key": { + "description": "Key for service instance related correlation.", + "required": false, + "type": "string" + }, + "occurrence": { + "description": "Number of time to perform the resolution.", + "required": false, + "default": 1, + "type": "integer" + }, + "store-result": { + "description": "Whether or not to store the output.", + "required": false, + "type": "boolean" + }, + "resource-type": { + "description": "Request type.", + "required": false, + "type": "string" + }, + "resolution-summary": { + "description": "Enable resolution-summary output", + "required": false, + "type": "boolean" + }, + "artifact-prefix-names": { + "required": true, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "request-id": { + "description": "Request Id, Unique Id for the request.", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Resource Id.", + "required": false, + "type": "string" + }, + "action-name": { + "description": "Action Name of the process", + "required": false, + "type": "string" + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "resource-assignment-map": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-script-executor": { + "description": "This is CLI Transaction Configuration Component API", + "version": "1.0.0", + "attributes": { + "response-data": { + "required": false, + "type": "json" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": { + "description": "Script type, kotlin type is supported", + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython", + "internal" + ] + } + ], + "default": "internal" + }, + "script-class-reference": { + "description": "Kotlin Script class name or jython script name.", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "description": "Instance names to inject to Jython or Kotlin Script.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" + } + }, + "outputs": { + "response-data": { + "description": "Execution Response Data.", + "required": false, + "type": "string" + }, + "status": { + "description": "Status of the Component Execution ( success or failure )", + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-k8s-profile-upload": { + "description": "This component is rendering and sending the k8s profile to the multicloud plugin.", + "version": "1.0.0", + "attributes": { + "statuses": { + "required": true, + "type": "json" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "K8sProfileUploadComponent": { + "operations": { + "process": { + "inputs": { + "k8s-rb-profile-name": { + "description": "K8s profile name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-name": { + "description": "K8s definition name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-version": { + "description": "Version of the definition", + "required": false, + "type": "string" + }, + "k8s-rb-profile-namespace": { + "description": "a K8s namespace for the profile", + "required": false, + "type": "string" + }, + "k8s-rb-profile-k8s-version": { + "description": "a K8s cluster version for the profile", + "required": false, + "type": "string" + }, + "k8s-rb-profile-source": { + "description": "Source (tgz/folder) for the template in CBA", + "required": false, + "type": "string" + }, + "artifact-prefix-names": { + "description": "Resource Assignment Artifact Prefix names", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "resource-assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": false, + "type": "json" + } + }, + "outputs": { + "statuses": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-k8s-config-template": { + "description": "This component is rendering and sending the k8s template to the multicloud plugin.", + "version": "1.0.0", + "attributes": { + "statuses": { + "required": true, + "type": "json" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "K8sConfigTemplateComponent": { + "operations": { + "process": { + "inputs": { + "k8s-rb-config-template-name": { + "description": "K8s template name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-name": { + "description": "K8s definition name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-version": { + "description": "Version of the definition", + "required": false, + "type": "string" + }, + "k8s-rb-config-template-source": { + "description": "Source (tgz/folder) for the template in CBA", + "required": false, + "type": "string" + }, + "artifact-prefix-names": { + "description": "Resource Assignment Artifact Prefix names", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "resource-assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": false, + "type": "json" + } + }, + "outputs": { + "statuses": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-k8s-config-value": { + "description": "This component is sending the k8s config value to the multicloud plugin.", + "version": "1.0.0", + "attributes": { + "statuses": { + "required": true, + "type": "json" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "K8sConfigValueComponent": { + "operations": { + "process": { + "inputs": { + "k8s-rb-config-template-name": { + "description": "K8s template name", + "required": false, + "type": "string" + }, + "k8s-rb-config-name": { + "description": "K8s config name", + "required": false, + "type": "string" + }, + "k8s-instance-id": { + "description": "K8s instance id", + "required": false, + "type": "string" + }, + "k8s-rb-config-value-source": { + "description": "Location of value source in CBA", + "required": false, + "type": "string" + }, + "k8s-config-operation-type": { + "required": false, + "type": "string", + "constraints": [ + { + "valid_values": [ + "create", + "update", + "delete" + ] + } + ], + "default": "create" + }, + "artifact-prefix-names": { + "description": "Resource Assignment Artifact Prefix names", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "resource-assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": false, + "type": "json" + } + }, + "outputs": { + "statuses": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "source-capability": { + "description": "This is Component Resource Source Node Type", + "version": "1.0.0", + "properties": { + "script-type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "kotlin", + "internal", + "jython" + ] + } + ], + "default": "kotlin" + }, + "script-class-reference": { + "description": "Capability reference name for internal and kotlin, for jython script file path", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "description": "Instance dependency Names to Inject to Kotlin / Jython Script.", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "description": "Resource Resolution dependency dictionary names.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" + }, + "source-db": { + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ], + "default": "SQL" + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "query": { + "required": true, + "type": "string" + }, + "input-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" + }, + "source-default": { + "description": "This is Default Resource Source Node Type", + "version": "1.0.0", + "properties": {}, + "derived_from": "tosca.nodes.ResourceSource" + }, + "source-input": { + "description": "This is Input Resource Source Node Type", + "version": "1.0.0", + "properties": {}, + "derived_from": "tosca.nodes.ResourceSource" + }, + "source-rest": { + "description": "This is Rest Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "JSON" + ] + } + ], + "default": "JSON" + }, + "headers": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "verb": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "GET", + "POST", + "DELETE", + "PUT" + ] + } + ], + "default": "GET" + }, + "payload": { + "required": false, + "type": "string", + "default": "" + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "url-path": { + "required": true, + "type": "string" + }, + "path": { + "required": true, + "type": "string" + }, + "expression-type": { + "required": false, + "type": "string", + "constraints": [ + { + "valid_values": [ + "JSON_PATH", + "JSON_POINTER" + ] + } + ], + "default": "JSON_PATH" + }, + "input-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" + }, + "tosca.nodes.Component": { + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.ResourceSource": { + "description": "TOSCA base type for Resource Sources", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.Vnf": { + "description": "This is VNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.Workflow": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "vnf-netconf-device": { + "description": "This is VNF Device with Netconf Capability", + "version": "1.0.0", + "capabilities": { + "netconf": { + "type": "tosca.capabilities.Netconf", + "properties": { + "login-key": { + "required": true, + "type": "string", + "default": "sdnc" + }, + "login-account": { + "required": true, + "type": "string", + "default": "sdnc-tacacs" + }, + "source": { + "required": false, + "type": "string", + "default": "npm" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer", + "default": 830 + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + }, + "restconf": { + "type": "tosca.capabilities.Restconf", + "properties": { + "login-key": { + "required": true, + "type": "string" + }, + "login-account": { + "required": true, + "type": "string" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer" + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + } + }, + "derived_from": "tosca.nodes.Vnf" + } + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/policy_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/policy_types.json new file mode 100644 index 00000000..335746c4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types": {} +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/relationship_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/relationship_types.json new file mode 100644 index 00000000..8a388510 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/relationship_types.json @@ -0,0 +1,3 @@ +{ + "relationship_types": {} +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Definitions/resources_definition_types.json b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/resources_definition_types.json new file mode 100644 index 00000000..2e9adcc4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Definitions/resources_definition_types.json @@ -0,0 +1,1463 @@ +{ + "active-streams": { + "tags": "active-streams", + "name": "active-streams", + "property": { + "description": "active-streams", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "aic-cloud-region": { + "tags": "aic-cloud-region", + "name": "aic-cloud-region", + "property": { + "description": "aic-cloud-region", + "type": "string" + }, + "group": "default", + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "dcae_collector_ip": { + "tags": "dcae_collector_ip", + "name": "dcae_collector_ip", + "property": { + "description": "dcae_collector_ip", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/dcae_collector_ip", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "dcae_collector_ip": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "dcae_collector_port": { + "tags": "dcae_collector_port", + "name": "dcae_collector_port", + "property": { + "description": "dcae_collector_port", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/dcae_collector_port", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "dcae_collector_port": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "demo_artifacts_version": { + "tags": "demo_artifacts_version", + "name": "demo_artifacts_version", + "property": { + "description": "demo_artifacts_version", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/demo_artifacts_version", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "demo_artifacts_version": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "int_private1_net_cidr": { + "tags": "int_private1_net_cidr", + "name": "int_private1_net_cidr", + "property": { + "description": "int_private1_net_cidr", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/int_private1_net_cidr", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "int_private1_net_cidr": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private1\"", + "input-key-mapping": {}, + "output-key-mapping": { + "int_private1_net_cidr": "prefix" + } + } + } + } + }, + "int_private2_net_cidr": { + "tags": "int_private2_net_cidr", + "name": "int_private2_net_cidr", + "property": { + "description": "int_private2_net_cidr", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private2\"", + "output-key-mapping": { + "int_private2_net_cidr": "prefix" + }, + "input-key-mapping": {} + } + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/int_private2_net_cidr", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "int_private2_net_cidr": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "k8s-rb-profile-name": { + "tags": "k8s, cnf, profile, k8s-rb-profile-name", + "name": "k8s-rb-profile-name", + "property": { + "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string" + }, + "group": "default", + "updated-by": "Samuli, Silvius ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-instance-release-name": { + "tags": "k8s, cnf, profile, k8s-rb-instance-release-name", + "name": "k8s-rb-instance-release-name", + "property": { + "description": "Name of the release for the helm package instance in k8s", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-profile-namespace": { + "tags": "k8s, cnf, profile, namespace, k8s-rb-profile-namespace", + "name": "k8s-rb-profile-namespace", + "property": { + "description": "Profile name used in multicloud/k8s plugin", + "type": "string" + }, + "group": "default", + "updated-by": "Samuli, Silvius ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/k8s-rb-profile-namespace", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "k8s-rb-profile-namespace": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "k8s-rb-profile-k8s-version": { + "tags": "k8s, cnf, profile, k8s version, k8s-rb-profile-k8s-version", + "name": "k8s-rb-profile-k8s-version", + "property": { + "description": "Profile k8s version used in multicloud/k8s plugin", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/k8s-rb-profile-k8s-version", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "k8s-rb-profile-k8s-version": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "k8s-rb-profile-source": { + "tags": "k8s, cnf, profile, k8s-rb-profile-source", + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-config-template-name": { + "tags": "k8s, cnf, config, k8s-rb-config-template-name", + "name": "k8s-rb-config-template-name", + "property": { + "description": "The name of configuration template for config-assign operation", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-config-template-source": { + "tags": "k8s, cnf, config, k8s-rb-config-template-source", + "name": "k8s-rb-config-template-source", + "property": { + "description": "The source of configuration template for config-assign operation", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-config-value-source": { + "tags": "k8s, cnf, config, k8s-rb-config-value-source", + "name": "k8s-rb-config-value-source", + "property": { + "description": "The source of configuration values for config-deploy operation", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "k8s-rb-config-name": { + "tags": "k8s, cnf, config, k8s-rb-config-name", + "name": "k8s-rb-config-name", + "property": { + "description": "The source of configuration values for config-deploy operation", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "management-prefix-id": { + "tags": "management-prefix-id", + "name": "management-prefix-id", + "property": { + "description": "management-prefix-id", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/management-prefix-id", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "management-prefix-id": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"management\"", + "input-key-mapping": {}, + "output-key-mapping": { + "management-prefix-id": "prefix_id" + } + } + } + } + }, + "onap_private_net_cidr": { + "tags": "onap_private_net_cidr", + "name": "onap_private_net_cidr", + "property": { + "description": "onap_private_net_cidr", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"management\"", + "input-key-mapping": {}, + "output-key-mapping": { + "onap_private_net_cidr": "prefix" + } + } + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_net_cidr", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "onap_private_net_cidr": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "private1-prefix-id": { + "tags": "private1-prefix-id", + "name": "private1-prefix-id", + "property": { + "description": "private1-prefix-id", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/private1-prefix-id", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "private1-prefix-id": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private1\"", + "input-key-mapping": {}, + "output-key-mapping": { + "private1-prefix-id": "prefix_id" + } + } + } + } + }, + "private2-prefix-id": { + "tags": "private2-prefix-id", + "name": "private2-prefix-id", + "property": { + "description": "private2-prefix-id", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/private2-prefix-id", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "private2-prefix-id": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private2\"", + "input-key-mapping": {}, + "output-key-mapping": { + "private2-prefix-id": "prefix_id" + } + } + } + } + }, + "put-active-streams": { + "tags": "put-active-streams", + "name": "put-active-streams", + "property": { + "description": "put-active-streams", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "PUT", + "type": "JSON", + "url-path": "$vpg_onap_private_ip_0:8183/restconf/config/stream-count:stream-count/streams", + "path": "/param/0/value", + "input-key-mapping": { + "vpg_onap_private_ip_0": "vpg_onap_private_ip_0", + "active-streams": "active-streams" + }, + "output-key-mapping": {}, + "key-dependencies": [ + "vpg_onap_private_ip_0", + "active-streams" + ], + "endpoint-selector": "vpkg-rest-api", + "payload": "{\"streams\": {\"active-streams\": $active-streams}}" + } + } + } + }, + "service-instance-id": { + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "name": "service-instance-id", + "property": { + "description": "To be provided", + "type": "string" + }, + "group": "default", + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input", + "properties": {} + }, + "any-db": { + "type": "source-db", + "properties": { + "query": "SELECT artifact_name FROM BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", + "input-key-mapping": {}, + "output-key-mapping": { + "service-instance-id": "artifact_name" + } + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "query": "SELECT artifact_name FROM BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", + "input-key-mapping": {}, + "output-key-mapping": { + "service-instance-id": "artifact_name" + } + } + }, + "capability": { + "type": "source-capability", + "properties": { + "script-type": "jython", + "script-class-reference": "SampleRAProcessor", + "instance-dependencies": [] + } + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id", + "path": "/service/0/service-instance-id", + "input-key-mapping": { + "service-instance-id": "service-instance.service-instance-id" + }, + "output-key-mapping": { + "service-instance-id": "service-instance-id" + }, + "key-dependencies": [ + "service-instance.service-instance-id" + ] + } + } + } + }, + "vf-module-id": { + "tags": "vf-module-id", + "name": "vf-module-id", + "property": { + "description": "vf-module-id", + "type": "string" + }, + "group": "default", + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/vf-module/$vf-module-id", + "path": "/vf-module/0/vf-module-id", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id", + "vf-module-id": "vf-module.vf-module-id" + }, + "output-key-mapping": { + "vf-module-id": "vf-module-id" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id", + "vf-module.vf-module-id" + ] + } + } + } + }, + "vf-module-name": { + "tags": "vf-module-name", + "name": "vf-module-name", + "property": { + "description": "vf-module-name", + "type": "string" + }, + "group": "default", + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/vf-module/$vf_module_id/vf-module-data/vf-module-topology/vf-module-parameters/param/vf-module-name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vf-module-name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id", + "vf_module_id" + ] + } + }, + "rest": { + "type": "source-rest", + "properties": { + "endpoint-selector": "naming-resolution", + "verb": "POST", + "type": "JSON", + "headers": { + "Accept": "application/json", + "Content-Type": "application/json" + }, + "url-path": "/v1/genNetworkElementName", + "payload": "{\r\n \"elements\": [\r\n {\r\n \"resource-name\": \"vf-module-name\",\r\n \"resource-value\": \"${vf-module-name}\",\r\n \"external-key\": \"${vf-module-id}\",\r\n \"policy-instance-name\": \"${vf-naming-policy}\",\r\n \"naming-type\": \"VF-MODULE\",\r\n \"VNF_NAME\": \"${vnf_name}\",\r\n \"VF_MODULE_LABEL\":\"${vf-module-label}\",\r\n \"VF_MODULE_TYPE\":\"vfmt\"\r\n }\r\n ]\r\n}", + "path": "/elements/0/resource-value", + "input-key-mapping": { + "vf-naming-policy": "vf-naming-policy", + "vnf_name": "vnf_name", + "vf-module-label": "vf-module-label", + "vf-module-id": "vf-module-id" + }, + "output-key-mapping": { + "vf-module-name": "resource-value" + }, + "key-dependencies": [ + "vf-naming-policy", + "vnf_name", + "vf-module-label", + "vf-module-id" + ] + } + } + } + }, + "vf-module-type": { + "tags": "vf-module-type", + "name": "vf-module-type", + "property": { + "description": "vf-module-type", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", + "output-key-mapping": { + "vf-module-type": "vf_module_type" + }, + "input-key-mapping": { + "customizationid": "vf-module-model-customization-uuid" + }, + "key-dependencies": [ + "vf-module-model-customization-uuid" + ] + } + } + } + }, + "vf-module-label": { + "tags": "vf-module-label", + "name": "vf-module-label", + "property": { + "description": "vf-module-label", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", + "input-key-mapping": { + "customizationid": "vf-module-model-customization-uuid" + }, + "output-key-mapping": { + "vf-module-label": "vf_module_label" + }, + "key-dependencies": [ + "vf-module-model-customization-uuid" + ] + } + } + } + }, + "vf-module-model-customization-uuid": { + "tags": "vf-module-model-customization-uuid", + "name": "vf-module-model-customization-uuid", + "property": { + "description": "vf-module-model-customization-uuid", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "vf-module-model-invariant-uuid": { + "tags": "vnf, vf-module", + "name": "vf-module-model-invariant-uuid", + "property": { + "description": "vf module model invariant uuid", + "type": "string" + }, + "group": "default", + "updated-by": "Samuli, Silvius ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.VF_MODULE_MODEL.invariant_uuid as vf_module_model_invariant_uuid from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", + "input-key-mapping": { + "customizationid": "vf-module-model-customization-uuid" + }, + "output-key-mapping": { + "vf-module-model-invariant-uuid": "vf_module_model_invariant_uuid" + }, + "key-dependencies": [ + "vf-module-model-customization-uuid" + ] + } + } + } + }, + "vf-module-model-version": { + "tags": "vnf, vf-module", + "name": "vf-module-model-version", + "property": { + "description": "vf module model model version", + "type": "string" + }, + "group": "default", + "updated-by": "Samuli, Silvius ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.VF_MODULE_MODEL.uuid as vf_module_model_version from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", + "input-key-mapping": { + "customizationid": "vf-module-model-customization-uuid" + }, + "output-key-mapping": { + "vf-module-model-version": "vf_module_model_version" + }, + "key-dependencies": [ + "vf-module-model-customization-uuid" + ] + } + } + } + }, + "vf-naming-policy": { + "tags": "vf-naming-policy", + "name": "vf-naming-policy", + "property": { + "description": "vf-naming-policy", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vf-naming-policy", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vf-naming-policy": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "processor-db": { + "type": "source-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", + "input-key-mapping": { + "vnf_model_customization_uuid": "vnf-model-customization-uuid" + }, + "output-key-mapping": { + "vf-naming-policy": "vf_naming_policy" + }, + "key-dependencies": [ + "vnf-model-customization-uuid" + ] + } + } + } + }, + "vnf-id": { + "tags": "vnf-id", + "name": "vnf-id", + "property": { + "description": "vnf-id", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/", + "path": "/vnf/0/vnf-id", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "generic-vnf.vnf-id" + }, + "output-key-mapping": { + "vnf-id": "vnf-id" + }, + "key-dependencies": [ + "service-instance-id", + "generic-vnf.vnf-id" + ] + } + } + } + }, + "vnf_name": { + "tags": "vnf_name", + "name": "vnf_name", + "property": { + "description": "vnf_name", + "type": "string" + }, + "group": "default", + "updated-by": "MALAKOV, YURIY ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "headers": { + "Accept": "application/json", + "Content-Type": "application/json" + }, + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + }, + "rest": { + "type": "source-rest", + "properties": { + "endpoint-selector": "naming-resolution", + "verb": "POST", + "type": "JSON", + "headers": { + "Accept": "application/json", + "Content-Type": "application/json" + }, + "url-path": "/v1/genNetworkElementName", + "payload": "{\r\n \"elements\": [\r\n {\r\n \"resource-name\": \"vnf_name\",\r\n \"resource-value\": \"${vnf_name}\",\r\n \"external-key\": \"${vnf-id}\",\r\n \"policy-instance-name\": \"${vf-naming-policy}\",\r\n \"naming-type\": \"VNF\",\r\n \"AIC_CLOUD_REGION\": \"${aic-cloud-region}\"\r\n }\r\n ]\r\n}", + "path": "/elements/0/resource-value", + "input-key-mapping": { + "vnf-id": "vnf-id", + "aic-cloud-region": "aic-cloud-region", + "vf-naming-policy": "vf-naming-policy" + }, + "output-key-mapping": { + "vnf_name": "resource-value" + }, + "key-dependencies": [ + "vnf-id", + "aic-cloud-region", + "vf-naming-policy" + ] + } + } + } + }, + "replica-count": { + "tags": "replica-count", + "name": "replica-count", + "property": { + "description": "replica-count", + "type": "integer" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "vpg_onap_private_ip_0": { + "tags": "vpg_onap_private_ip_0", + "name": "vpg_onap_private_ip_0", + "property": { + "description": "vpg_onap_private_ip_0", + "type": "string" + }, + "group": "default", + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vpg_onap_private_ip_0", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vpg_onap_private_ip_0": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "vf-modules-list": { + "tags": "vf-modules-list", + "name": "vf-modules-list", + "property": { + "description": "List of vf-modules associated with vnf", + "type": "json" + }, + "group": "default", + "updated-by": "Lukasz Rajewski ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "aai-data": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/aai/v19/network/generic-vnfs/generic-vnf/${vnf-id}?depth=1", + "path": "/vf-modules", + "input-key-mapping": { + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vf-modules": "vf-module" + }, + "key-dependencies": [ + "vnf-id" + ] + } + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules", + "path": "/vf-modules", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vf-modules": "vf-module" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + }, + "config-deploy-setup": { + "tags": "config-deploy-setup", + "name": "config-deploy-setup", + "property": { + "description": "Configuration Input setup for config-deploy operation", + "type": "json" + }, + "group": "default", + "updated-by": "Lukasz Rajewski ", + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploySetup", + "instance-dependencies": [] + } + } + } + }, + "registration-reconfiguration-parameters": { + "tags": "registration-reconfiguration-parameters", + "name": "registration-reconfiguration-parameters", + "property": { + "description": "Configuration Input setup for config-deploy operation", + "type": "json" + }, + "group": "default", + "updated-by": "Chabiera, Michal ", + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploySetup", + "instance-dependencies": [] + } + } + } + }, + "pnf-instance-name": { + "tags": "pnf-instance-name", + "name": "pnf-instance-name", + "property": { + "description": "Configuration Input setup for config-deploy operation", + "type": "string" + }, + "group": "default", + "updated-by": "Chabiera, Michal ", + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploySetup", + "instance-dependencies": [] + } + } + } + }, + "core-instance-name": { + "tags": "PNF, ueransim, core, core-instance-namee", + "name": "core-instance-name", + "property": { + "description": "Name of 5g core instance that requires PNF registration", + "type": "string" + }, + "group": "default", + "updated-by": "Chabiera, Michal ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, + "service-instance-name": { + "tags": "service-instance-name", + "name": "service-instance-name", + "property": { + "description": "service-instance-name", + "type": "string" + }, + "group": "default", + "updated-by": "Chabiera, Michal ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "sdnc": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id", + "path": "/service/0/service-data/service-topology/service-topology-identifier/service-instance-name", + "input-key-mapping": { + "service-instance-id": "service-instance-id" + }, + "output-key-mapping": { + "service-instance-name": "value" + }, + "key-dependencies": [ + "service-instance-id" + ] + } + } + } + }, + "pnf-details-aai": { + "tags": "pnf-details-aai", + "name": "pnf-details-aai", + "property": { + "description": "PNF details stored in AAI", + "type": "json" + }, + "group": "default", + "updated-by": "Chabiera, Michal ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + }, + "aai-data": { + "type": "source-rest", + "properties": { + "verb": "GET", + "type": "JSON", + "url-path": "/aai/v19/network/pnfs?pnf-name=$pnf-instance-name", + "path": "", + "input-key-mapping": { + "pnf-instance-name": "pnf-instance-name" + }, + "output-key-mapping": { + "pnf": "pnf" + }, + "key-dependencies": [ + "pnf-instance-name" + ] + } + } + } + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/CollectorScript.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/CollectorScript.kt new file mode 100644 index 00000000..589b9342 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/CollectorScript.kt @@ -0,0 +1,53 @@ +/* + * Copyright © 2021 Bell Canada. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode +import org.onap.ccsdk.cds.controllerblueprints.core.logger + +open class CollectorScript : AbstractScriptComponentFunction() { + + private val log = logger(CollectorScript::class) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + bluePrintRuntimeService.bluePrintContext() + .serviceTemplate.topologyTemplate!!.nodeTemplates!! + .keys.filter { it.startsWith("execute-script") } + .associateWith { responseData(it) } + .let { it.asJsonNode() } + .also { log.info("Collected results: $it") } + .let { setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, it) } + } + + private fun responseData(nodeTemplateName: String): JsonNode? { + return try { + bluePrintRuntimeService.getNodeTemplateAttributeValue( + nodeTemplateName, + ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA + ) + } catch (exception: BluePrintProcessorException) { null } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + addError(runtimeException.message ?: "Failed without error message") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploy.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploy.kt new file mode 100644 index 00000000..96b3c515 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploy.kt @@ -0,0 +1,48 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.slf4j.LoggerFactory + +open class ConfigDeploy : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!! + + override fun getName(): String { + return "ConfigDeploy" + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val resolutionKey = getDynamicProperties("resolution-key").asText() + log.info("Got the resolution_key: $resolutionKey from config-deploy going to retrieve the data from DB") + val prefix = "config-deploy" // used in the config-assign resolution + + val payload = storedContentFromResolvedArtifactNB(resolutionKey, prefix) + log.info("cnf configuration data from DB : \n$payload\n") + + println("Run config-deploy") + println("$payload") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt new file mode 100644 index 00000000..b01d7e69 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt @@ -0,0 +1,154 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.template.K8sConfigTemplateComponent +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.template.K8sConfigValueComponent +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory + +open class ConfigDeploySetup() : ResourceAssignmentProcessor() { + + private val log = LoggerFactory.getLogger(ConfigDeploySetup::class.java)!! + + override fun getName(): String { + return "ConfigDeploySetup" + } + + override suspend fun processNB(executionRequest: ResourceAssignment) { + + try { + if (executionRequest.name == "registration-reconfiguration-parameters"){ + val objectMapper = jacksonObjectMapper() + var retValue: ObjectNode? = null + val result: ObjectNode = objectMapper.createObjectNode() + + val pnfDetailsAai = raRuntimeService.getResolutionStore("pnf-details-aai") + val serviceInstanceId = raRuntimeService.getResolutionStore("service-instance-id") + val vnfId = raRuntimeService.getResolutionStore("vnf-id") + + if (pnfDetailsAai.get("pnf").get(0).get("orchestration-status").asText() == "Active") { //to sie dzieje w CORE, na potrzeby rekonfiguracji UERANSIM, gdy PNF nie jest aktywny, to znaczy ze nie został zarejestrowany + val reconfigParam: ObjectNode = objectMapper.createObjectNode() + reconfigParam.put("service-instance-id", pnfDetailsAai.get("pnf").get(0).get("serial-number")) + reconfigParam.put("vnf-id", pnfDetailsAai.get("pnf").get(0).get("equip-model")) + result.put("reconfiguration-params", reconfigParam) + } + else { //to sie dzieje w UERANSIM, na potrzeby eventu rejestracyjnego + val regiParam: ObjectNode = objectMapper.createObjectNode() + regiParam.put("service-instance-id", serviceInstanceId) + regiParam.put("vnf-id", vnfId) + result.put("registration-params", regiParam) + } + + retValue = result + ResourceAssignmentUtils.setResourceDataValue(executionRequest, raRuntimeService, retValue) + } + else if (executionRequest.name == "pnf-instance-name") { + var retValue: String? = null + + val modulesSdnc = raRuntimeService.getResolutionStore("vf-modules-list-sdnc")["vf-modules"] + val serviceInstanceName = raRuntimeService.getResolutionStore("service-instance-name").asText() + + var result: String = serviceInstanceName + for (module in modulesSdnc) { + val modelTopology = module.at("/vf-module-data/vf-module-topology") + val moduleParameters = modelTopology.at("/vf-module-parameters/param") + val label: String? = getParamValueByName(moduleParameters, "vf_module_label") + if (label == "helm_ueransim") { + val coreInstanceName: String? = getParamValueByName(moduleParameters, "core-instance-name") + if (coreInstanceName != null) + result = coreInstanceName + } + } + + retValue = result + ResourceAssignmentUtils.setResourceDataValue(executionRequest, raRuntimeService, retValue) + } + else if (executionRequest.name == "config-deploy-setup") { + val objectMapper = jacksonObjectMapper() + var retValue: ObjectNode? = null + val result: ObjectNode = objectMapper.createObjectNode() + + val modulesSdnc = raRuntimeService.getResolutionStore("vf-modules-list-sdnc")["vf-modules"] + val modulesAai = raRuntimeService.getResolutionStore("vf-modules-list-aai")["vf-modules"] + + for (module in modulesSdnc) { + val modelTopology = module.at("/vf-module-data/vf-module-topology") + val moduleParameters = modelTopology.at("/vf-module-parameters/param") + val label: String? = getParamValueByName(moduleParameters, "vf_module_label") + if (label != null) { + val modelInfo = modelTopology["onap-model-information"] + val moduleData: ObjectNode = objectMapper.createObjectNode() + result.put(label, moduleData) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_NAME, modelInfo["model-invariant-uuid"].asText()) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_VERSION, modelInfo["model-customization-uuid"].asText()) + val templateName: String? = getParamValueByName(moduleParameters, K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_NAME) + val templateSource: String? = getParamValueByName(moduleParameters, K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_SOURCE) + val configValueSource: String? = getParamValueByName(moduleParameters, K8sConfigValueComponent.INPUT_K8S_CONFIG_VALUE_SOURCE) + val configName: String? = getParamValueByName(moduleParameters, K8sConfigValueComponent.INPUT_K8S_RB_CONFIG_NAME) + val coreInstanceName: String? = getParamValueByName(moduleParameters, "core-instance-name") + + if (templateName != null) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_NAME, templateName) + if (templateSource != null) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_SOURCE, templateSource) + if (configValueSource != null) + moduleData.put(K8sConfigValueComponent.INPUT_K8S_CONFIG_VALUE_SOURCE, configValueSource) + if (configName != null) + moduleData.put(K8sConfigValueComponent.INPUT_K8S_RB_CONFIG_NAME, configName) + if (coreInstanceName != null) + moduleData.put("core-instance-name", coreInstanceName) + + for (aaiModule in modulesAai) { + if (aaiModule["vf-module-id"].asText() == module["vf-module-id"].asText() && aaiModule["heat-stack-id"] != null) { + moduleData.put(K8sConfigValueComponent.INPUT_K8S_INSTANCE_ID, aaiModule["heat-stack-id"].asText()) + break + } + } + } + } + retValue = result + ResourceAssignmentUtils.setResourceDataValue(executionRequest, raRuntimeService, retValue) + } + + } catch (e: Exception) { + log.error(e.message, e) + ResourceAssignmentUtils.setResourceDataValue(executionRequest, raRuntimeService, "ERROR") + + throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments, cause: ${e.message}", e) + } + } + + private fun getParamValueByName(params: JsonNode, paramName: String): String? { + for (param in params) { + if (param["name"].asText() == paramName && param["value"].asText() != "null") { + return param["value"].asText() + } + } + return null + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + this.addError("${runtimeException.message}") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/PnfRegistration.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/PnfRegistration.kt new file mode 100644 index 00000000..471c932e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/PnfRegistration.kt @@ -0,0 +1,170 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.node.ObjectNode +import com.google.gson.Gson +import kotlinx.coroutines.delay +import kotlinx.coroutines.withTimeout +import net.minidev.json.JSONObject +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.slf4j.LoggerFactory +import org.springframework.http.HttpMethod + +open class PnfRegistration : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(PnfRegistration::class.java)!! + + override fun getName(): String { + return "PnfRegistration" + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("PNF REGISTRATION - START") + val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode + val registrationParams: ObjectNode = getDynamicProperties("registration-reconfiguration-parameters") as ObjectNode + val vesIpAddress = "dcae-ves-collector" + val vesPort = "8443" + val aaiIpAddress = "aai" + val aaiPort = "8443" +// val vesIpAddress = "10.254.184.164" +// val vesPort = "8443" +// val aaiIpAddress = "10.254.184.164" +// val aaiPort = "30233" + configValueSetup.fields().forEach { it -> + if (it.key == "helm_ueransim"){ + if (registrationParams.has("registration-params")){ + val coreInstanceName = it.value["core-instance-name"].asText() + val serviceInstanceId = registrationParams.get("registration-params").get("service-instance-id").asText() + val vnfId = registrationParams.get("registration-params").get("vnf-id").asText() + try { + withTimeout(60500) { + while(!isPnfRegistered(coreInstanceName, aaiIpAddress, aaiPort)) + { + log.info("PNF not registered, sending registration event.") + sendPnfRegistrationEvent(coreInstanceName, vesIpAddress, vesPort, serviceInstanceId, vnfId) + delay(15000) + } + log.info("PNF registered") + } + } + catch (e: Exception){ + log.error("Error during request sending.") + } + } + else { + log.error("No need to register PNF.") //See ConfigDeploySetup - status "Active" means PNF is registered + } + } + else { + log.info("Run PnfRegistration only for helm_ueransim") + } + } + log.info("PNF REGISTRATION - END") + } + + private fun isPnfRegistered(sourceName: String, ipAddress: String, port: String): Boolean { + val restClientProperties: BasicAuthRestClientProperties = BasicAuthRestClientProperties() + restClientProperties.url = "https://$ipAddress:$port" + restClientProperties.password = "AAI" + restClientProperties.username = "AAI" + val additionalHeaders = hashMapOf() + additionalHeaders["X-TransactionId"] = "1234" + additionalHeaders["X-FromAppId"] = "CDS" + restClientProperties.additionalHeaders = additionalHeaders + val restClientService: BasicAuthRestClientService = BasicAuthRestClientService(restClientProperties) + var result : BlueprintWebClientService.WebClientResponse? = null + result = restClientService.exchangeResource(HttpMethod.GET.name, "/aai/v16/network/pnfs/pnf/$sourceName", "") + val bodyString = result.body.toString() + val bodyMap = Gson().fromJson>(bodyString, MutableMap::class.java) + + return bodyMap["orchestration-status"] == "Active" + } + + private fun sendPnfRegistrationEvent(sourceName: String, vesIpAddress: String, vesPort: String, serviceInstanceId: String, vnfId: String){ + val restClientProperties: BasicAuthRestClientProperties = BasicAuthRestClientProperties() + restClientProperties.url = "https://$vesIpAddress:$vesPort" + restClientProperties.password = "sample1" + restClientProperties.username = "sample1" + val restClientService: BasicAuthRestClientService = BasicAuthRestClientService(restClientProperties) + var result : BlueprintWebClientService.WebClientResponse? = null + + val payload = prepareRequestBody(sourceName, serviceInstanceId, vnfId) + + result = restClientService.exchangeResource(HttpMethod.POST.name, "/eventListener/v7", payload.toString()) + + if (result.status == 202 && result.body == "Accepted") { + log.info("PNF Registration event sent successfully") + } else { + log.error("Something went wrong with PNF Registrtation") + } + } + + private fun prepareRequestBody(sourceName: String, serviceInstanceId: String, vnfId: String): JSONObject { + val commonEventHeaderData = JSONObject() + commonEventHeaderData.appendField("startEpochMicrosec", 1538407540940) + commonEventHeaderData.appendField("sourceId", "val13") + commonEventHeaderData.appendField("eventId", "registration_38407540") + commonEventHeaderData.appendField("nfcNamingCode", "oam") + commonEventHeaderData.appendField("internalHeaderFields", JSONObject()) + commonEventHeaderData.appendField("eventType", "pnfRegistration") + commonEventHeaderData.appendField("priority", "Normal") + commonEventHeaderData.appendField("version", "4.0.1") + commonEventHeaderData.appendField("reportingEntityName", "NOK6061ZW3") + commonEventHeaderData.appendField("sequence", 0) + commonEventHeaderData.appendField("domain", "pnfRegistration") + commonEventHeaderData.appendField("lastEpochMicrosec",1538407540940) + commonEventHeaderData.appendField("eventName", "test") + commonEventHeaderData.appendField("vesEventListenerVersion", "7.0.1") + commonEventHeaderData.appendField("sourceName", sourceName) + commonEventHeaderData.appendField("nfNamingCode", "pnfservice") + + val pnfRegistrationFieldsData = JSONObject() + pnfRegistrationFieldsData.appendField("unitType", "val8") + pnfRegistrationFieldsData.appendField("serialNumber", serviceInstanceId) + pnfRegistrationFieldsData.appendField("pnfRegistrationFieldsVersion", "2.0") + pnfRegistrationFieldsData.appendField("manufactureDate", "1538407540942") + pnfRegistrationFieldsData.appendField("modelNumber", vnfId) + pnfRegistrationFieldsData.appendField("lastServiceDate", "1538407540942") + pnfRegistrationFieldsData.appendField("unitFamily", "BBU") + pnfRegistrationFieldsData.appendField("vendorName", "Juniper") + pnfRegistrationFieldsData.appendField("oamV4IpAddress", "10.10.10.10") + pnfRegistrationFieldsData.appendField("oamV6IpAddress", "ff02::02") + pnfRegistrationFieldsData.appendField("softwareVersion", "1") + + val eventData = JSONObject() + eventData.appendField("pnfRegistrationFields", pnfRegistrationFieldsData) + eventData.appendField("commonEventHeader", commonEventHeaderData) + + val payload = JSONObject() + payload.appendField("event", eventData) + + val payloadString = payload.toString() + log.info("Request body: $payloadString") + + return payload + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/README.md b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/README.md new file mode 100644 index 00000000..29b7978e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/README.md @@ -0,0 +1 @@ +kotlin Folder \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/RanReconfiguration.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/RanReconfiguration.kt new file mode 100644 index 00000000..ba0a279e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/RanReconfiguration.kt @@ -0,0 +1,92 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.ObjectNode +import net.minidev.json.JSONObject +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.ExecutionServiceHandler +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString +import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.slf4j.LoggerFactory + +open class RanReconfiguration : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(RanReconfiguration::class.java)!! + + override fun getName(): String { + return "RanReconfiguration" + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("RAN RECONFIGURATION - START") + val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode + val reconfigurationParams: ObjectNode = getDynamicProperties("registration-reconfiguration-parameters") as ObjectNode + if (configValueSetup.has("helm_free5gc")) { + val pnfDetailsServiceInstanceId = reconfigurationParams.get("reconfiguration-params").get("service-instance-id").asText() + val pnfDetailsVnfId = reconfigurationParams.get("reconfiguration-params").get("vnf-id").asText() + + sendReconfigurationRequest(pnfDetailsServiceInstanceId, pnfDetailsVnfId) + } + else { + log.info("Run RanReconfiguration only for helm_free5gc") + } + log.info("RAN RECONFIGURATION - END") + } + + private suspend fun sendReconfigurationRequest(serviceInstanceId: String, vnfId: String){ + val executionServiceHandler: ExecutionServiceHandler = + this.functionDependencyInstanceAsType("executionServiceHandler") + + val executionServiceInput = ExecutionServiceInput() + //Common header + executionServiceInput.commonHeader = CommonHeader() + executionServiceInput.commonHeader.originatorId = "onap-me-cm-adapter" + executionServiceInput.commonHeader.requestId = "1" + executionServiceInput.commonHeader.subRequestId = "1" + //action identifiers + executionServiceInput.actionIdentifiers = ActionIdentifiers() + executionServiceInput.actionIdentifiers.blueprintName = "free5GC" + executionServiceInput.actionIdentifiers.blueprintVersion = "1.1.1" + executionServiceInput.actionIdentifiers.actionName = "ue-reconfiguration" + executionServiceInput.actionIdentifiers.mode = "sync" + //payload + val mapper = ObjectMapper() + val ueReconfigurationRequest = mapper.createObjectNode() + ueReconfigurationRequest.put("resolution-key","VF_ueransim_CNF") + val properties = mapper.createObjectNode() + properties.put("service-instance-id", serviceInstanceId) + properties.put("vnf-id", vnfId) + ueReconfigurationRequest.put("ue-reconfiguration-properties", properties) + + executionServiceInput.payload = mapper.createObjectNode() + executionServiceInput.payload.put("ue-reconfiguration-request", ueReconfigurationRequest) + log.info("Request body: ${executionServiceInput.asJsonString()}") + + val processResult = executionServiceHandler.doProcess(executionServiceInput) + log.info("Request result: ${processResult.asJsonString()}") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt new file mode 100644 index 00000000..8e4a58ab --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt @@ -0,0 +1,41 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.slf4j.LoggerFactory + +open class SimpleErrorCheck : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(SimpleErrorCheck::class.java)!! + + override fun getName(): String { + return "SimpleErrorCheck" + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("SIMPLE ERROR CHECK - START") + + log.info("SIMPLE ERROR CHECK - END") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt new file mode 100644 index 00000000..6356bf5e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt @@ -0,0 +1,82 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.K8sConnectionPluginConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.K8sPluginInstanceApi +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.instance.K8sRbInstanceStatus +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.slf4j.LoggerFactory + +open class SimpleStatusCheck : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(SimpleStatusCheck::class.java)!! + + override fun getName(): String { + return "SimpleStatusCheck" + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("SIMPLE STATUS CHECK - START") + + val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode + + val bluePrintPropertiesService: BluePrintPropertiesService = + this.functionDependencyInstanceAsType("bluePrintPropertiesService") + + val k8sConfiguration = K8sConnectionPluginConfiguration(bluePrintPropertiesService) + + val instanceApi = K8sPluginInstanceApi(k8sConfiguration) + + var checkCount: Int = 30 // in the future to be read in from the input + while (checkCount > 0) { + var continueCheck = false + configValueSetup.fields().forEach { it -> + val vfModuleName = it.key + val instanceName = it.value.get("k8s-instance-id").asText() + + val instanceStatus: K8sRbInstanceStatus? = instanceApi.getInstanceStatus(instanceName) + log.debug("Get status for ${vfModuleName} (${instanceName})") + if (!instanceStatus?.ready!!) { + continueCheck = true + log.info("VfModule ${vfModuleName} (${instanceName}) is not ready. Please wait...") + } + else { + log.info("VfModule ${vfModuleName} (${instanceName}) is ready.") + } + } + if (continueCheck) { + checkCount-- + if (checkCount == 0) + throw BluePrintException("Instance State verification failed") + Thread.sleep(10000L) + } else + checkCount = 0 + } + + log.info("SIMPLE STATUS CHECK - END") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/UeSubscription.kt b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/UeSubscription.kt new file mode 100644 index 00000000..a87f780d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Scripts/kotlin/UeSubscription.kt @@ -0,0 +1,94 @@ +/* + * Copyright © 2021 Orange + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.KotlinModule +import com.google.gson.Gson +import kotlinx.coroutines.delay +import net.minidev.json.JSONObject +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.error.catalog.core.logger +import org.slf4j.LoggerFactory +import org.springframework.http.HttpMethod +import java.lang.Thread.sleep + +open class UeSubscription : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(PnfRegistration::class.java)!! + + override fun getName(): String { + return "UeSubscription" + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("UE SUBSCRIPTION - START") + val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode + + configValueSetup.fields().forEach { it -> + if (it.key == "helm_ueransim"){ + try { + log.info("Sending UE Subscription request") + subscribeUe() + log.info("UE Subscribed") + } + catch (e: Exception) { + log.error("Error during request sending.") + } + } else { + log.info("Run UeSubscription only for helm_ueransim") + } + } + log.info("UE SUBSCRIPTION - END") + } + + private fun subscribeUe() { + val restClientProperties: BasicAuthRestClientProperties = BasicAuthRestClientProperties() + restClientProperties.url = "http://10.254.184.92:30500" + restClientProperties.username="" + restClientProperties.password="" + val restClientService: BasicAuthRestClientService = BasicAuthRestClientService(restClientProperties) + var result : BlueprintWebClientService.WebClientResponse? = null + + val payload = prepareRequestBody() + log.info("Request body: ${payload.toString()}") + result = restClientService.exchangeResource(HttpMethod.POST.name, + "/api/subscriber/imsi-208930000000003/20893", payload.toString()) + log.info(payload.toString()) + } + + private fun prepareRequestBody(): String { + val bodyString = "{\"plmnID\":\"20893\",\"ueId\":\"imsi-208930000000003\",\"AuthenticationSubscription\":{\"authenticationManagementField\":\"8000\",\"authenticationMethod\":\"5G_AKA\",\"milenage\":{\"op\":{\"encryptionAlgorithm\":0,\"encryptionKey\":0,\"opValue\":\"\"}},\"opc\":{\"encryptionAlgorithm\":0,\"encryptionKey\":0,\"opcValue\":\"8e27b6af0e692e750f32667a3b14605d\"},\"permanentKey\":{\"encryptionAlgorithm\":0,\"encryptionKey\":0,\"permanentKeyValue\":\"8baf473f2f8fd09487cccbd7097c6862\"},\"sequenceNumber\":\"16f3b3f70fc2\"},\"AccessAndMobilitySubscriptionData\":{\"gpsis\":[\"msisdn-0900000000\"],\"nssai\":{\"defaultSingleNssais\":[{\"sst\":1,\"sd\":\"010203\",\"isDefault\":true},{\"sst\":1,\"sd\":\"112233\",\"isDefault\":true}],\"singleNssais\":[]},\"subscribedUeAmbr\":{\"downlink\":\"2 Gbps\",\"uplink\":\"1 Gbps\"}},\"SessionManagementSubscriptionData\":[{\"singleNssai\":{\"sst\":1,\"sd\":\"010203\"},\"dnnConfigurations\":{\"internet\":{\"sscModes\":{\"defaultSscMode\":\"SSC_MODE_1\",\"allowedSscModes\":[\"SSC_MODE_2\",\"SSC_MODE_3\"]},\"pduSessionTypes\":{\"defaultSessionType\":\"IPV4\",\"allowedSessionTypes\":[\"IPV4\"]},\"sessionAmbr\":{\"uplink\":\"200 Mbps\",\"downlink\":\"100 Mbps\"},\"5gQosProfile\":{\"5qi\":9,\"arp\":{\"priorityLevel\":8},\"priorityLevel\":8}},\"internet2\":{\"sscModes\":{\"defaultSscMode\":\"SSC_MODE_1\",\"allowedSscModes\":[\"SSC_MODE_2\",\"SSC_MODE_3\"]},\"pduSessionTypes\":{\"defaultSessionType\":\"IPV4\",\"allowedSessionTypes\":[\"IPV4\"]},\"sessionAmbr\":{\"uplink\":\"200 Mbps\",\"downlink\":\"100 Mbps\"},\"5gQosProfile\":{\"5qi\":9,\"arp\":{\"priorityLevel\":8},\"priorityLevel\":8}}}},{\"singleNssai\":{\"sst\":1,\"sd\":\"112233\"},\"dnnConfigurations\":{\"internet\":{\"sscModes\":{\"defaultSscMode\":\"SSC_MODE_1\",\"allowedSscModes\":[\"SSC_MODE_2\",\"SSC_MODE_3\"]},\"pduSessionTypes\":{\"defaultSessionType\":\"IPV4\",\"allowedSessionTypes\":[\"IPV4\"]},\"sessionAmbr\":{\"uplink\":\"200 Mbps\",\"downlink\":\"100 Mbps\"},\"5gQosProfile\":{\"5qi\":9,\"arp\":{\"priorityLevel\":8},\"priorityLevel\":8}},\"internet2\":{\"sscModes\":{\"defaultSscMode\":\"SSC_MODE_1\",\"allowedSscModes\":[\"SSC_MODE_2\",\"SSC_MODE_3\"]},\"pduSessionTypes\":{\"defaultSessionType\":\"IPV4\",\"allowedSessionTypes\":[\"IPV4\"]},\"sessionAmbr\":{\"uplink\":\"200 Mbps\",\"downlink\":\"100 Mbps\"},\"5gQosProfile\":{\"5qi\":9,\"arp\":{\"priorityLevel\":8},\"priorityLevel\":8}}}}],\"SmfSelectionSubscriptionData\":{\"DnnInfosubscribedSnssaiInfos\":{\"01010203\":{\"dnnInfos\":[{\"dnn\":\"internet\"}]},\"01112233\":{\"dnnInfos\":[{\"dnn\":\"internet\"}]}}},\"AmPolicyData\":{\"subscCats\":[\"free5gc\"]},\"SmPolicyData\":{\"smPolicySnssaiData\":{\"01010203\":{\"snssai\":{\"sst\":1,\"sd\":\"010203\"},\"smPolicyDnnData\":{\"internet\":{\"dnn\":\"internet\"}}},\"01112233\":{\"snssai\":{\"sst\":1,\"sd\":\"112233\"},\"smPolicyDnnData\":{\"internet\":{\"dnn\":\"internet\"}}}}},\"FlowRules\":[]}" +// val bodyMap = Gson().fromJson>(bodyString, MutableMap::class.java) +// perform payload modifications if needed +// val bodyJson = Gson().toJson(bodyMap) + +// return bodyJson + return bodyString + } + +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/TOSCA-Metadata/TOSCA.meta b/tutorials/xNF_5G/free5gc/templates/cba/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 00000000..569719fe --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Samuli Silvius +Entry-Definitions: Definitions/free5GC.json +Template-Name: free5GC +Template-Version: 1.1.1 +Template-Type: DEFAULT +Template-Tags: Samuli Silvius, Lukasz Rajewski, Michal Chabiera, free5GC diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-mapping.json new file mode 100644 index 00000000..f2d73181 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-mapping.json @@ -0,0 +1,132 @@ +[ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vf-modules-list-sdnc", + "property": { + "description": "list of modules associated with vnf from MDSAL", + "type": "json" + }, + "input-param": false, + "dictionary-name": "vf-modules-list", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + }, + { + "name": "vf-modules-list-aai", + "property": { + "description": "list of modules associated with vnf from AAI", + "type": "json" + }, + "input-param": false, + "dictionary-name": "vf-modules-list", + "dictionary-source": "aai-data", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + }, + { + "name": "config-deploy-setup", + "property": { + "description": "configuration for config value setup", + "type": "json" + }, + "input-param": false, + "dictionary-name": "config-deploy-setup", + "dictionary-source": "capability", + "dependencies": [ + "vf-modules-list-aai", + "vf-modules-list-sdnc" + ] + }, + { + "name": "registration-reconfiguration-parameters", + "property": { + "description": "configuration for config value setup", + "type": "json" + }, + "input-param": false, + "dictionary-name": "registration-reconfiguration-parameters", + "dictionary-source": "capability", + "dependencies": [ + "pnf-details-aai", + "service-instance-id", + "vnf-id" + ] + }, + { + "name": "service-instance-name", + "property": { + "description": "Service instance name retrieved based on service instance id", + "type": "string" + }, + "input-param": false, + "dictionary-name": "service-instance-name", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id" + ] + }, + { + "name": "pnf-instance-name", + "property": { + "description": "PNF details stored in AAI", + "type": "string" + }, + "input-param": false, + "dictionary-name": "pnf-instance-name", + "dictionary-source": "capability", + "dependencies": [ + "service-instance-name", + "vf-modules-list-sdnc" + ] + }, + { + "name": "pnf-details-aai", + "property": { + "description": "PNF details stored in AAI", + "type": "json" + }, + "input-param": false, + "dictionary-name": "pnf-details-aai", + "dictionary-source": "aai-data", + "dependencies": [ + "pnf-instance-name" + ] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-template.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-template.vtl new file mode 100644 index 00000000..88771d61 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/config-setup-template.vtl @@ -0,0 +1 @@ +${config-deploy-setup} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-mapping.json new file mode 100644 index 00000000..63f5431b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-mapping.json @@ -0,0 +1,314 @@ +[ + { + "name": "vf-module-model-invariant-uuid", + "property": { + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-module-model-invariant-uuid", + "dictionary-source": "processor-db", + "dependencies": [ + "vf-module-model-customization-uuid" + ] + }, + { + "name": "vf-module-model-version", + "property": { + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-module-model-version", + "dictionary-source": "processor-db", + "dependencies": [ + "vf-module-model-customization-uuid" + ] + }, + { + "name": "vf-module-name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-name", + "dictionary-source": "rest", + "dependencies": [ + "vnf_name", + "vf-module-label", + "vf-naming-policy", + "vf-module-id" + ], + "version": 0 + }, + { + "name": "vnf_name", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vnf_name", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "service-instance-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vf-module-label", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-module-label", + "dictionary-source": "processor-db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vf-module-model-customization-uuid", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-module-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vf-module-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vf-module-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "k8s-rb-profile-namespace", + "property": { + "description": "K8s namespace to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "default" + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-namespace", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + }, + { + "name": "k8s-rb-profile-k8s-version", + "property": { + "description": "K8s cluster version to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "1.18.9" + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-k8s-version", + "dictionary-source": "sdnc", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + }, + { + "name": "k8s-rb-profile-name", + "property": { + "description": "RB Profile name used in k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string", + "required": false, + "default": "default" + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-name", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-instance-release-name", + "property": { + "description": "Name of the release for the helm package instance in k8s", + "type": "string", + "required": false, + "default": "base" + }, + "input-param": false, + "dictionary-name": "k8s-rb-instance-release-name", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-definition-name", + "property": { + "description": "RB Name identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-invariant-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-name", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-invariant-uuid" + ] + }, + { + "name": "k8s-rb-definition-version", + "property": { + "description": "RB Version identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-customization-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-version", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-customization-uuid" + ] + }, + { + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-config-template-name", + "property": { + "description": "The source of configuration template for ue-reconfiuration operation", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "k8s-rb-config-template-name", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-config-template-source", + "property": { + "description": "The source of configuration template for ue-reconfiuration operation", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "k8s-rb-config-template-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-config-name", + "property": { + "description": "The source of configuration values for ue-reconfiguration operation", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "k8s-rb-config-name", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-config-value-source", + "property": { + "description": "The source of configuration values for ue-reconfiguration operation", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "k8s-rb-config-value-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "core-instance-name", + "property": { + "description": "Name of 5g core instance that requires PNF registration", + "type": "string", + "required": false + }, + "input-param": false, + "dictionary-name": "core-instance-name", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-template.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-template.vtl new file mode 100644 index 00000000..1bebcaa0 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/free5gc-template.vtl @@ -0,0 +1,67 @@ +{ + "capability-data": [ + { + "capability-name": "aai-vf-module-put", + "key-mapping": [ + { + "output-key-mapping": [ + { + "resource-name": "aai-vf-module-put", + "resource-value": "" + } + ] + } + ] + } + ], + "resource-accumulator-resolved-data": [ + { + "param-name": "vnf_name", + "param-value": "${vnf_name}" + }, + { + "param-name": "vf-module-name", + "param-value": "${vf-module-name}" + }, +##RB name + { + "param-name": "vf-module-model-invariant-uuid", + "param-value": "${vf-module-model-invariant-uuid}" + }, +##RB version + { + "param-name": "vf-module-model-version", + "param-value": "${vf-module-model-version}" + }, +##Release name + { + "param-name": "k8s-rb-instance-release-name", + "param-value": "${k8s-rb-instance-release-name}" + }, +##Profile name + { + "param-name": "k8s-rb-profile-name", + "param-value": "${k8s-rb-profile-name}" + }, + { + "param-name": "k8s-rb-config-template-name", + "param-value": "${k8s-rb-config-template-name}" + }, + { + "param-name": "k8s-rb-config-template-source", + "param-value": "${k8s-rb-config-template-source}" + }, + { + "param-name": "k8s-rb-config-name", + "param-value": "${k8s-rb-config-name}" + }, + { + "param-name": "k8s-rb-config-value-source", + "param-value": "${k8s-rb-config-value-source}" + }, + { + "param-name": "core-instance-name", + "param-value": "${core-instance-name}" + } + ] +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc.tar.gz new file mode 100644 index 00000000..084711db Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/Chart.yaml new file mode 100644 index 00000000..d4ae1d91 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/Chart.yaml @@ -0,0 +1,50 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc +description: A Helm chart to deploy Free5gc +version: 1.0.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: deployMongoDB +- name: free5gc-amf + condition: deployAMF +- name: free5gc-ausf + condition: deployAUSF +- name: free5gc-n3iwf + condition: deployN3IWF +- name: free5gc-nrf + condition: deployNRF +- name: free5gc-nssf + condition: deployNSSF +- name: free5gc-pcf + condition: deployPCF +- name: free5gc-smf + condition: deploySMF +- name: free5gc-udm + condition: deployUDM +- name: free5gc-udr + condition: deployUDR +- name: free5gc-upf + condition: deployUPF +- name: free5gc-webui + condition: deployWEBUI +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/Chart.yaml new file mode 100644 index 00000000..ffe4483e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/Chart.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-nrf +description: A Helm chart to deploy the Free5GC NRF +type: application +version: 0.1.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: db.enabled +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/_helpers.tpl new file mode 100644 index 00000000..4e1ff610 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-nrf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-nrf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-nrf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-nrf.labels" -}} +helm.sh/chart: {{ include "free5gc-nrf.chart" . }} +{{ include "free5gc-nrf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-nrf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-nrf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +NRF Pod Annotations +*/}} +{{- define "free5gc-nrf.nrfAnnotations" -}} +{{- with .Values.nrf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml new file mode 100644 index 00000000..eb7eafd9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml @@ -0,0 +1,41 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + nrfcfg.yaml: | + info: + version: 1.0.0 + description: NRF initial local configuration + + configuration: + MongoDBName: free5gc + MongoDBUrl: mongodb://{{ $.Values.mongodb.service.name }}:{{ $.Values.mongodb.service.port }} + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ $.Values.global.nrf.service.name }} # IP used to serve NFs or register to another NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml new file mode 100644 index 00000000..f050e84f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml @@ -0,0 +1,109 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-nrf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-nrf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-nrf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-nrf.nrfAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/nrf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-nrf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-mongo + {{- with $.Values.initcontainers.busybox }} + image: {{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + {{- with $.Values.mongodb.service }} + value: {{ .name }}:{{ .port }} + {{- end }} + command: ["sh", "-c", "until nc -z $DEPENDENCIES; do echo waiting for the MongoDB; sleep 2; done;"] + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ $.Values.global.nrf.service.port }} + command: ["./nrf"] + args: ["-nrfcfg", "../config/nrfcfg.yaml"] + env: + - name: DB_URI + value: mongodb://{{ $.Values.mongodb.service.name }}/free5gc + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + readinessProbe: + initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .readinessProbe.periodSeconds }} + timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} + failureThreshold: {{ .readinessProbe.failureThreshold }} + successThreshold: {{ .readinessProbe.successThreshold }} + httpGet: + scheme: {{ $.Values.global.sbi.scheme | quote | upper }} + port: {{ $.Values.global.nrf.service.port }} + livenessProbe: + initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .livenessProbe.periodSeconds }} + timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} + failureThreshold: {{ .livenessProbe.failureThreshold }} + successThreshold: {{ .livenessProbe.successThreshold }} + httpGet: + scheme: {{ $.Values.global.sbi.scheme | quote | upper }} + port: {{ $.Values.global.nrf.service.port }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/values.yaml new file mode 100644 index 00000000..8d686b83 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/charts/free5gc-nrf/values.yaml @@ -0,0 +1,134 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +db: + enabled: true +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + fullnameOverride: "mongodb" + useStatefulSet: true + auth: + enabled: false + persistence: + size: 6Gi + mountPath: /bitnami/mongodb/data/db/ + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +nrf: + name: nrf + replicaCount: 1 + image: + name: towards5gs/free5gc-nrf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: nrf-configmap + volume: + name: nrf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + DefaultPlmnId: + mcc: 208 + mnc: 93 + serviceNameList: + - nnrf-nfm + - nnrf-disc + logger: + NRF: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + MongoDBLibrary: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/values.yaml new file mode 100644 index 00000000..bef4c741 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/free5gc/values.yaml @@ -0,0 +1,125 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gc-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + name: free5gc + userPlaneArchitecture: single # possible values are "single" and "ulcl" + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 + service: + ngap: + enabled: false + name: amf-n2 + port: 38412 + nodeport: 38412 + protocol: SCTP + type: NodePort + smf: + n4if: + ipAddress: 10.100.50.244 + upf: + n6if: + ipAddress: 192.169.110.112 + service: + enabled: false + name: upf-service + type: NodePort + protocol: UDP + port: 21522 + nodeport: 2152 + + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + n4network: + name: n4network + masterIf: eth0 + subnetIP: 10.100.50.240 + cidr: 29 + gatewayIP: 10.100.50.246 + excludeIP: 10.100.50.246 + n6network: + name: n6network + masterIf: eth1 + subnetIP: 192.169.110.0 + cidr: 24 + gatewayIP: 192.169.110.1 + excludeIP: 192.169.110.254 + n9network: + name: n9network + masterIf: eth0 + subnetIP: 10.100.50.224 + cidr: 29 + gatewayIP: 10.100.50.230 + excludeIP: 10.100.50.230 + + +# These parameters can be used to enable/disable deployment of subcharts +deployMongoDB: true +deployAMF: true +deployAUSF: true +deployN3IWF: true +deployNRF: true +deployNSSF: true +deployPCF: true +deploySMF: true +deployUDM: true +deployUDR: true +deployUPF: true +deployWEBUI: true + +# Disable the deployment of mongodb as an NRF subchart +free5gc-nrf: + db: + enabled: false + nrf: + replicaCount: 1 + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + fullnameOverride: "mongodb" + useStatefulSet: true + auth: + enabled: false + persistence: + size: 6Gi + mountPath: /bitnami/mongodb/data/db/ + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values-mapping.json new file mode 100644 index 00000000..4423c710 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values-mapping.json @@ -0,0 +1,14 @@ +[ + { + "name": "replica-count", + "property": { + "description": "Number of replicas for scaling", + "type": "integer", + "default": 2 + }, + "input-param": false, + "dictionary-name": "replica-count", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml new file mode 100644 index 00000000..f73645f2 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml @@ -0,0 +1,3 @@ +free5gc-nrf: + nrf: + replicaCount: 4 diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml.vtl new file mode 100644 index 00000000..a954411d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/nrf-scaling/values.yaml.vtl @@ -0,0 +1,3 @@ +free5gc-nrf: + nrf: + replicaCount: ${replica-count} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/Chart.yaml new file mode 100644 index 00000000..e334320f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart to deploy ssh service for vPGN +name: ssh_service +version: 0.1.0 diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/ssh-service-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/ssh-service-mapping.json new file mode 100644 index 00000000..4fd287fc --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/ssh-service-mapping.json @@ -0,0 +1,14 @@ +[ + { + "name": "vpg-management-port", + "property": { + "description": "The number of node port for ssh service of vpg", + "type": "integer", + "default": 31922 + }, + "input-param": false, + "dictionary-name": "vpg-management-port", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/templates/ssh-service-template.yaml.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/templates/ssh-service-template.yaml.vtl new file mode 100644 index 00000000..3dc2eb5f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/templates/ssh-service-template.yaml.vtl @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.vpg_name_0 }}-ssh + labels: + vnf-name: {{ .Values.vnf_name }} + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }} +spec: + type: NodePort + ports: + - port: 22 + nodePort: ${vpg-management-port} + selector: + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/values.yaml new file mode 100644 index 00000000..5b46bd96 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-config/values.yaml @@ -0,0 +1,3 @@ +vnf_name: test-vnf +vpg_name_0: test-vnf-vpg +vpg_management_port: 31922 diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/ssh-service-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/ssh-service-mapping.json new file mode 100644 index 00000000..4fd287fc --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/ssh-service-mapping.json @@ -0,0 +1,14 @@ +[ + { + "name": "vpg-management-port", + "property": { + "description": "The number of node port for ssh service of vpg", + "type": "integer", + "default": 31922 + }, + "input-param": false, + "dictionary-name": "vpg-management-port", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/values.yaml.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/values.yaml.vtl new file mode 100644 index 00000000..f636e8f3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service-values/values.yaml.vtl @@ -0,0 +1,3 @@ +vnf_name: test-vnf +vpg_name_0: test-vnf-vpg +vpg_management_port: ${vpg-management-port} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service.tar.gz new file mode 100644 index 00000000..a8d643bb Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ssh-service.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/Makefile b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/Makefile new file mode 100644 index 00000000..88f27ee7 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/Makefile @@ -0,0 +1,9 @@ +.PHONY: all clean prepare + +all: prepare + +prepare: + tar -czvf ueransim.tar.gz ueransim + +clean: + rm -f ueransim.tar.gz \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim.tar.gz new file mode 100644 index 00000000..54063286 Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/Chart.yaml new file mode 100644 index 00000000..e02f2aca --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/Chart.yaml @@ -0,0 +1,23 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: ueransim +description: A Helm chart to deploy UERANSIM +version: 2.0.0 +appVersion: v3.1.3 +icon: https://raw.githubusercontent.com/aligungr/UERANSIM/master/.github/logo.png +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/README.md b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/README.md new file mode 100644 index 00000000..8f90283e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/README.md @@ -0,0 +1,157 @@ +# UERANSIM Helm chart + +This is a Helm chart for deploying [UERANSIM](https://github.com/aligungr/UERANSIM) on Kubernetes. It has been tested only with [free5GC](../chart/free5gc) but should also run with [open5gs](https://github.com/open5gs/open5gs). + +## Prerequisites + - A Kubernetes cluster ready to use. You can use [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/) to create it. + - [Multus-CNI](https://github.com/intel/multus-cni). + - [Helm3](https://helm.sh/docs/intro/install/). + - [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (optional). + - A physical network interface on each Kubernetes node named `eth0`. +**Note:** If the name of network interfaces on your Kubernetes nodes is different from `eth0`, see [Networks configuration](#networks-configuration). + +## Quickstart guide + +### Install UERANSIM +```console +kubectl create ns +helm -n install ./ueransim/ +``` + +Note that if you have already installed the N3iwf on the same cluster, you should disable the creation of the N2 network as it has already been created for the N3iwf. +```console +helm -n install --set global.n2network.enabled=false ./ueransim/ +``` + +### Check the state of the created pod +```console +kubectl -n get pods -l "app=ueransim" +``` + +### Uninstall UERANSIM +```console +helm -n delete +``` +Or... +```console +helm -n uninstall +``` + +## Configuration + +### Testing with another 5G core network +This Helm chart has been tested only with [free5GC](../chart/free5gc) but should also run with [open5gs](https://github.com/open5gs/open5gs). If you want to test it with open5gs then you should only use the `open5gs-values.yaml` file to override the Helm chart default values. +```console +helm -n install -f ./ueransim/open5gs-values.yaml ./ueransim/ +``` + + +### Networks configuration +In this section, we'll suppose that you have at least one interface on each Kubernetes node and its name is `toto`. Then you have to set these parameters to `toto`: + - `global.n2network.masterIf` + - `global.n4network.masterIf` +Please see [NETWORKS5G's README](../networks5g) for more details. + +## Usage information +Once this helm chart installed, a PDU session will be crated automatically. Furthermore, a TUN interface will be created on the UE POD. This interface can be used to test the connectivity: +```console +kubectl -n exec -it -- bash +``` +Whithin the POD: + - Verify that the TUN interface has been created. Its name should be `uesimtun0`. +```console +ip address +... +5: uesimtun0: mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500 + link/none + inet 10.1.0.1/32 scope global uesimtun0 + valid_lft forever preferred_lft forever +``` + - Use the TUN interface. +```console +ping -I uesimtun0 www.google.com +traceroute -i uesimtun0 www.google.com +curl --interface uesimtun0 www.google.com +``` + +## Customized installation +This chart allows you to customize its installation. The table below shows the parameters that can be modified before installing the chart or when upgrading it as well as their default values. + +### Global parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.multiCluster` | Must be set to `true` if you are deploying the the N3IWF in a different cluster from the one where the control plane is deployed and `global.amf.service.ngap.enabled` is set to true. | `false` | +| `global.cpClusterIP` | The IP address of one of the cluster nodes where the control plane is deployed. | `nil` | + +| `global.amf.service.ngap.name` | The name of the AMF NGAP service. | `amf-n2` | +| `global.amf.service.ngap.type` | The type of the AMF NGAP service. | `ClusterIP` | +| `global.amf.service.ngap.port` | The AMF NGAP port number. | `38412` | +| `global.amf.service.ngap.nodeport` | The nodePort number to access the AMF NGAP service from outside of cluster. | `31412` | +| `global.amf.service.ngap.protocol` | The protocol used for this service. | `SCTP` | +| `global.gnb.n3if.IpAddress` | The IP address of the UERANSIM’s N3 interface. | `10.100.50.233` | + +### N2 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n2network.name` | N2 network name. | `n2network` | +| `global.n2network.masterIf` | N2 network MACVLAN master interface. | `eth0` | +| `global.n2network.subnetIP` | N2 network subnet IP address. | `10.100.50.248` | +| `global.n2network.cidr` | N2 network cidr. | `29` | +| `global.n2network.gatewayIP` | N2 network gateway IP address. | `10.100.50.254` | + +### N3 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n3network.name` | N3 network name. | `n3network` | +| `global.n3network.masterIf` | N3 network MACVLAN master interface. | `eth0` | +| `global.n3network.subnetIP` | N3 network subnet IP address. | `10.100.50.232` | +| `global.n3network.cidr` | N3 network cidr. | `29` | +| `global.n3network.gatewayIP` | N3 network gateway IP address. | `10.100.50.238` | + +### Main chart parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `projectName` | The name of UERANSIM application (used in labels). | `ueransim` | + +### gNB parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `gnb.enabled` | If `true` then deploy the UERANSIM gNB. | `true` | +| `gnb.name` | Th name of the gNB (used in labels and when naming the deployment). | `gnb` | +| `gnb.replicaCount` | The number of gNB replicas | `1` | +| `gnb.image.name` | The gNB Docker image name. | `towards5gs/ueransim-gnb` | +| `gnb.image.tag` | The gNB Docker image tag. | `defaults to the chart AppVersion` | +| `gnb.configmap.name` | The name of the configmap to be used to import the configuration to the gNB POD. | `gnb-configmap` | +| `gnb.volume.name` | The name of the volume to be mounted to the gNB POD. | `gnb-volume` | +| `gnb.volume.mount` | The path to the folder where configuration files should be mounted on the gNB POD. | `/ueransim/config` | +| `gnb.service.name` | The name of the service to expose the RADIO interface. | `gnb-service` | +| `gnb.service.type` | The type of the service to expose the RADIO interface. | `ClusterIP` | +| `gnb.service.port` | The port number used for the RADIO interface. | `4997` | +| `gnb.service.protocol` | The protocol used for the RADIO interface. | `UDP` | +| `gnb.configuration` | The UERANSIM gNB [configuration](https://github.com/aligungr/UERANSIM/wiki/Configuration#gnb-configuration) in YAML format. | Check [values.yaml](./values.yaml) | +| `gnb.ipAddress`| The IP address of gNB’s N2 interface. | `10.100.50.250` | +| `gnb.amf.n2if.IpAddress` | The IP address of the AMF’s N2 interface. | `10.100.50.249` | +| `gnb.amf.service.ngap.enabled` | If `true` then a Kubernetes service will be used to access the AMF NGAP service instead of accessing directly the AMF’s N2 interface. `gnb.amf.n2if.IpAddress` must be set to the name of the service or IP address of a node where AMF is deployed. | `false` | + +### UE parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `ue.enabled` | If `true` then deploy the UERANSIM UE. | `true` | +| `ue.name` | Th name of the UE (used in labels and when naming the deployment). | `ue` | +| `ue.replicaCount` | The number of UE replicas | `1` | +| `ue.image.name` | The UE Docker image name. | `towards5gs/ueransim-ue` | +| `ue.image.tag` | The UE Docker image tag. | `defaults to the chart AppVersion` | +| `ue.configmap.name` | The name of the configmap to be used to import the configuration to the UE POD. | `ue-configmap` | +| `ue.volume.name` | The name of the volume to be mounted to the UE POD. | `ue-volume` | +| `ue.volume.mount` | The path to the folder where configuration files should be mounted on the UE POD. | `/ueransim/config` | +| `ue.configuration` | The UERANSIM UE [configuration](https://github.com/aligungr/UERANSIM/wiki/Configuration#ue-configuration) in YAML format. | Check [values.yaml](./values.yaml) | +| `ue.command` | The command to be executed to run the UERANSIM UE. | `"../build/nr-ue -c ./ue-config.yaml"` | +| `ue.script` | A script to be executed after running the UERANSIM UE. It may be used to periodically generate traffic for example. | `""` | + +## Reference + - https://github.com/aligungr/UERANSIM/wiki/ + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/_helpers.tpl new file mode 100644 index 00000000..073f25c6 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/_helpers.tpl @@ -0,0 +1,87 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "ueransim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ueransim.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "ueransim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ueransim.labels" -}} +helm.sh/chart: {{ include "ueransim.chart" . }} +{{ include "ueransim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ueransim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ueransim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +gNB Pod Annotations +*/}} +{{- define "ueransim.gnbAnnotations" -}} +{{- with .Values.gnb }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +UE Pod Annotations +*/}} +{{- define "ueransim.ueAnnotations" -}} +{{- with .Values.ue }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/gnb/gnb-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/gnb/gnb-deployment.yaml new file mode 100644 index 00000000..e56870bb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/templates/gnb/gnb-deployment.yaml @@ -0,0 +1,90 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.gnb }} +{{- if and .enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ueransim.fullname" $ }}-{{ .name }} + labels: + {{- include "ueransim.labels" $ | nindent 4 }} + app: {{ $.Values.projectName }} + component: {{ .name }} +spec: + selector: + matchLabels: + {{- include "ueransim.selectorLabels" $ | nindent 6 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + replicas: {{ .replicaCount }} + template: + metadata: + labels: + {{- include "ueransim.selectorLabels" $ | nindent 8 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + annotations: + {{- include "ueransim.gnbAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + {{- if not .amf.service.ngap.enabled }} + { "name": "{{ $.Values.global.n2network.name }}-{{ include "ueransim.fullname" $ }}", + "interface": "n2", + "ips": [ "{{ .n2if.ipAddress }}/{{ $.Values.global.n2network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n2network.gatewayIP }}" ] + }, + {{- end }} + { "name": "{{ $.Values.global.n3network.name }}-{{ include "ueransim.fullname" $ }}", + "interface": "n3", + "ips": [ "{{ .n3if.ipAddress }}/{{ $.Values.global.n3network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n3network.gatewayIP }}" ] + } + ]' + + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + name: {{ .name }} + imagePullPolicy: {{ .image.pullPolicy }} + ports: + - name: gnb-ue + containerPort: {{ .service.port }} + protocol: {{ .service.protocol }} + securityContext: + capabilities: + add: ["NET_ADMIN"] + command: ["./nr-gnb"] + args: ["-c", "{{ .volume.mount }}/gnb-config.yaml"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + configMap: + name: {{ .configmap.name }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/values.yaml new file mode 100644 index 00000000..b4f97f9f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/ueransim/values.yaml @@ -0,0 +1,177 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for ueransim-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + multiCluster: false + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + + +projectName: ueransim + +gnb: + enabled: true + name: gnb + replicaCount: 1 + image: + name: towards5gs/ueransim-gnb + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: gnb-configmap + volume: + name: gnb-volume + mount: /ueransim/config + service: + name: gnb-service + type: ClusterIP + port: 4997 + protocol: UDP + + n2if: # NGAP + ipAddress: 10.100.50.250 + n3if: # GTP-U + ipAddress: 10.100.50.236 + + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 #amf-n2 + port: 38412 + service: + ngap: + enabled: true # if true set gnb.amf.n2if.ipAddress to the name of AMF NGAP service or the IP of the cluster hosting the AMF + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + resources: + limits: + cpu: 250m + memory: 256Mi + requests: + cpu: 250m + memory: 256Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + nci: '0x000000010' # NR Cell Identity (36-bit) + idLength: 32 # NR gNB ID length in bits [22...32] + tac: 1 # Tracking Area Code + # List of supported S-NSSAIs by this gNB + slices: + - sst: 0x1 + sd: 0x010203 + # Indicates whether or not SCTP stream number errors should be ignored. + ignoreStreamIds: true +ue: + enabled: true + name: ue + replicaCount: 1 + image: + name: towards5gs/ueransim-ue + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: ue-configmap + volume: + name: ue-volume + mount: /ueransim/config + command: "./nr-ue -c ../config/ue-config.yaml" # This is the command that will be launched in the UE container + # A script that will be run after the UE creation. It may be used to periodically generate traffic + script: "" + # script: |- + # ping ..... + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 120m + memory: 128Mi + requests: + cpu: 120m + memory: 128Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + supi: "imsi-208930000000003" # IMSI number + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + key: "8baf473f2f8fd09487cccbd7097c6862" # Operator code (OP or OPC) of the UE + op: "8e27b6af0e692e750f32667a3b14605d" # This value specifies the OP type and it can be either 'OP' or 'OPC' + opType: "OPC" # This value specifies the OP type and it can be either 'OP' or 'OPC' + amf: '8000' # Authentication Management Field (AMF) value + imei: '356938035643803' # IMEI number of the device + imeiSv: '4370816125816151' + sessions: + - type: "IPv4" + apn: "internet" + slice: + sst: 0x01 + sd: 0x010203 + # Configured NSSAI for this UE by HPLMN + configured-nssai: + - sst: 0x01 + sd: 0x010203 + # Default Configured NSSAI for this UE + default-nssai: + - sst: 1 + sd: 1 + # Supported encryption and integrity algorithms by this UE + integrity: + IA1: true + IA2: true + IA3: true + ciphering: + EA1: true + EA2: true + EA3: true + + test: + connectivity: + name: ue-connectivity-test + image: bitnami/kubectl:1.22.0 + configmap: + name: connectivity-test-configmap + volume: + name: connectivity-test-volume + mount: /scripts + ttlseconds: 100 diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/values.yaml new file mode 100644 index 00000000..935e2955 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-configs/ue-reconfiguration/values.yaml @@ -0,0 +1,3 @@ +gnb: + image: + pullPolicy: Always diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile.tar.gz new file mode 100644 index 00000000..91fb7cd7 Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/manifest.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/manifest.yaml new file mode 100644 index 00000000..4d381d02 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/manifest.yaml @@ -0,0 +1,4 @@ +--- +version: v1 +type: + values: "override_values.yaml" diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/override_values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/override_values.yaml new file mode 100644 index 00000000..9513e308 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/free5gc-cnf-cds-base-profile/override_values.yaml @@ -0,0 +1,123 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gc-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + name: free5gc + userPlaneArchitecture: single # possible values are "single" and "ulcl" + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 + service: + ngap: + enabled: false + name: amf-n2 + port: 38412 + nodeport: 38412 + protocol: SCTP + type: NodePort + smf: + n4if: + ipAddress: 10.100.50.244 + upf: + n6if: + ipAddress: 192.169.110.112 + service: + enabled: false + name: upf-service + type: NodePort + protocol: UDP + port: 21522 + nodeport: 2152 + + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + n4network: + name: n4network + masterIf: eth0 + subnetIP: 10.100.50.240 + cidr: 29 + gatewayIP: 10.100.50.246 + excludeIP: 10.100.50.246 + n6network: + name: n6network + masterIf: eth1 + subnetIP: 192.169.110.0 + cidr: 24 + gatewayIP: 192.169.110.1 + excludeIP: 192.169.110.254 + n9network: + name: n9network + masterIf: eth0 + subnetIP: 10.100.50.224 + cidr: 29 + gatewayIP: 10.100.50.230 + excludeIP: 10.100.50.230 + + +# These parameters can be used to enable/disable deployment of subcharts +deployMongoDB: true +deployAMF: true +deployAUSF: true +deployN3IWF: true +deployNRF: true +deployNSSF: true +deployPCF: true +deploySMF: true +deployUDM: true +deployUDR: true +deployUPF: true +deployWEBUI: true + +# Disable the deployment of mongodb as an NRF subchart +free5gc-nrf: + db: + enabled: false + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + fullnameOverride: "mongodb" + useStatefulSet: true + auth: + enabled: false + persistence: + size: 6Gi + mountPath: /bitnami/mongodb/data/db/ + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile.tar.gz new file mode 100644 index 00000000..2cff551a Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/manifest.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/manifest.yaml new file mode 100644 index 00000000..4d381d02 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/manifest.yaml @@ -0,0 +1,4 @@ +--- +version: v1 +type: + values: "override_values.yaml" diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/override_values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/override_values.yaml new file mode 100644 index 00000000..e5d5a123 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/ueransim-cnf-cds-base-profile/override_values.yaml @@ -0,0 +1,177 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for ueransim-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + multiCluster: false + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + + +projectName: ueransim + +gnb: + enabled: true + name: gnb + replicaCount: 1 + image: + name: towards5gs/ueransim-gnb + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: gnb-configmap + volume: + name: gnb-volume + mount: /ueransim/config + service: + name: gnb-service + type: ClusterIP + port: 4997 + protocol: UDP + + n2if: # NGAP + ipAddress: 10.100.50.250 + n3if: # GTP-U + ipAddress: 10.100.50.236 + + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 #amf-n2 + port: 38412 + service: + ngap: + enabled: false # if true set gnb.amf.n2if.ipAddress to the name of AMF NGAP service or the IP of the cluster hosting the AMF + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + resources: + limits: + cpu: 250m + memory: 256Mi + requests: + cpu: 250m + memory: 256Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + nci: '0x000000010' # NR Cell Identity (36-bit) + idLength: 32 # NR gNB ID length in bits [22...32] + tac: 1 # Tracking Area Code + # List of supported S-NSSAIs by this gNB + slices: + - sst: 0x1 + sd: 0x010203 + # Indicates whether or not SCTP stream number errors should be ignored. + ignoreStreamIds: true +ue: + enabled: true + name: ue + replicaCount: 1 + image: + name: towards5gs/ueransim-ue + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: ue-configmap + volume: + name: ue-volume + mount: /ueransim/config + command: "./nr-ue -c ../config/ue-config.yaml" # This is the command that will be launched in the UE container + # A script that will be run after the UE creation. It may be used to periodically generate traffic + script: "" + # script: |- + # ping ..... + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 120m + memory: 128Mi + requests: + cpu: 120m + memory: 128Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + supi: "imsi-208930000000003" # IMSI number + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + key: "8baf473f2f8fd09487cccbd7097c6862" # Operator code (OP or OPC) of the UE + op: "8e27b6af0e692e750f32667a3b14605d" # This value specifies the OP type and it can be either 'OP' or 'OPC' + opType: "OPC" # This value specifies the OP type and it can be either 'OP' or 'OPC' + amf: '8000' # Authentication Management Field (AMF) value + imei: '356938035643803' # IMEI number of the device + imeiSv: '4370816125816151' + sessions: + - type: "IPv4" + apn: "internet" + slice: + sst: 0x01 + sd: 0x010203 + # Configured NSSAI for this UE by HPLMN + configured-nssai: + - sst: 0x01 + sd: 0x010203 + # Default Configured NSSAI for this UE + default-nssai: + - sst: 1 + sd: 1 + # Supported encryption and integrity algorithms by this UE + integrity: + IA1: true + IA2: true + IA3: true + ciphering: + EA1: true + EA2: true + EA3: true + + test: + connectivity: + name: ue-connectivity-test + image: bitnami/kubectl:1.22.0 + configmap: + name: connectivity-test-configmap + volume: + name: connectivity-test-volume + mount: /scripts + ttlseconds: 100 diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-base-profile.tar.gz b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-base-profile.tar.gz new file mode 100644 index 00000000..ee8465cd Binary files /dev/null and b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-base-profile.tar.gz differ diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml new file mode 100644 index 00000000..adb9f86c --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml @@ -0,0 +1,7 @@ +--- +version: v1 +type: + values: "override_values.yaml" + configresource: + - filepath: ssh-service-template.yaml + chartpath: vpkg/templates/ssh-service-template.yaml diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml @@ -0,0 +1 @@ + diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json new file mode 100644 index 00000000..d5ab945f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json @@ -0,0 +1,14 @@ +[ + { + "name": "vpg-management-port", + "property": { + "description": "The number of node port for ssh service of vpg", + "type": "integer", + "default": 0 + }, + "input-param": false, + "dictionary-name": "vpg-management-port", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl new file mode 100644 index 00000000..3dc2eb5f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.vpg_name_0 }}-ssh + labels: + vnf-name: {{ .Values.vnf_name }} + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }} +spec: + type: NodePort + ports: + - port: 22 + nodePort: ${vpg-management-port} + selector: + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-mapping.json b/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-mapping.json new file mode 100644 index 00000000..a049e452 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-mapping.json @@ -0,0 +1,104 @@ +[ + { + "name": "vnf-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "vnf_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf_name", + "dictionary-source": "rest", + "dependencies": [ + "aic-cloud-region", + "vf-naming-policy", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": false, + "type": "string", + "default": "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "default", + "dependencies": [], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "service-instance-id", + "property": { + "description": "", + "required": false, + "type": "string" + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + }, + { + "name": "k8s-rb-profile-namespace", + "property": { + "description": "K8s namespace to create helm chart for specified profile", + "type": "string", + "default": "default" + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-namespace", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-profile-k8s-version", + "property": { + "description": "K8s cluster version to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "1.18.9" + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-k8s-version", + "dictionary-source": "default", + "dependencies": [] + } +] diff --git a/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-template.vtl b/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-template.vtl new file mode 100644 index 00000000..3e5ad195 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/Templates/vnf-template.vtl @@ -0,0 +1,22 @@ +{ + "capability-data": [ + ], + "resource-accumulator-resolved-data": [ + { + "param-name": "vnf_name", + "param-value": "${vnf_name}" + }, + { + "param-name": "vf-naming-policy", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "k8s-rb-profile-namespace", + "param-value": "${k8s-rb-profile-namespace}" + }, + { + "param-name": "k8s-rb-profile-k8s-version", + "param-value": "${k8s-rb-profile-k8s-version}" + } + ] +} diff --git a/tutorials/xNF_5G/free5gc/templates/cba/pom.xml b/tutorials/xNF_5G/free5gc/templates/cba/pom.xml new file mode 100644 index 00000000..c4116025 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba/pom.xml @@ -0,0 +1,68 @@ + + + + + 4.0.0 + + + org.onap.ccsdk.cds.components.cba + test-blueprint-kotlin-parent + 1.1.4-SNAPSHOT + + + free5gc + 1.1.4-SNAPSHOT + pom + + + + ccsdkapps + ccsdkapps + + + + + + org.onap.ccsdk.cds.blueprintsprocessor.modules + processor-core + 1.1.4-SNAPSHOT + compile + + + org.onap.ccsdk.cds.blueprintsprocessor.functions + k8s-connection-plugin + 1.1.4-SNAPSHOT + compile + + + com.att.aft + dme2 + 3.1.200-oss + compile + + + org.onap.ccsdk.cds.blueprintsprocessor.modules + selfservice-api + + + diff --git a/tutorials/xNF_5G/free5gc/templates/cba2dd.py b/tutorials/xNF_5G/free5gc/templates/cba2dd.py new file mode 100644 index 00000000..02cf6085 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/cba2dd.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# COPYRIGHT NOTICE STARTS HERE + +# Copyright 2020 . Samsung Electronics Co., Ltd. +# +# 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 NOTICE ENDS HERE + +import os +import argparse +import json + +# +# Script to convert given Enriched CDS CBA model to Data Dictionary output +# Usage: +# ./cba2dd.py --cba_dir | python3 -m json.tool +# + +def get_resources_definition_file(cba_dir): + definitions_dir = cba_dir + os.sep + "Definitions" + resource_definition_file = definitions_dir + os.sep + "resources_definition_types.json" + if not os.path.exists(definitions_dir): + raise RuntimeError("'%s' directory does not exists or is not CBA directory" % cba_dir) + if not os.path.exists(resource_definition_file): + raise RuntimeError("'%s' file does not exists in CBA Definitions directory. CBA is not Enriched!" % resource_definition_file) + return resource_definition_file + +def create_dd(cba_dir): + with open(get_resources_definition_file(cba_dir)) as f: + output_json = json.load(f) + dd = [] + for _, entry in output_json.items(): + dd.append(build_dd_entry(entry)) + print(json.dumps(dd)) + +def build_dd_entry(definition_entry): + """Builds Data Dictionary entry from given dictionary entry. Given entry + itself is added as value for "definition" key. + { + "name": "", + "tags": "", + "data_type": "", + "description": "", + "entry_schema": "", + "updatedBy": "", + "definition": definition_entry + } + """ + out_dict = {} + out_dict["name"] = definition_entry["name"] + out_dict["tags"] = definition_entry["tags"] + out_dict["data_type"] = definition_entry["property"]["type"] + out_dict["description"] = definition_entry["property"]["description"] + out_dict["entry_schema"] = definition_entry["property"]["type"] + out_dict["updatedBy"] = definition_entry["updated-by"] + out_dict["definition"] = definition_entry + return out_dict + +def main(): + description = """Script to convert given Enriched CDS CBA model to Data Dictionary output. +Example: + ./cba2dd.py --cba_dir cba | python3 -m json.tool + """ + parser = argparse.ArgumentParser(description=description, + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument('--cba_dir', + help='Path to CDS CBA model main directory', + default='') + args = parser.parse_args() + try: + create_dd(args.cba_dir) + except Exception as e: + print(e) + parser.print_help() + exit(1) + +if __name__ == '__main__': + main() diff --git a/tutorials/xNF_5G/free5gc/templates/helm/.gitignore b/tutorials/xNF_5G/free5gc/templates/helm/.gitignore new file mode 100644 index 00000000..17d6b367 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/.gitignore @@ -0,0 +1 @@ +/*.tgz diff --git a/tutorials/xNF_5G/free5gc/templates/helm/Makefile b/tutorials/xNF_5G/free5gc/templates/helm/Makefile new file mode 100644 index 00000000..3f7f22fb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/Makefile @@ -0,0 +1,18 @@ +vf-modules = free5gc +.PHONY: build clean $(vf-modules:=-build) $(vf-modules:-clean) $(vf-modules:=-package) + +package: $(vf-modules:=-package) +build: $(vf-modules:=-build) +clean: $(vf-modules:=-clean) + +$(vf-modules:=-package): %-package: %-build + mv $(@:package=)*.tgz helm_$(@:-package=).tgz + cp helm_$(@:-package=).tgz $(@:-package=)_cloudtech_k8s_charts.tgz + +$(vf-modules:=-build): %-build: %-clean + helm package $(@:-build=) + +$(vf-modules:=-clean): + rm -f $(@:-clean=)-*.tgz + rm -f helm_$(@:-clean=).tgz + rm -f $(@:-clean=)_cloudtech_k8s_charts.tgz diff --git a/tutorials/xNF_5G/free5gc/templates/helm/README.txt b/tutorials/xNF_5G/free5gc/templates/helm/README.txt new file mode 100644 index 00000000..63429e91 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/README.txt @@ -0,0 +1,7 @@ +Helm content of onboarding package + +To create necessary archives, please ensure you have [helm] and [make] installed first. + +In case it's your first time you're using helm, please issue `helm init -c` command to initialize your helm client + +To create necessary artifacts, issue `make` command diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/Chart.yaml new file mode 100644 index 00000000..d4ae1d91 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/Chart.yaml @@ -0,0 +1,50 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc +description: A Helm chart to deploy Free5gc +version: 1.0.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: deployMongoDB +- name: free5gc-amf + condition: deployAMF +- name: free5gc-ausf + condition: deployAUSF +- name: free5gc-n3iwf + condition: deployN3IWF +- name: free5gc-nrf + condition: deployNRF +- name: free5gc-nssf + condition: deployNSSF +- name: free5gc-pcf + condition: deployPCF +- name: free5gc-smf + condition: deploySMF +- name: free5gc-udm + condition: deployUDM +- name: free5gc-udr + condition: deployUDR +- name: free5gc-upf + condition: deployUPF +- name: free5gc-webui + condition: deployWEBUI +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/README.md b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/README.md new file mode 100644 index 00000000..84fe841b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/README.md @@ -0,0 +1,195 @@ +# free5gc Helm chart + +This is a Helm chart for deploying the [free5GC](https://github.com/free5gc/free5gc)-v3.0.5 on Kubernetes. Tt can be used to deploy the following Helm charts: + - [free5gc-amf](charts/free5gc-amf). + - [free5gc-ausf](charts/free5gc-ausf). + - [free5gc-n3iwf](charts/free5gc-n3iwf). + - [free5gc-nrf](charts/free5gc-nrf). + - [free5gc-nssf](charts/free5gc-nssf). + - [free5gc-pcf](charts/free5gc-pcf). + - [free5gc-smf](charts/free5gc-smf). + - [free5gc-udm](charts/free5gc-udm). + - [free5gc-udr](charts/free5gc-udr). + - [free5gc-upf](charts/free5gc-upf). + - [free5gc-webui](charts/free5gc-webui). + +## Prerequisites + - A Kubernetes cluster ready to use with all worker nodes using kernel `5.0.0-23-generic` and they should contain gtp5g kernel module. + - The AMF NGAP service relies on SCTP which is supported by default in Kubernetes from version [1.20](https://kubernetes.io/docs/setup/release/notes/#feature) onwards. If you are using an older version of Kubernetes please refer to this [link](https://v1-19.docs.kubernetes.io/docs/concepts/services-networking/service/#sctp) to enbale SCTP support. + - A Persistent Volume Provisioner (optional). + - [Multus-CNI](https://github.com/intel/multus-cni). + - [Helm3](https://helm.sh/docs/intro/install/). + - [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (optional). + - A physical network interface on each Kubernetes node named `eth0`. + - A physical network interface on each Kubernetes node named `eth1` to connect the UPF to the Data Network. +**Note:** If the names of network interfaces on your Kubernetes nodes are different from `eth0` and `eth1`, see [Networks configuration](#networks-configuration). + +## Quickstart guide + +### Verify the kernel version on worker nodes +```console +uname -r +``` +It should be `5.0.0-23-generic`. + +### Install the gtp5g kernel module on worker nodes +```console +git clone https://github.com/PrinzOwO/gtp5g.git +cd gtp5g +make +sudo make install +``` + +### Create a Persistent Volume +If you don't have a Persistent Volume provisioner, you can use the following commands to create a namespace for the project and a [Persistent Volume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) within this namespace that will be consumed by MongoDB by adapting it to your implementation (you have to replace `worker1` by the name of the node and `/home/vagrant/kubedata` by the right directory on this node in which you want to persist the MongoDB data). +```console +kubectl create ns +cat < install ./free5gc/ +``` + +### Check the state of the created pod +```console +kubectl -n get pods -l "project=free5gc" +``` + +### Uninstall free5gc +```console +helm -n delete +``` +Or... +```console +helm -n uninstall +``` + +## Configuration + +### Enable the ULCL feature +If you want to enable the ULCL feature, you can use the [ulcl-enabled-values.yaml](ulcl-enabled-values.yaml) to override the default chart values. + +### Networks configuration +In this section, we'll suppose that you have only one interface on each Kubernetes node and its name is `toto`. Then you have to set these parameters to `toto`: + - `global.n2network.masterIf` + - `global.n3network.masterIf` + - `global.n4network.masterIf` + - `global.n6network.masterIf` + +In addition, please make sure `global.n6network.subnetIP`, `global.n6network.gatewayIP` and `upf.n6if.IpAddress` parameters will match the IP address of the `toto` interface in order to make the UPF able to reach the Data Network via its N6 interface. + +In case of ULCL enabled take care about `free5gc-upf.upfb.n6if.IpAddress`, `free5gc-upf.upf1.n6if.IpAddress` and `free5gc-upf.upf2.n6if.IpAddress` instead of `free5gc-upf.upf.n6if.IpAddress`. + +## Customized installation +This chart allows you to customize its installation. The table below shows the parameters that can be modified before installing the chart or when upgrading it as well as their default values. + +### Main chart parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `deployMongoDB` | If `true` then the MongoDB subchart will be installed. | `true` | +| `deploy` | If `true` then the `` subchart will be installed. `` must be one of the following: AMF, AUSF, NRF, NSSF, PCF, SMF, UDM, UDR, UPF, WEBUI. | `true` | +| `deployN3IWF` | If `true` then the N3IWF subchart will be installed. | `false` | + +### Global and subcharts' parameters +Please check this [link](https://helm.sh/docs/chart_template_guide/subcharts_and_globals/) to see how to customize global and subcharts' parameters. + +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.projectName` | The name of the project. | `free5gc` | +| `global.userPlaneArchitecture` | User plane topology. Possible values are `single` and `ulcl` | `single` | +| `global.sbi.scheme` | The SBI scheme for all control plane NFs. Possible values are `http` and `https` | `http` | +| `global.nrf.service.name` | The name of the service used to expose the NRF SBI interface. | `nrf-service` | +| `global.nrf.service.type` | The type of the NRF SBI service. | `NodePort` | +| `global.nrf.service.port` | The NRF SBI port number. | `8000` | +| `global.nrf.service.port` | The NRF SBI service nodePort number. | `30800` | +| `global.smf.n4if.IpAddress` | The IP address of the SMF’s N4 interface. | `10.100.50.249` | +| `global.amf.n2if.IpAddress` | The IP address of the AMF’s N2 interface. | `10.100.50.249` | +| `global.amf.service.ngap.enabled` | If `true` then a Kubernetes service will be used to expose the AMF NGAP service. | `false` | +| `global.amf.service.ngap.name` | The name of the AMF NGAP service. | `amf-n2` | +| `global.amf.service.ngap.type` | The type of the AMF NGAP service. | `NodePort` | +| `global.amf.service.ngap.port` | The AMF NGAP port number. | `38412` | +| `global.amf.service.ngap.nodeport` | The nodePort number to access the AMF NGAP service from outside of cluster. | `31412` | +| `global.amf.service.ngap.protocol` | The protocol used for this service. | `SCTP` | + +### N2 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n2network.name` | N2 network name. | `n2network` | +| `global.n2network.masterIf` | N2 network MACVLAN master interface. | `eth0` | +| `global.n2network.subnetIP` | N2 network subnet IP address. | `10.100.50.248` | +| `global.n2network.cidr` | N2 network cidr. | `29` | +| `global.n2network.gatewayIP` | N2 network gateway IP address. | `10.100.50.254` | + +### N3 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n3network.name` | N3 network name. | `n3network` | +| `global.n3network.masterIf` | N3 network MACVLAN master interface. | `eth0` | +| `global.n3network.subnetIP` | N3 network subnet IP address. | `10.100.50.232` | +| `global.n3network.cidr` | N3 network cidr. | `29` | +| `global.n3network.gatewayIP` | N3 network gateway IP address. | `10.100.50.238` | + +### N4 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n4network.name` | N4 network name. | `n4network` | +| `global.n4network.masterIf` | N4 network MACVLAN master interface. | `eth0` | +| `global.n4network.subnetIP` | N4 network subnet IP address. | `10.100.50.240` | +| `global.n4network.cidr` | N4 network cidr. | `29` | +| `global.n4network.gatewayIP` | N4 network gateway IP address. | `10.100.50.246` | + +### N6 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n6network.name` | N6 network name. | `n6network` | +| `global.n6network.masterIf` | N6 network MACVLAN master interface. The IP address of this interface must be in the N6 network subnet IP rang. | `eth1` | +| `global.n6network.subnetIP` | N6 network subnet IP address (The IP address of the Data Network. | `10.100.100.0` | +| `global.n6network.cidr` | N6 network cidr. | `24` | +| `global.n6network.gatewayIP` | N6 network gateway IP address (The IP address to go to the Data Network). | `10.100.100.1` | + +### N9 Network parameters +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. + +| Parameter | Description | Default value | +| --- | --- | --- | +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. +| `global.n9network.name` | N9 network name. | `n9network` | +| `global.n9network.masterIf` | N9 network MACVLAN master interface. The IP address of this interface must be in the N9 network subnet IP rang. | `eth1` | +| `global.n9network.subnetIP` | N9 network subnet IP address (The IP address of the Data Network. | `10.100.50.224` | +| `global.n9network.cidr` | N9 network cidr. | `29` | +| `global.n9network.gatewayIP` | N9 network gateway IP address (The IP address to go to the Data Network). | `10.100.50.230` | + +## Reference + - https://github.com/free5gc/free5gc + - https://github.com/free5gc/free5gc-compose + + + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/Chart.yaml new file mode 100644 index 00000000..3b9e7a5a --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-amf +description: A Helm chart to deploy the Free5GC AMF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/NOTES.txt new file mode 100644 index 00000000..ae3a9a16 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-amf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/_helpers.tpl new file mode 100644 index 00000000..c0d64df0 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-amf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-amf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-amf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-amf.labels" -}} +helm.sh/chart: {{ include "free5gc-amf.chart" . }} +{{ include "free5gc-amf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-amf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-amf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +AMF Pod Annotations +*/}} +{{- define "free5gc-amf.amfAnnotations" -}} +{{- with .Values.amf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-configmap.yaml new file mode 100644 index 00000000..869f76ed --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-configmap.yaml @@ -0,0 +1,46 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + amfcfg.yaml: | + info: + version: 1.0.0 + description: AMF initial local configuration + + configuration: + ngapIpList: +{{- if $.Values.global.amf.service.ngap.enabled }} + - 0.0.0.0 +{{- else }} + - {{ $.Values.global.amf.n2if.ipAddress }} +{{- end }} + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-deployment.yaml new file mode 100644 index 00000000..4ea863eb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-deployment.yaml @@ -0,0 +1,102 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-amf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-amf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-amf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-amf.amfAnnotations" $ | nindent 8 }} +{{- if not $.Values.global.amf.service.ngap.enabled }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n2network.name }}-{{ .name }}", + "interface": "n2", + "ips": [ "{{ $.Values.global.amf.n2if.ipAddress }}/{{ $.Values.global.n2network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n2network.gatewayIP }}" ] + }]' +{{- end }} + checksum/config: {{ include (print $.Template.BasePath "/amf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-amf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + ports: + - name: namf + containerPort: {{ .service.port }} + - name: n2 + containerPort: {{ $.Values.global.amf.service.ngap.port }} + protocol: {{ $.Values.global.amf.service.ngap.protocol }} + command: ["./amf"] + args: ["-amfcfg", "../config/amfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-hpa.yaml new file mode 100644 index 00000000..20a98ad4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-amf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-amf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-amf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-ingress.yaml new file mode 100644 index 00000000..8c2538f9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-amf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-networkattachmentdefinition.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-networkattachmentdefinition.yaml new file mode 100644 index 00000000..92be3f52 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-networkattachmentdefinition.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if not $.Values.global.amf.service.ngap.enabled }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n2network.name }}-{{ .Values.amf.name }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n2network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n2network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-service.yaml new file mode 100644 index 00000000..c3ed7485 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/amf-service.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-amf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-amf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + +{{- if $.Values.global.amf.service.ngap.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.global.amf.service.ngap.name }} + labels: + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ $.Values.global.amf.service.ngap.type }} + ports: + - name: n2 + port: {{ $.Values.global.amf.service.ngap.port }} + nodePort: {{ $.Values.global.amf.service.ngap.nodeport }} + protocol: {{ $.Values.global.amf.service.ngap.protocol }} + selector: + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} + +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..8e33debb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.amf }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-amf.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-amf.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/values.yaml new file mode 100644 index 00000000..6363ca68 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-amf/values.yaml @@ -0,0 +1,217 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 + service: + ngap: + enabled: false + name: amf-n2 + port: 38412 + nodeport: 31412 + protocol: SCTP + type: NodePort + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +amf: + name: amf + replicaCount: 1 + image: + name: towards5gs/free5gc-amf + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: amf-namf + type: ClusterIP + port: 80 + configmap: + name: amf-configmap + volume: + name: amf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 150m + memory: 128Mi + requests: + cpu: 150m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + amfName: AMF + serviceNameList: + - namf-comm + - namf-evts + - namf-mt + - namf-loc + - namf-oam + servedGuamiList: + - plmnId: + mcc: 208 + mnc: 93 + amfId: cafe00 + supportTaiList: + - plmnId: + mcc: 208 + mnc: 93 + tac: 1 + plmnSupportList: + - plmnId: + mcc: 208 + mnc: 93 + snssaiList: + - sst: 1 + sd: 010203 + - sst: 1 + sd: 112233 + supportDnnList: + - internet + security: + integrityOrder: + - NIA2 + cipheringOrder: + - NEA0 + networkName: + full: free5GC + short: free + t3502Value: 720 + t3512Value: 3600 + non3gppDeregistrationTimerValue: 3240 + # retransmission timer for paging message + t3513: + enable: true # true or false + expireTime: 6s # default is 6 seconds + maxRetryTimes: 4 # the max number of retransmission + # retransmission timer for NAS Registration Accept message + t3522: + enable: true # true or false + expireTime: 6s # default is 6 seconds + maxRetryTimes: 4 # the max number of retransmission + # retransmission timer for NAS Registration Accept message + t3550: + enable: true # true or false + expireTime: 6s # default is 6 seconds + maxRetryTimes: 4 # the max number of retransmission + # retransmission timer for NAS Authentication Request/Security Mode Command message + t3560: + enable: true # true or false + expireTime: 6s # default is 6 seconds + maxRetryTimes: 4 # the max number of retransmission + # retransmission timer for NAS Notification message + t3565: + enable: true # true or false + expireTime: 6s # default is 6 seconds + maxRetryTimes: 4 # the max number of retransmission + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + AMF: + debugLevel: info + ReportCaller: false + NAS: + debugLevel: info + ReportCaller: false + FSM: + debugLevel: info + ReportCaller: false + NGAP: + debugLevel: info + ReportCaller: false + Aper: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/Chart.yaml new file mode 100644 index 00000000..746e938f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-ausf +description: A Helm chart to deploy the Free5GC AUSF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/NOTES.txt new file mode 100644 index 00000000..9fe84bb4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-ausf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/_helpers.tpl new file mode 100644 index 00000000..58a9b4bf --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/_helpers.tpl @@ -0,0 +1,74 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-ausf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-ausf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-ausf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-ausf.labels" -}} +helm.sh/chart: {{ include "free5gc-ausf.chart" . }} +{{ include "free5gc-ausf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-ausf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-ausf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +AUSF Pod Annotations +*/}} +{{- define "free5gc-ausf.ausfAnnotations" -}} +{{- with .Values.ausf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-configmap.yaml new file mode 100644 index 00000000..9092258e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-configmap.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + ausfcfg.yaml: | + info: + version: 1.0.0 + description: AUSF initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-deployment.yaml new file mode 100644 index 00000000..2c223774 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-deployment.yaml @@ -0,0 +1,88 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-ausf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-ausf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-ausf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-ausf.ausfAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/ausf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-ausf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./ausf"] + args: ["-ausfcfg", "../config/ausfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-hpa.yaml new file mode 100644 index 00000000..e5dcf5be --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-ausf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-ausf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-ausf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-ingress.yaml new file mode 100644 index 00000000..5178c2ae --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-ausf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-service.yaml new file mode 100644 index 00000000..97711cd6 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/ausf-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-ausf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-ausf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..bd3884b5 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-ausf.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-ausf.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/values.yaml new file mode 100644 index 00000000..e064c06f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-ausf/values.yaml @@ -0,0 +1,131 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +ausf: + name: ausf + replicaCount: 1 + image: + name: towards5gs/free5gc-ausf + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: ausf-nausf + type: ClusterIP + port: 80 + configmap: + name: ausf-configmap + volume: + name: ausf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + serviceNameList: + - nausf-auth + plmnSupportList: + - mcc: 208 + mnc: 93 + - mcc: 123 + mnc: 45 + groupId: ausfGroup001 + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + AUSF: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/Chart.yaml new file mode 100644 index 00000000..738b90fe --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-n3iwf +description: A Helm chart to deploy the Free5GC N3IWF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/NOTES.txt new file mode 100644 index 00000000..5810ac92 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/NOTES.txt @@ -0,0 +1,14 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm +# diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/_helpers.tpl new file mode 100644 index 00000000..7c2a9779 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-n3iwf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-n3iwf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-n3iwf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-n3iwf.labels" -}} +helm.sh/chart: {{ include "free5gc-n3iwf.chart" . }} +{{ include "free5gc-n3iwf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-n3iwf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-n3iwf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +n3iwf Pod Annotations +*/}} +{{- define "free5gc-n3iwf.n3iwfAnnotations" -}} +{{- with .Values.n3iwf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/amf-ngap-external.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/amf-ngap-external.yaml new file mode 100644 index 00000000..d39474fa --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/amf-ngap-external.yaml @@ -0,0 +1,41 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if and .Values.global.amf.service.ngap.enabled }} +{{- if and .Values.multiCluster }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.global.amf.service.ngap.name }} + labels: + project: {{ .Values.global.projectName }} +spec: + type: {{ .Values.global.amf.service.ngap.type }} + ports: + - name: n2 + port: {{ .Values.global.amf.service.ngap.port }} + targetPort: {{ .Values.global.amf.service.ngap.nodeport }} + protocol: {{ .Values.global.amf.service.ngap.protocol }} +--- +apiVersion: v1 +kind: Endpoints +metadata: + name: {{ .Values.global.amf.service.ngap.name }} +subsets: + - addresses: + - ip: {{ .Values.cpClusterIP }} + ports: + - name: n2 + port: {{ .Values.global.amf.service.ngap.nodeport }} + protocol: {{ .Values.global.amf.service.ngap.protocol }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-configmap.yaml new file mode 100644 index 00000000..d4e73a2b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-configmap.yaml @@ -0,0 +1,58 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.n3iwf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + n3iwfcfg.yaml: | + info: + version: 1.0.0 + description: N3IWF initial local configuration + + configuration: + AMFSCTPAddresses: + - IP: +{{- if $.Values.global.amf.service.ngap.enabled }} + - {{ $.Values.global.amf.service.ngap.name }} +{{- else }} + - {{ $.Values.global.amf.n2if.ipAddress }} +{{- end }} + + # Bind Interfaces + # IKE interface + IKEBindAddress: {{ .ike.ipAddress }} + # contrarly to the example used in docker compose here we attribute a special interface for the IKE daemon (as specified in the free5gc main project in github) + + # GTP interface + GTPBindAddress: {{ .n3if.ipAddress }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + + + n3iwf-ipsec.sh: | + #!/bin/sh + + ### N3iwf IPSec tunnel configuration + + ip l add name ipsec0 type vti local {{ .ike.ipAddress }} remote 0.0.0.0 key 5 + ip a add {{ .configuration.IPSecInterfaceAddress }}/24 dev ipsec0 + ip l set dev ipsec0 up + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-deployment.yaml new file mode 100644 index 00000000..5438f052 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-deployment.yaml @@ -0,0 +1,101 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.n3iwf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-n3iwf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-n3iwf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-n3iwf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-n3iwf.n3iwfAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + {{- if not $.Values.global.amf.service.ngap.enabled }} + { "name": "{{ $.Values.global.n2network.name }}-{{ .name }}", + "interface": "n2", + "ips": [ "{{ .n2if.ipAddress }}/{{ $.Values.global.n2network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n2network.gatewayIP }}" ] + }, + {{- end }} + { "name": "{{ $.Values.global.n3network.name }}-{{ .name }}", + "interface": "n3", + "ips": [ "{{ .n3if.ipAddress }}/{{ $.Values.global.n3network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n3network.gatewayIP }}" ] + }, + + { "name": "{{ .ike.name }}-{{ .name }}", + "interface": "ike", + "ips": [ "{{ .ike.ipAddress }}/{{ .ike.cidr }}" ], + "gateway": [ "{{ .ike.gatewayIP }}" ] + } + ]' + checksum/config: {{ include (print $.Template.BasePath "/n3iwf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-n3iwf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + command: ["sh", "-c", "../config/n3iwf-ipsec.sh && ./n3iwf -n3iwfcfg ../config/n3iwfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: n3iwfcfg.yaml + path: n3iwfcfg.yaml + - key: n3iwf-ipsec.sh + path: n3iwf-ipsec.sh + mode: 0777 +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-hpa.yaml new file mode 100644 index 00000000..55343b57 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.n3iwf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-n3iwf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-n3iwf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-n3iwf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-ike-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-ike-nad.yaml new file mode 100644 index 00000000..9c806c5d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-ike-nad.yaml @@ -0,0 +1,43 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.n3iwf.ike }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .name }}-{{ $.Values.n3iwf.name }} +spec: + + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n2-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n2-nad.yaml new file mode 100644 index 00000000..38224d16 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n2-nad.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if not .Values.global.amf.service.ngap.enabled }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n2network.name }}-{{ .Values.n3iwf.name }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n2network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n2network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n3-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n3-nad.yaml new file mode 100644 index 00000000..52fb51ce --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/templates/n3iwf-n3-nad.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n3network.name }}-{{ .Values.n3iwf.name }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n3network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n3network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/values.yaml new file mode 100644 index 00000000..aed7b308 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-n3iwf/values.yaml @@ -0,0 +1,185 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 + service: + ngap: + enabled: false + name: amf-n2 + port: 38412 + nodeport: 31412 + protocol: SCTP + type: NodePort + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +n3iwf: + name: n3iwf + replicaCount: 1 + image: + name: towards5gs/free5gc-n3iwf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: n3iwf-configmap + volume: + name: n3iwf-volume + mount: /free5gc/config/ + # network paramters + n2if: # NGAP + ipAddress: 10.100.50.251 + n3if: # GTPU + ipAddress: 10.100.50.237 + ike: # define an interface for the IKE daemon as mentioned in the free5gc github README.md + ipAddress: 172.16.10.5 + name: ikenetwork + masterIf: eth0 + subnetIP: 172.16.10.0 + cidr: 24 + gatewayIP: 172.16.10.1 + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + configuration: + IPSecInterfaceAddress: 10.0.0.1 + configuration: |- + N3IWFInformation: + GlobalN3IWFID: + PLMNID: + MCC: 208 + MNC: 93 + N3IWFID: 135 + Name: + free5GC_N3IWF + SupportedTAList: + - TAC: 000001 + BroadcastPLMNList: + - PLMNID: + MCC: 208 + MNC: 93 + TAISliceSupportList: + - SNSSAI: + SST: 1 + SD: 010203 + - SNSSAI: + SST: 1 + SD: 112233 + + # IPSec virtual interface + IPSecInterfaceAddress: 10.0.0.1 + + # IPSec virtual interface mark + IPSecInterfaceMark: 5 + + # NAS TCP Listen Port + NASTCPPort: 20000 + + # N3IWF FQDN + FQDN: n3iwf.free5gc.org + + # Security + # Private Key File Path + PrivateKey: + # Certificate Authority (CA) + CertificateAuthority: + # Certificate + Certificate: + + # IP address that will be allocated to UE in IPSec tunnel + UEIPAddressRange: 10.0.0.0/24 + + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + N3IWF: + debugLevel: info + ReportCaller: false + NGAP: + debugLevel: info + ReportCaller: false + Aper: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + +# These parameters apply in case of deployinh N3IWF if a different cluster from the one where AMF is deployed and a Kubernetes service is used for AMF' N2 interface +multiCluster: false +cpClusterIP: "" diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/Chart.yaml new file mode 100644 index 00000000..ffe4483e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/Chart.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-nrf +description: A Helm chart to deploy the Free5GC NRF +type: application +version: 0.1.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: db.enabled +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/NOTES.txt new file mode 100644 index 00000000..7ef935c2 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" $.Values.global.nrf.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $.Values.global.nrf.service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" $.Values.global.nrf.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ $.Values.global.nrf.service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ $.Values.global.nrf.service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ $.Values.global.nrf.service.port }} +{{- else if contains "ClusterIP" $.Values.global.nrf.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-nrf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/_helpers.tpl new file mode 100644 index 00000000..4e1ff610 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-nrf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-nrf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-nrf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-nrf.labels" -}} +helm.sh/chart: {{ include "free5gc-nrf.chart" . }} +{{ include "free5gc-nrf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-nrf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-nrf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +NRF Pod Annotations +*/}} +{{- define "free5gc-nrf.nrfAnnotations" -}} +{{- with .Values.nrf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml new file mode 100644 index 00000000..eb7eafd9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-configmap.yaml @@ -0,0 +1,41 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + nrfcfg.yaml: | + info: + version: 1.0.0 + description: NRF initial local configuration + + configuration: + MongoDBName: free5gc + MongoDBUrl: mongodb://{{ $.Values.mongodb.service.name }}:{{ $.Values.mongodb.service.port }} + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ $.Values.global.nrf.service.name }} # IP used to serve NFs or register to another NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml new file mode 100644 index 00000000..f050e84f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-deployment.yaml @@ -0,0 +1,109 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-nrf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-nrf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-nrf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-nrf.nrfAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/nrf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-nrf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-mongo + {{- with $.Values.initcontainers.busybox }} + image: {{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + {{- with $.Values.mongodb.service }} + value: {{ .name }}:{{ .port }} + {{- end }} + command: ["sh", "-c", "until nc -z $DEPENDENCIES; do echo waiting for the MongoDB; sleep 2; done;"] + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ $.Values.global.nrf.service.port }} + command: ["./nrf"] + args: ["-nrfcfg", "../config/nrfcfg.yaml"] + env: + - name: DB_URI + value: mongodb://{{ $.Values.mongodb.service.name }}/free5gc + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + readinessProbe: + initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .readinessProbe.periodSeconds }} + timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} + failureThreshold: {{ .readinessProbe.failureThreshold }} + successThreshold: {{ .readinessProbe.successThreshold }} + httpGet: + scheme: {{ $.Values.global.sbi.scheme | quote | upper }} + port: {{ $.Values.global.nrf.service.port }} + livenessProbe: + initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .livenessProbe.periodSeconds }} + timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} + failureThreshold: {{ .livenessProbe.failureThreshold }} + successThreshold: {{ .livenessProbe.successThreshold }} + httpGet: + scheme: {{ $.Values.global.sbi.scheme | quote | upper }} + port: {{ $.Values.global.nrf.service.port }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-hpa.yaml new file mode 100644 index 00000000..0d0580a5 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-nrf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-nrf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-nrf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-ingress.yaml new file mode 100644 index 00000000..c62f0634 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +{{- if .ingress.enabled -}} +{{- $fullName := $.Values.global.nrf.service.name -}} +{{- $svcPort := $.Values.global.nrf.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-nrf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-service.yaml new file mode 100644 index 00000000..35c8a465 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/nrf-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nrf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.global.nrf.service.name }} + labels: + {{- include "free5gc-nrf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ $.Values.global.nrf.service.type }} + ports: + - port: {{ $.Values.global.nrf.service.port }} + targetPort: {{ $.Values.global.nrf.service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-nrf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..dcabec35 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/templates/tests/test-connection.yaml @@ -0,0 +1,27 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-nrf.fullname" . }}-test-connection" + labels: + {{- include "free5gc-nrf.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .Values.global.nrf.service.name }}:{{ .Values.global.nrf.service.port }}'] + restartPolicy: Never diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/values.yaml new file mode 100644 index 00000000..8d686b83 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nrf/values.yaml @@ -0,0 +1,134 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +db: + enabled: true +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + fullnameOverride: "mongodb" + useStatefulSet: true + auth: + enabled: false + persistence: + size: 6Gi + mountPath: /bitnami/mongodb/data/db/ + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +nrf: + name: nrf + replicaCount: 1 + image: + name: towards5gs/free5gc-nrf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: nrf-configmap + volume: + name: nrf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + DefaultPlmnId: + mcc: 208 + mnc: 93 + serviceNameList: + - nnrf-nfm + - nnrf-disc + logger: + NRF: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + MongoDBLibrary: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/Chart.yaml new file mode 100644 index 00000000..c7229c36 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-nssf +description: A Helm chart to deploy the Free5GC NSSF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/NOTES.txt new file mode 100644 index 00000000..9fe84bb4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ausf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-ausf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/_helpers.tpl new file mode 100644 index 00000000..f7440eeb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-nssf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-nssf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-nssf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-nssf.labels" -}} +helm.sh/chart: {{ include "free5gc-nssf.chart" . }} +{{ include "free5gc-nssf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-nssf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-nssf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +NSSF Pod Annotations +*/}} +{{- define "free5gc-nssf.nssfAnnotations" -}} +{{- with .Values.nssf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-configmap.yaml new file mode 100644 index 00000000..dd492efa --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-configmap.yaml @@ -0,0 +1,141 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + nssfcfg.yaml: | + info: + version: 1.0.0 + description: NSSF initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + nsiList: + - snssai: + sst: 1 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 10 + - snssai: + sst: 1 + sd: 1 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 11 + - snssai: + sst: 1 + sd: 2 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 12 + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 12 + - snssai: + sst: 1 + sd: 3 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 13 + - snssai: + sst: 2 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 20 + - snssai: + sst: 2 + sd: 1 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 21 + - snssai: + sst: 1 + sd: 010203 + nsiInformationList: + - nrfId: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }}/nnrf-nfm/v1/nf-instances + nsiId: 22 + amfSetList: + - amfSetId: 1 + amfList: + - ffa2e8d7-3275-49c7-8631-6af1df1d9d26 + - 0e8831c3-6286-4689-ab27-1e2161e15cb1 + - a1fba9ba-2e39-4e22-9c74-f749da571d0d + nrfAmfSet: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:8081/nnrf-nfm/v1/nf-instances + supportedNssaiAvailabilityData: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33456 + supportedSnssaiList: + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - sst: 2 + sd: 1 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33457 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - amfSetId: 2 + nrfAmfSet: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:8084/nnrf-nfm/v1/nf-instances + supportedNssaiAvailabilityData: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33456 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 3 + - sst: 2 + sd: 1 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33458 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 2 + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-deployment.yaml new file mode 100644 index 00000000..50540df0 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-deployment.yaml @@ -0,0 +1,88 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-nssf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-nssf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-nssf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-nssf.nssfAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/nssf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-nssf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./nssf"] + args: ["-nssfcfg", "../config/nssfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-hpa.yaml new file mode 100644 index 00000000..71775d66 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-nssf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-nssf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-nssf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-ingress.yaml new file mode 100644 index 00000000..552085fe --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-nssf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-service.yaml new file mode 100644 index 00000000..41c72c20 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/nssf-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-nssf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-nssf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..af3483a4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.nssf }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-nssf.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-nssf.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/values.yaml new file mode 100644 index 00000000..8a249df8 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-nssf/values.yaml @@ -0,0 +1,334 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +nssf: + name: nssf + replicaCount: 1 + image: + name: towards5gs/free5gc-nssf + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: nssf-nnssf + type: ClusterIP + port: 80 + configmap: + name: nssf-configmap + volume: + name: nssf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + nssfName: NSSF + serviceNameList: + - nnssf-nsselection + - nnssf-nssaiavailability + supportedPlmnList: + - mcc: 208 + mnc: 93 + supportedNssaiInPlmnList: + - plmnId: + mcc: 208 + mnc: 93 + supportedSnssaiList: + - sst: 1 + sd: 010203 + - sst: 1 + sd: 112233 + - sst: 1 + sd: 3 + - sst: 2 + sd: 1 + - sst: 2 + sd: 2 + amfList: + - nfId: 469de254-2fe5-4ca0-8381-af3f500af77c + supportedNssaiAvailabilityData: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33456 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 2 + - sst: 2 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33457 + supportedSnssaiList: + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - nfId: fbe604a8-27b2-417e-bd7c-8a7be2691f8d + supportedNssaiAvailabilityData: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33458 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 3 + - sst: 2 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33459 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 2 + - sst: 2 + sd: 1 + - nfId: b9e6e2cb-5ce8-4cb6-9173-a266dd9a2f0c + supportedNssaiAvailabilityData: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33456 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - sst: 2 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33458 + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 2 + - sst: 2 + sd: 1 + taList: + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33456 + accessType: 3GPP_ACCESS + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - sst: 2 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33457 + accessType: 3GPP_ACCESS + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 2 + - sst: 2 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33458 + accessType: 3GPP_ACCESS + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 1 + sd: 3 + - sst: 2 + restrictedSnssaiList: + - homePlmnId: + mcc: 310 + mnc: 560 + sNssaiList: + - sst: 1 + sd: 3 + - tai: + plmnId: + mcc: 466 + mnc: 92 + tac: 33459 + accessType: 3GPP_ACCESS + supportedSnssaiList: + - sst: 1 + - sst: 1 + sd: 1 + - sst: 2 + - sst: 2 + sd: 1 + restrictedSnssaiList: + - homePlmnId: + mcc: 310 + mnc: 560 + sNssaiList: + - sst: 2 + sd: 1 + mappingListFromPlmn: + - operatorName: NTT Docomo + homePlmnId: + mcc: 440 + mnc: 10 + mappingOfSnssai: + - servingSnssai: + sst: 1 + sd: 1 + homeSnssai: + sst: 1 + sd: 1 + - servingSnssai: + sst: 1 + sd: 2 + homeSnssai: + sst: 1 + sd: 3 + - servingSnssai: + sst: 1 + sd: 3 + homeSnssai: + sst: 1 + sd: 4 + - servingSnssai: + sst: 2 + sd: 1 + homeSnssai: + sst: 2 + sd: 2 + - operatorName: AT&T Mobility + homePlmnId: + mcc: 310 + mnc: 560 + mappingOfSnssai: + - servingSnssai: + sst: 1 + sd: 1 + homeSnssai: + sst: 1 + sd: 2 + - servingSnssai: + sst: 1 + sd: 2 + homeSnssai: + sst: 1 + sd: 3 + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + NSSF: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/Chart.yaml new file mode 100644 index 00000000..9c4f4d74 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-pcf +description: A Helm chart to deploy the Free5GC PCF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/NOTES.txt new file mode 100644 index 00000000..27fdb452 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-pcf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/_helpers.tpl new file mode 100644 index 00000000..22a6efdf --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-pcf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-pcf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-pcf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-pcf.labels" -}} +helm.sh/chart: {{ include "free5gc-pcf.chart" . }} +{{ include "free5gc-pcf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-pcf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-pcf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +PCF Pod Annotations +*/}} +{{- define "free5gc-pcf.pcfAnnotations" -}} +{{- with .Values.pcf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-configmap.yaml new file mode 100644 index 00000000..dd9d1bbc --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-configmap.yaml @@ -0,0 +1,44 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + pcfcfg.yaml: | + info: + version: 1.0.0 + description: PCF initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + + mongodb: # the mongodb connected by this PCF + name: free5gc # name of the mongodb + url: mongodb://{{ $.Values.mongodb.service.name }}:{{ $.Values.mongodb.service.port }} # a valid URL of the mongodb + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-deployment.yaml new file mode 100644 index 00000000..40006ccd --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-deployment.yaml @@ -0,0 +1,89 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-pcf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-pcf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-pcf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-pcf.pcfAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/pcf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-pcf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./pcf"] + args: ["-pcfcfg", "../config/pcfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-hpa.yaml new file mode 100644 index 00000000..b1800d6c --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-pcf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-pcf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-pcf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-ingress.yaml new file mode 100644 index 00000000..09a1df02 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-pcf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-service.yaml new file mode 100644 index 00000000..3ed38f81 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/pcf-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-pcf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-pcf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..38595bb9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.pcf }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-pcf.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-pcf.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/values.yaml new file mode 100644 index 00000000..9075b3e4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-pcf/values.yaml @@ -0,0 +1,136 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +pcf: + name: pcf + replicaCount: 1 + image: + name: towards5gs/free5gc-pcf + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: pcf-npcf + type: ClusterIP + port: 80 + configmap: + name: pcf-configmap + volume: + name: pcf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + pcfName: PCF + timeFormat: 2019-01-02 15:04:05 + defaultBdtRefId: BdtPolicyId- + serviceList: + - serviceName: npcf-am-policy-control + - serviceName: npcf-smpolicycontrol + suppFeat: 3fff + - serviceName: npcf-bdtpolicycontrol + - serviceName: npcf-policyauthorization + suppFeat: 3 + - serviceName: npcf-eventexposure + - serviceName: npcf-ue-policy-control + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + PCF: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/Chart.yaml new file mode 100644 index 00000000..0cd3b115 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-smf +description: A Helm chart to deploy the Free5GC SMF +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/NOTES.txt new file mode 100644 index 00000000..f7a3aa2f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-smf.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/_helpers.tpl new file mode 100644 index 00000000..05d7ff44 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-smf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-smf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-smf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-smf.labels" -}} +helm.sh/chart: {{ include "free5gc-smf.chart" . }} +{{ include "free5gc-smf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-smf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-smf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +SMF Pod Annotations +*/}} +{{- define "free5gc-smf.smfAnnotations" -}} +{{- with .Values.smf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-configmap.yaml new file mode 100644 index 00000000..dc2ddcb0 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-configmap.yaml @@ -0,0 +1,54 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + smfcfg.yaml: | + info: + version: 1.0.0 + description: SMF initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + tls: + key: free5gc/support/TLS/smf.key + pem: free5gc/support/TLS/smf.pem + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + pfcp: + addr: {{ $.Values.global.smf.n4if.ipAddress }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + + + uerouting.yaml: | + info: + version: 1.0.0 + description: Routing information for UE + ueRoutingInfo: + {{- .configuration.ueRoutingInfo | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-deployment.yaml new file mode 100644 index 00000000..137b0cc6 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-deployment.yaml @@ -0,0 +1,106 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-smf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-smf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-smf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-smf.smfAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n4network.name }}-{{ .name }}", + "interface": "n4", + "ips": [ "{{ $.Values.global.smf.n4if.ipAddress }}/{{ $.Values.global.n4network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n4network.gatewayIP }}" ] + }]' + checksum/config: {{ include (print $.Template.BasePath "/smf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-smf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + ports: + - name: nsmf + containerPort: {{ .service.port }} + - name: n4 + containerPort: 8805 + protocol: UDP + command: ["./smf"] + args: ["-smfcfg", "../config/smfcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: smfcfg.yaml + path: smfcfg.yaml + - key: uerouting.yaml + path: uerouting.yaml +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-hpa.yaml new file mode 100644 index 00000000..472538ca --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-smf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-smf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-smf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-ingress.yaml new file mode 100644 index 00000000..48286b55 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-smf.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-networkattachmentdefinition.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-networkattachmentdefinition.yaml new file mode 100644 index 00000000..be79d60b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-networkattachmentdefinition.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n4network.name }}-{{ .Values.smf.name }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n4network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n4network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-service.yaml new file mode 100644 index 00000000..693b6620 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/smf-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-smf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-smf.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/tests/test-connection.yaml new file mode 100644 index 00000000..c963ab36 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.smf }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-smf.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-smf.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/ulcl-enabled-values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/ulcl-enabled-values.yaml new file mode 100644 index 00000000..91fdfd8d --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/ulcl-enabled-values.yaml @@ -0,0 +1,120 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + userPlaneArchitecture: ulcl # possible values are "single" and "ulcl" + +smf: + configuration: + configuration: |- + smfName: SMF + serviceNameList: + - nsmf-pdusession + - nsmf-event-exposure + - nsmf-oam + snssaiInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.0.0/17 # should be CIDR type + - sNssai: + sst: 1 + sd: 112233 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.128.0/17 # should be CIDR type ????? + - sNssai: + sst: 2 + sd: 112234 + dnnInfos: + - dnn: internet + dns: + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.2.0.0/16 + userplane_information: + up_nodes: + gNB1: + type: AN + an_ip: 10.100.50.236 + BranchingUPF: + type: UPF + node_id: 10.100.50.241 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + - sNssai: + sst: 1 + sd: 112233 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N3 + endpoints: + - 10.100.50.233 + networkInstance: internet + - interfaceType: N9 + endpoints: + - 10.100.50.225 + networkInstance: internet + AnchorUPF1: + type: UPF + node_id: 10.100.50.242 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N9 + endpoints: + - 10.100.50.226 # UPF1 N9 address + networkInstance: internet + AnchorUPF2: + type: UPF + node_id: 10.100.50.243 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N9 + endpoints: + - 10.100.50.227 # UPF2 N9 address + networkInstance: internet + links: + - A: gNB1 + B: BranchingUPF + - A: BranchingUPF + B: AnchorUPF1 + - A: BranchingUPF + B: AnchorUPF2 + + + + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/values.yaml new file mode 100644 index 00000000..e292c132 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-smf/values.yaml @@ -0,0 +1,225 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + userPlaneArchitecture: single # possible values are "single" and "ulcl" + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + smf: + n4if: + ipAddress: 10.100.50.244 + n4network: + name: n4network + masterIf: eth0 + subnetIP: 10.100.50.240 + cidr: 29 + gatewayIP: 10.100.50.246 + excludeIP: 10.100.50.246 + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +smf: + name: smf + replicaCount: 1 + image: + name: towards5gs/free5gc-smf + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: smf-nsmf + type: ClusterIP + port: 80 + configmap: + name: smf-configmap + volume: + name: smf-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + smfName: SMF + serviceNameList: + - nsmf-pdusession + - nsmf-event-exposure + - nsmf-oam + snssaiInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.0.0/17 # should be CIDR type + - sNssai: + sst: 1 + sd: 112233 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.128.0/17 # should be CIDR type ????? + - sNssai: + sst: 2 + sd: 112234 + dnnInfos: + - dnn: internet + dns: + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.2.0.0/16 + userplane_information: # list of userplane information + up_nodes: # information of userplane node (AN or UPF) + gNB1: # the name of the node + type: AN # the type of the node (AN or UPF) + UPF: # the name of the node + type: UPF # the type of the node (AN or UPF) + node_id: 10.100.50.241 # the IP/FQDN of N4 interface on this UPF (PFCP) + sNssaiUpfInfos: # S-NSSAI information list for this UPF + - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information) + sst: 1 # Slice/Service Type (uinteger, range: 0~255) + sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF) + dnnUpfInfoList: # DNN information list for this S-NSSAI + - dnn: internet + - sNssai: # S-NSSAI (Single Network Slice Selection Assistance Information) + sst: 1 # Slice/Service Type (uinteger, range: 0~255) + sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF) + dnnUpfInfoList: # DNN information list for this S-NSSAI + - dnn: internet + interfaces: # Interface list for this UPF + - interfaceType: N3 # the type of the interface (N3 or N9) + endpoints: # the IP address of this N3/N9 interface on this UPF + - 10.100.50.233 + networkInstance: internet # Data Network Name (DNN) + links: # the topology graph of userplane, A and B represent the two nodes of each link + - A: gNB1 + B: UPF + ueRoutingInfo: |- + - SUPI: imsi-208930000000003 + AN: 10.100.50.226 + PathList: + - DestinationIP: 10.100.100.16 + UPF: !!seq + - BranchingUPF + - AnchorUPF1 + - DestinationIP: 10.100.100.26 + UPF: !!seq + - BranchingUPF + - AnchorUPF2 + - SUPI: imsi-208930000000004 + AN: 10.100.50.227 + PathList: + - DestinationIP: 10.100.100.16 + UPF: !!seq + - BranchingUPF + - AnchorUPF1 + - DestinationIP: 10.100.100.26 + UPF: !!seq + - BranchingUPF + - AnchorUPF2 + logger: + SMF: + debugLevel: info + ReportCaller: false + NAS: + debugLevel: info + ReportCaller: false + NGAP: + debugLevel: info + ReportCaller: false + Aper: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + PFCP: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/Chart.yaml new file mode 100644 index 00000000..d9c93cfd --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-udm +description: A Helm chart to deploy the Free5GC UDM +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/NOTES.txt new file mode 100644 index 00000000..e87678cd --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-udm.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/_helpers.tpl new file mode 100644 index 00000000..3d7f0845 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-udm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-udm.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-udm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-udm.labels" -}} +helm.sh/chart: {{ include "free5gc-udm.chart" . }} +{{ include "free5gc-udm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-udm.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-udm.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +UDM Pod Annotations +*/}} +{{- define "free5gc-udm.udmAnnotations" -}} +{{- with .Values.udm }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/tests/test-connection.yaml new file mode 100644 index 00000000..3879fe34 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-udm.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-udm.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-configmap.yaml new file mode 100644 index 00000000..44ec6baa --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-configmap.yaml @@ -0,0 +1,44 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + udmcfg.yaml: | + info: + version: 1.0.0 + description: UDM initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + tls: + log: free5gc/udmsslkey.log + pem: free5gc/support/TLS/udm.pem + key: free5gc/support/TLS/udm.key + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + {{- .configuration.configuration | nindent 6 }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-deployment.yaml new file mode 100644 index 00000000..c5263867 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-deployment.yaml @@ -0,0 +1,88 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-udm.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-udm.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-udm.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-udm.udmAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/udm-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-udm.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./udm"] + args: ["-udmcfg", "../config/udmcfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-hpa.yaml new file mode 100644 index 00000000..548a0554 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-udm.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-udm.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-udm.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-ingress.yaml new file mode 100644 index 00000000..47215495 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-udm.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-service.yaml new file mode 100644 index 00000000..240c3145 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/templates/udm-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udm }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-udm.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-udm.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/values.yaml new file mode 100644 index 00000000..84200509 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udm/values.yaml @@ -0,0 +1,131 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +udm: + name: udm + replicaCount: 1 + image: + name: towards5gs/free5gc-udm + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: udm-nudm + type: ClusterIP + port: 80 + configmap: + name: udm-configmap + volume: + name: udm-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: |- + serviceNameList: + - nudm-sdm + - nudm-uecm + - nudm-ueau + - nudm-ee + - nudm-pp + keys: + udmProfileAHNPublicKey: 5a8d38864820197c3394b92613b20b91633cbd897119273bf8e4a6f4eec0a650 + udmProfileAHNPrivateKey: c53c22208b61860b06c62e5406a7b330c2b577aa5558981510d128247d38bd1d + udmProfileBHNPublicKey: 0472DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD15A7DED52FCBB097A4ED250E036C7B9C8C7004C4EEDC4F068CD7BF8D3F900E3B4 + udmProfileBHNPrivateKey: F1AB1074477EBCC7F554EA1C5FC368B1616730155E0041AC447D6301975FECDA + logger: + UDM: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/Chart.yaml new file mode 100644 index 00000000..5f38d8c2 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/Chart.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-udr +description: A Helm chart to deploy the Free5GC UDR +type: application +version: 0.1.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: db.enabled +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/NOTES.txt new file mode 100644 index 00000000..05140f9e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-udr.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/_helpers.tpl new file mode 100644 index 00000000..6c076c16 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-udr.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-udr.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-udr.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-udr.labels" -}} +helm.sh/chart: {{ include "free5gc-udr.chart" . }} +{{ include "free5gc-udr.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-udr.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-udr.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +UDR Pod Annotations +*/}} +{{- define "free5gc-udr.udrAnnotations" -}} +{{- with .Values.udr }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/tests/test-connection.yaml new file mode 100644 index 00000000..15404e32 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-udr.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-udr.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-configmap.yaml new file mode 100644 index 00000000..86c492f4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-configmap.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + udrcfg.yaml: | + info: + version: 1.0.0 + description: UDR initial local configuration + + configuration: + sbi: + scheme: {{ $.Values.global.sbi.scheme }} + registerIPv4: {{ .service.name }} # IP used to register to NRF + bindingIPv4: 0.0.0.0 # IP used to bind the service + port: {{ .service.port }} + + mongodb: + name: free5gc + url: mongodb://{{ $.Values.mongodb.service.name }}:{{ $.Values.mongodb.service.port }} + + nrfUri: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + + logger: + {{- toYaml .configuration.logger | nindent 6 }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-deployment.yaml new file mode 100644 index 00000000..a22ad5b9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-deployment.yaml @@ -0,0 +1,90 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-udr.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-udr.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-udr.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-udr.udrAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/udr-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-udr.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-nrf + {{- with $.Values.initcontainers.curl }} + image: {{ .registry }}/{{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + value: {{ $.Values.global.sbi.scheme }}://{{ $.Values.global.nrf.service.name }}:{{ $.Values.global.nrf.service.port }} + command: ['sh', '-c', 'set -x; for dependency in $DEPENDENCIES; do while [ $(curl --connect-timeout 1 -s -o /dev/null -w "%{http_code}" $dependency) -ne 200 ]; do echo waiting for dependencies; sleep 1; done; done;'] + + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./udr"] + args: ["-udrcfg", "../config/udrcfg.yaml"] + env: + - name: DB_URI + value: mongodb://{{ $.Values.mongodb.service.name }}/free5gc + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-hpa.yaml new file mode 100644 index 00000000..90eae798 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-udr.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-udr.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-udr.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-ingress.yaml new file mode 100644 index 00000000..914c942a --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-udr.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-service.yaml new file mode 100644 index 00000000..83557f9f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/templates/udr-service.yaml @@ -0,0 +1,33 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.udr }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-udr.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + protocol: TCP + name: http + selector: + {{- include "free5gc-udr.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/values.yaml new file mode 100644 index 00000000..5f655711 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-udr/values.yaml @@ -0,0 +1,206 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +db: + enabled: false +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +udr: + name: udr + replicaCount: 1 + image: + name: towards5gs/free5gc-udr + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: udr-nudr + type: ClusterIP + port: 80 + configmap: + name: udr-configmap + volume: + name: udr-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: + configuration: {} + # the kind of log output + # debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic + # ReportCaller: enable the caller report or not, value: true or false + logger: + UDR: + debugLevel: info + ReportCaller: false + MongoDBLibrary: + debugLevel: info + ReportCaller: false + PathUtil: + debugLevel: info + ReportCaller: false + OpenApi: + debugLevel: info + ReportCaller: false + +free5gc: + configmap: + create: true + name: free5gc4udr-configmap + configuration: + #all logging levels + #panic + #fatal + #error + #warn + #info + #debug + #trace + logger: + # network function + AMF: + debugLevel: info + ReportCaller: true + SMF: + debugLevel: info + ReportCaller: true + UDR: + debugLevel: info + ReportCaller: true + UDM: + debugLevel: info + ReportCaller: true + NRF: + debugLevel: info + ReportCaller: true + PCF: + debugLevel: info + ReportCaller: true + AUSF: + debugLevel: info + ReportCaller: true + N3IWF: + debugLevel: info + ReportCaller: true + # library + NAS: + debugLevel: info + ReportCaller: true + FSM: + debugLevel: info + ReportCaller: true + NGAP: + debugLevel: info + ReportCaller: true + NamfComm: + debugLevel: info + ReportCaller: true + NamfEventExposure: + debugLevel: info + ReportCaller: true + NsmfPDUSession: + debugLevel: info + ReportCaller: true + NudrDataRepository: + debugLevel: info + ReportCaller: true + OpenApi: + debugLevel: info + ReportCaller: true + Aper: + debugLevel: info + ReportCaller: true + CommonConsumerTest: + debugLevel: info + ReportCaller: true + # webui + WEBUI: + debugLevel: info + ReportCaller: true + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/Chart.yaml new file mode 100644 index 00000000..5cf385fe --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/Chart.yaml @@ -0,0 +1,26 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-upf +description: A Helm chart to deploy the Free5GC User Plane +type: application +version: 0.1.0 +appVersion: v3.0.5 +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/README.md b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/README.md new file mode 100644 index 00000000..e50a3b09 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/README.md @@ -0,0 +1,190 @@ +# free5gc-upf Helm chart + +This is a Helm chart for deploying the [free5GC](https://github.com/free5gc/free5gc)-v3.0.5 UPF on Kubernetes. + +This chart is included in the [dependencies](/charts/free5gc/charts) of the [main chart](/charts/free5gc). Furthermore, it can be installed separately on Kubernetes a cluster at the same network with the clusters other Free5GC NFs are deployed. + +## Prerequisites + - A Kubernetes cluster ready to use with all worker nodes using kernel `5.0.0-23-generic` and they should contain gtp5g kernel module. + - [Multus-CNI](https://github.com/intel/multus-cni). + - [Helm3](https://helm.sh/docs/intro/install/). + - [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (optional). + - A physical network interface on each Kubernetes node named `eth0`. + - A physical network interface on each Kubernetes node named `eth1` to connect the UPF to the Data Network. +**Note:** If the names of network interfaces on your Kubernetes nodes are different from `eth0` and `eth1`, see [Networks configuration](#networks-configuration). + +## Quickstart guide + +### Verify the kernel version on worker nodes +```console +uname -r +``` +It should be `5.0.0-23-generic`. + +### Install the gtp5g kernel module on worker nodes +```console +git clone https://github.com/PrinzOwO/gtp5g.git +cd gtp5g +make +sudo make install +``` + +### Install the user plane +Run the following commands on a host that can communicate with the API server of your cluster. +```console +kubectl create ns +helm -n install ./free5gc-upf/ +``` + +### Check the state of the created pod +```console +kubectl -n get pods -l "project=free5gc" +``` + +### Uninstall the user plane +```console +helm -n delete +``` +Or... +```console +helm -n uninstall +``` + +## Configuration + +### Enable the ULCL feature +If you want to enable the ULCL feature, you can use the [ulcl-enabled-values.yaml](ulcl-enabled-values.yaml) to override the default chart values. + +### Networks configuration +In this section, we'll suppose that you have only one interface on each Kubernetes node and its name is `toto`. Then you have to set these parameters to `toto`: + - `global.n2network.masterIf` + - `global.n3network.masterIf` + - `global.n4network.masterIf` + - `global.n6network.masterIf` + +In addition, please make sure `global.n6network.subnetIP`, `global.n6network.gatewayIP` and `upf.n6if.IpAddress` parameters will match the IP address of the `toto` interface in order to make the UPF able to reach the Data Network via its N6 interface. + +In case of ULCL enabled take care about `upfb.n6if.IpAddress`, `upf1.n6if.IpAddress` and `upf2.n6if.IpAddress` instead of `upf.n6if.IpAddress`. + +## Customized installation +This chart allows you to customize its installation. The table below shows the parameters that can be modified before installing the chart or when upgrading it as well as their default values. + +### Global parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.projectName` | The name of the project. | `free5gc` | +| `global.userPlaneArchitecture` | User plane topology. Possible values are `single` and `ulcl` | `single` | + + +### N3 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n3network.name` | N3 network name. | `n3network` | +| `global.n3network.masterIf` | N3 network MACVLAN master interface. | `eth0` | +| `global.n3network.subnetIP` | N3 network subnet IP address. | `10.100.50.232` | +| `global.n3network.cidr` | N3 network cidr. | `29` | +| `global.n3network.gatewayIP` | N3 network gateway IP address. | `10.100.50.238` | + +### N4 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n4network.name` | N4 network name. | `n4network` | +| `global.n4network.masterIf` | N4 network MACVLAN master interface. | `eth0` | +| `global.n4network.subnetIP` | N4 network subnet IP address. | `10.100.50.240` | +| `global.n4network.cidr` | N4 network cidr. | `29` | +| `global.n4network.gatewayIP` | N4 network gateway IP address. | `10.100.50.246` | + +### N6 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n6network.name` | N6 network name. | `n6network` | +| `global.n6network.masterIf` | N6 network MACVLAN master interface. The IP address of this interface must be in the N6 network subnet IP rang. | `eth1` | +| `global.n6network.subnetIP` | N6 network subnet IP address (The IP address of the Data Network. | `10.100.100.0` | +| `global.n6network.cidr` | N6 network cidr. | `24` | +| `global.n6network.gatewayIP` | N6 network gateway IP address (The IP address to go to the Data Network). | `10.100.100.1` | + +### N9 Network parameters +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. + +| Parameter | Description | Default value | +| --- | --- | --- | +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. +| `global.n9network.name` | N9 network name. | `n9network` | +| `global.n9network.masterIf` | N9 network MACVLAN master interface. The IP address of this interface must be in the N9 network subnet IP rang. | `eth1` | +| `global.n9network.subnetIP` | N9 network subnet IP address (The IP address of the Data Network. | `10.100.50.224` | +| `global.n9network.cidr` | N9 network cidr. | `29` | +| `global.n9network.gatewayIP` | N9 network gateway IP address (The IP address to go to the Data Network). | `10.100.50.230` | + +### UPF parameters +These parameters if `global.userPlaneArchitecture` is set to `signle`. + +| Parameter | Description | Default value | +| --- | --- | --- | +| `upf.name` | The Network Function name of UPF. | `upf` | +| `upf.replicaCount` | The number of UPF replicas. | `1` | +| `upf.image.name` | The UPF Docker image name. | `towards5gs/free5gc-upf` | +| `upf.image.tag` | The UPF Docker image tag. | `defaults to the chart AppVersion` | +| `upf.configmap.name` | The name of the configmap to be used to import the configuration to the UPF POD. | `upf-configmap` | +| `upf.volume.name` | The name of the volume to be mounted to the UPF POD. | `upf-volume` | +| `upf.volume.mount` | The path to the folder where configuration files should be mounted. | `/free5gc/config/` | +| `upf.n3if.IpAddress` | The IP address of the UPF’s N3 interface. | `10.100.50.233` | +| `upf.n4if.IpAddress` | The IP address of the UPF’s N4 interface. | `10.100.50.241` | +| `upf.n6if.IpAddress` | The IP address of the UPF’s N6 interface. | `10.100.100.12` | + +### UPF1 parameters +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. + +| Parameter | Description | Default value | +| --- | --- | --- | +| `upf1.name` | The Network Function name of UPF1. | `upf1` | +| `upf1.replicaCount` | The number of UPF1 replicas. | `1` | +| `upf.image.name` | The UPF Docker image name. | `towards5gs/free5gc-upf` | +| `upf.image.tag` | The UPF Docker image tag. | `defaults to the chart AppVersion` | +| `upf1.configmap.name` | The name of the configmap to be used to import the configuration to the UPF1 POD. | `upf1-configmap` | +| `upf1.volume.name` | The name of the volume to be mounted to the UPF1 POD. | `upf1-volume` | +| `upf1.volume.mount` | The path to the folder where configuration files should be mounted. | `/free5gc/config/` | +| `upf1.n4if.IpAddress` | The IP address of the UPF1’s N4 interface. | `10.100.50.242` | +| `upf1.n6if.IpAddress` | The IP address of the UPF1’s N6 interface. | `10.100.100.13` | +| `upf1.n9if.IpAddress` | The IP address of the UPF1’s N9 interface. | `10.100.50.226` | + +### UPF2 parameters +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. + +| Parameter | Description | Default value | +| --- | --- | --- | +| `upf2.name` | The Network Function name of UPF2. | `upf2` | +| `upf2.replicaCount` | The number of UPF2 replicas. | `1` | +| `upf.image.name` | The UPF Docker image name. | `towards5gs/free5gc-upf` | +| `upf.image.tag` | The UPF Docker image tag. | `defaults to the chart AppVersion` | +| `upf2.configmap.name` | The name of the configmap to be used to import the configuration to the UPF2 POD. | `upf2-configmap` | +| `upf2.volume.name` | The name of the volume to be mounted to the UPF2 POD. | `upf2-volume` | +| `upf2.volume.mount` | The path to the folder where configuration files should be mounted. | `/free5gc/config/` | +| `upf2.n4if.IpAddress` | The IP address of the UPF2’s N4 interface. | `10.100.50.243` | +| `upf2.n6if.IpAddress` | The IP address of the UPF2’s N6 interface. | `10.100.100.14` | +| `upf2.n9if.IpAddress` | The IP address of the UPF2’s N9 interface. | `10.100.50.227` | + +### UPFb parameters +These parameters if `global.userPlaneArchitecture` is set to `ulcl`. + +| Parameter | Description | Default value | +| --- | --- | --- | +| `upfb.name` | The Network Function name of UPFb. | `upfb` | +| `upfb.replicaCount` | The number of UPFb replicas. | `1` | +| `upf.image.name` | The UPF Docker image name. | `towards5gs/free5gc-upf` | +| `upf.image.tag` | The UPF Docker image tag. | `defaults to the chart AppVersion` | +| `upfb.configmap.name` | The name of the configmap to be used to import the configuration to the UPFb POD. | `upfb-configmap` | +| `upfb.volume.name` | The name of the volume to be mounted to the UPFb POD. | `upfb-volume` | +| `upfb.volume.mount` | The path to the folder where configuration files should be mounted. | `/free5gc/config/` | +| `upfb.n3if.IpAddress` | The IP address of the UPFb’s N3 interface. | `10.100.50.233` | +| `upfb.n4if.IpAddress` | The IP address of the UPFb’s N4 interface. | `10.100.50.241` | +| `upfb.n6if.IpAddress` | The IP address of the UPFb’s N6 interface. | `10.100.100.12` | +| `upfb.n9if.IpAddress` | The IP address of the UPFb’s N9 interface. | `10.100.50.225` | + +## Known limitations +Currently, this Helm chart uses the [MACVLAN plugin](https://www.cni.dev/plugins/main/macvlan/) for all network attachment definition. However, the use of a Userspace CNI plugin like [SR-IOV] is necessary for user plane traffic (N3 and N6 interfaces). Using this CNI plugin may be possible in next versions. + +## Reference + - https://github.com/free5gc/free5gc + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/NOTES.txt new file mode 100644 index 00000000..b69e6126 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/NOTES.txt @@ -0,0 +1,15 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# +# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm +# diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/_helpers.tpl new file mode 100644 index 00000000..d40b6817 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/_helpers.tpl @@ -0,0 +1,108 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-upf.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-upf.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-upf.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-upf.labels" -}} +helm.sh/chart: {{ include "free5gc-upf.chart" . }} +{{ include "free5gc-upf.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-upf.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-upf.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +UPF Pod Annotations +*/}} +{{- define "free5gc-upf.upfAnnotations" -}} +{{- with .Values.upf }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +UPFb Pod Annotations +*/}} +{{- define "free5gc-upf.upfbAnnotations" -}} +{{- with .Values.upfb }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +UPF1 Pod Annotations +*/}} +{{- define "free5gc-upf.upf1Annotations" -}} +{{- with .Values.upf1 }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +UPF2 Pod Annotations +*/}} +{{- define "free5gc-upf.upf2Annotations" -}} +{{- with .Values.upf2 }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n3-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n3-nad.yaml new file mode 100644 index 00000000..85b8c391 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n3-nad.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n3network.name }}-{{ include "free5gc-upf.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n3network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n3network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n4-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n4-nad.yaml new file mode 100644 index 00000000..32ea9285 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n4-nad.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n4network.name }}-{{ include "free5gc-upf.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n4network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n4network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n6-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n6-nad.yaml new file mode 100644 index 00000000..8c8032c3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n6-nad.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n6network.name }}-{{ include "free5gc-upf.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n6network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n6network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n9-nad.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n9-nad.yaml new file mode 100644 index 00000000..1a3bb366 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf-n9-nad.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n9network.name }}-{{ include "free5gc-upf.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n9network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n9network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-configmap.yaml new file mode 100644 index 00000000..7f99d606 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-configmap.yaml @@ -0,0 +1,53 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "single" }} +{{- with .Values.upf }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + upfcfg.yaml: | + info: + version: 1.0.0 + description: UPF configuration + + configuration: + {{- toYaml .configuration.configuration | nindent 6 }} + + pfcp: + - addr: {{ .n4if.ipAddress }} + + gtpu: + - addr: {{ .n3if.ipAddress }} + # [optional] gtpu.name + # - name: upf.5gc.nctu.me + # [optional] gtpu.ifname + # - ifname: gtpif + + wrapper.sh: | + #!/bin/bash + + ### Implement networking rules + iptables -A FORWARD -j ACCEPT + iptables -t nat -A POSTROUTING -s {{ $.Values.global.uesubnet }} -o n6 -j MASQUERADE # route traffic comming from the UE SUBNET to the interface N6 + echo "1200 n6if" >> /etc/iproute2/rt_tables # create a routing table for the interface N6 + ip rule add from {{ $.Values.global.uesubnet }} table n6if # use the created ip table to route the traffic comming from the UE SUBNET + ip route add default via {{ $.Values.global.n6network.gatewayIP }} dev n6 table n6if # add a default route in the created table so that all UEs will use this gateway for external communications (target IP not in the Data Network attached to the interface N6) and then the Data Network will manage to route the traffic + + /free5gc/free5gc-upfd/free5gc-upfd -f {{ .volume.mount }}/upfcfg.yaml + +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-deployment.yaml new file mode 100644 index 00000000..e7c8f676 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-deployment.yaml @@ -0,0 +1,114 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "single" }} +{{- with .Values.upf }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-upf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-upf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-upf.upfAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n3network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n3", + "ips": [ "{{ .n3if.ipAddress }}/{{ $.Values.global.n3network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n3network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n6network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n6", + "ips": [ "{{ .n6if.ipAddress }}/{{ $.Values.global.n6network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n6network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n4network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n4", + "ips": [ "{{ .n4if.ipAddress }}/{{ $.Values.global.n4network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n4network.gatewayIP }}" ] + } + ]' + checksum/config: {{ include (print $.Template.BasePath "/upf/upf-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - args: ["UDP4-RECVFROM:21522,fork", "UDP4-SENDTO:{{ .n3if.ipAddress }}:2152"] + command: ["/usr/bin/socat"] + image: numtide/docker-host-forwarder + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + name: forwarder + ports: + - containerPort: 21522 + name: n3 + protocol: UDP + resources: + {{- toYaml .resources | nindent 12 }} + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - name: n4 + containerPort: 8805 + protocol: UDP + command: ["{{ .volume.mount }}/wrapper.sh"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: upfcfg.yaml + path: upfcfg.yaml + - key: wrapper.sh + path: wrapper.sh + mode: 0777 +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-hpa.yaml new file mode 100644 index 00000000..e668358e --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-hpa.yaml @@ -0,0 +1,44 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "single" }} +{{- with .Values.upf }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-upf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-service.yaml new file mode 100644 index 00000000..4709dd3b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf/upf-service.yaml @@ -0,0 +1,34 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI, Michal Chabiera +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.upf }} +{{- if $.Values.global.upf.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ $.Values.global.upf.service.name }} + labels: + {{- include "free5gc-upf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ $.Values.global.upf.service.type }} + ports: + - name: michal + port: {{ $.Values.global.upf.service.port }} + nodePort: {{ $.Values.global.upf.service.nodeport }} + protocol: {{ $.Values.global.upf.service.protocol }} + selector: + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-configmap.yaml new file mode 100644 index 00000000..e5d12522 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-configmap.yaml @@ -0,0 +1,53 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf1 }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + upfcfg.yaml: | + info: + version: 1.0.0 + description: UPF configuration + + configuration: + {{- toYaml .configuration.configuration | nindent 6 }} + + pfcp: + - addr: {{ .n4if.ipAddress }} + + gtpu: + - addr: {{ .n9if.ipAddress }} + # [optional] gtpu.name + # - name: upf.5gc.nctu.me + # [optional] gtpu.ifname + # - ifname: gtpif + + wrapper.sh: | + #!/bin/bash + + ### Implement networking rules + iptables -A FORWARD -j ACCEPT + iptables -t nat -A POSTROUTING -s {{ $.Values.global.uesubnet }} -o n6 -j MASQUERADE # route traffic comming from the UE SUBNET to the interface N6 + echo "1200 n6if" >> /etc/iproute2/rt_tables # create a routing table for the interface N6 + ip rule add from {{ $.Values.global.uesubnet }} table n6if # use the created ip table to route the traffic comming from the UE SUBNET + ip route add default via {{ $.Values.global.n6network.gatewayIP }} dev n6 table n6if # add a default route in the created table so that all UEs will use this gateway for external communications (target IP not in the Data Network attached to the interface N6) and then the Data Network will manage to route the traffic + + /free5gc/free5gc-upfd/free5gc-upfd -f {{ .volume.mount }}/upfcfg.yaml + +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-deployment.yaml new file mode 100644 index 00000000..7f56a84f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-deployment.yaml @@ -0,0 +1,101 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf1 }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-upf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-upf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-upf.upf1Annotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n9network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n9", + "ips": [ "{{ .n9if.ipAddress }}/{{ $.Values.global.n9network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n9network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n6network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n6", + "ips": [ "{{ .n6if.ipAddress }}/{{ $.Values.global.n6network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n6network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n4network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n4", + "ips": [ "{{ .n4if.ipAddress }}/{{ $.Values.global.n4network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n4network.gatewayIP }}" ] + } + ]' + checksum/config: {{ include (print $.Template.BasePath "/upf1/upf1-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - name: n4 + containerPort: 8805 + protocol: UDP + command: ["{{ .volume.mount }}/wrapper.sh"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: upfcfg.yaml + path: upfcfg.yaml + - key: wrapper.sh + path: wrapper.sh + mode: 0777 +{{- end }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-hpa.yaml new file mode 100644 index 00000000..ed2b3d40 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf1/upf1-hpa.yaml @@ -0,0 +1,45 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf1 }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-upf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-configmap.yaml new file mode 100644 index 00000000..b666b807 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-configmap.yaml @@ -0,0 +1,54 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf2 }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + upfcfg.yaml: | + info: + version: 1.0.0 + description: UPF configuration + + configuration: + {{- toYaml .configuration.configuration | nindent 6 }} + + pfcp: + - addr: {{ .n4if.ipAddress }} + + gtpu: + - addr: {{ .n9if.ipAddress }} + # [optional] gtpu.name + # - name: upf.5gc.nctu.me + # [optional] gtpu.ifname + # - ifname: gtpif + + wrapper.sh: | + #!/bin/bash + + ### Implement networking rules + iptables -A FORWARD -j ACCEPT + iptables -t nat -A POSTROUTING -s {{ $.Values.global.uesubnet }} -o n6 -j MASQUERADE # route traffic comming from the UE SUBNET to the interface N6 + echo "1200 n6if" >> /etc/iproute2/rt_tables # create a routing table for the interface N6 + ip rule add from {{ $.Values.global.uesubnet }} table n6if # use the created ip table to route the traffic comming from the UE SUBNET + ip route add default via {{ $.Values.global.n6network.gatewayIP }} dev n6 table n6if # add a default route in the created table so that all UEs will use this gateway for external communications (target IP not in the Data Network attached to the interface N6) and then the Data Network will manage to route the traffic + + /free5gc/free5gc-upfd/free5gc-upfd -f {{ .volume.mount }}/upfcfg.yaml + +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-deployment.yaml new file mode 100644 index 00000000..e2b5a5ee --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-deployment.yaml @@ -0,0 +1,101 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf2 }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-upf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-upf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-upf.upf2Annotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n9network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n9", + "ips": [ "{{ .n9if.ipAddress }}/{{ $.Values.global.n9network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n9network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n6network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n6", + "ips": [ "{{ .n6if.ipAddress }}/{{ $.Values.global.n6network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n6network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n4network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n4", + "ips": [ "{{ .n4if.ipAddress }}/{{ $.Values.global.n4network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n4network.gatewayIP }}" ] + } + ]' + checksum/config: {{ include (print $.Template.BasePath "/upf2/upf2-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - name: n4 + containerPort: 8805 + protocol: UDP + command: ["{{ .volume.mount }}/wrapper.sh"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: upfcfg.yaml + path: upfcfg.yaml + - key: wrapper.sh + path: wrapper.sh + mode: 0777 +{{- end }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-hpa.yaml new file mode 100644 index 00000000..cd7d002f --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upf2/upf2-hpa.yaml @@ -0,0 +1,45 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upf2 }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-upf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-configmap.yaml new file mode 100644 index 00000000..e079500b --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-configmap.yaml @@ -0,0 +1,53 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upfb }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + upfcfg.yaml: | + info: + version: 1.0.0 + description: UPF configuration + + configuration: + {{- toYaml .configuration.configuration | nindent 6 }} + + pfcp: + - addr: {{ .n4if.ipAddress }} + + gtpu: + - addr: {{ .n3if.ipAddress }} + - addr: {{ .n9if.ipAddress }} + # [optional] gtpu.name + # - name: upf.5gc.nctu.me + # [optional] gtpu.ifname + # - ifname: gtpif + + wrapper.sh: | + #!/bin/bash + + iptables -A FORWARD -j ACCEPT + iptables -t nat -A POSTROUTING -s {{ $.Values.global.uesubnet }} -o n6 -j MASQUERADE # Allow routing traffic comming from the UE SUBNET to the interface N6 + iptables -t nat -A POSTROUTING -o n9 -j MASQUERADE + iptables -t nat -A POSTROUTING -o n3 -j MASQUERADE + + /free5gc/free5gc-upfd/free5gc-upfd -f {{ .volume.mount }}/upfcfg.yaml + +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-deployment.yaml new file mode 100644 index 00000000..266a30fd --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-deployment.yaml @@ -0,0 +1,106 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upfb }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-upf.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-upf.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-upf.upfbAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + { "name": "{{ $.Values.global.n3network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n3", + "ips": [ "{{ .n3if.ipAddress }}/{{ $.Values.global.n3network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n3network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n9network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n9", + "ips": [ "{{ .n9if.ipAddress }}/{{ $.Values.global.n9network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n9network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n6network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n6", + "ips": [ "{{ .n6if.ipAddress }}/{{ $.Values.global.n6network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n6network.gatewayIP }}" ] + }, + { "name": "{{ $.Values.global.n4network.name }}-{{ include "free5gc-upf.fullname" $ }}", + "interface": "n4", + "ips": [ "{{ .n4if.ipAddress }}/{{ $.Values.global.n4network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n4network.gatewayIP }}" ] + } + ]' + checksum/config: {{ include (print $.Template.BasePath "/upfb/upfb-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-upf.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - name: n4 + containerPort: 8805 + protocol: UDP + command: ["{{ .volume.mount }}/wrapper.sh"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} + items: + - key: upfcfg.yaml + path: upfcfg.yaml + - key: wrapper.sh + path: wrapper.sh + mode: 0777 +{{- end }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-hpa.yaml new file mode 100644 index 00000000..4d901677 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/templates/upfb/upfb-hpa.yaml @@ -0,0 +1,45 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if eq .Values.global.userPlaneArchitecture "ulcl" }} +{{- with .Values.upfb }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-upf.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-upf.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/ulcl-enabled-values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/ulcl-enabled-values.yaml new file mode 100644 index 00000000..c85f9321 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/ulcl-enabled-values.yaml @@ -0,0 +1,20 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + userPlaneArchitecture: ulcl # possible values are "single" and "ulcl" + + + + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/values.yaml new file mode 100644 index 00000000..a20ea646 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-upf/values.yaml @@ -0,0 +1,326 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcUserPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + + +global: + projectName: free5gc + userPlaneArchitecture: single # possible values are "single" and "ulcl" + uesubnet: 10.1.0.0/17 +#Global network parametes + n4network: + name: n4network + masterIf: eth0 + subnetIP: 10.100.50.240 + cidr: 29 + gatewayIP: 10.100.50.246 + excludeIP: 10.100.50.246 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + n6network: + name: n6network + masterIf: eth1 + subnetIP: 10.100.100.0 + cidr: 24 + gatewayIP: 10.100.100.1 + excludeIP: 10.100.100.254 + n9network: + name: n9network + masterIf: eth0 + subnetIP: 10.100.50.224 + cidr: 29 + gatewayIP: 10.100.50.230 + excludeIP: 10.100.50.230 + +upf: + name: upf + replicaCount: 1 + image: + name: towards5gs/free5gc-upf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: upf-configmap + volume: + name: upf-volume + mount: /free5gc/config/ + + # network paramters + n3if: # GTP-U + ipAddress: 10.100.50.233 + n4if: # PFCP + ipAddress: 10.100.50.241 + n6if: # DN + ipAddress: 192.169.110.112 + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 500m + memory: 512Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + configuration: + configuration: + # debugLevel: panic|fatal|error|warn|info|debug|trace + debugLevel: info + ReportCaller: false + + dnn_list: + - dnn: internet + cidr: 10.1.0.0/17 + # [optional] apn_list[*].natifname + natifname: n6 + + +# The followed values will be considered in the case of choosing "ulcl" architecture for the user plane +upf1: + name: upf1 + replicaCount: 1 + image: + name: towards5gs/free5gc-upf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: upf1-configmap + volume: + name: upf1-volume + mount: /free5gc/config/ + + # network paramters + n9if: # GTP-U + ipAddress: 10.100.50.226 + n4if: # PFCP + ipAddress: 10.100.50.242 + n6if: # DN + ipAddress: 10.100.100.13 + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 500m + memory: 512Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + configuration: + configuration: + # debugLevel: panic|fatal|error|warn|info|debug|trace + debugLevel: info + ReportCaller: false + + dnn_list: + - dnn: internet + cidr: 10.1.0.0/17 + # [optional] apn_list[*].natifname + natifname: n6 + +upf2: + name: upf2 + replicaCount: 1 + image: + name: towards5gs/free5gc-upf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: upf2-configmap + volume: + name: upf2-volume + mount: /free5gc/config/ + + # network paramters + n9if: # GTP-U + ipAddress: 10.100.50.227 + n4if: # PFCP + ipAddress: 10.100.50.243 + n6if: # DN + ipAddress: 10.100.100.14 + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 500m + memory: 512Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + configuration: + configuration: + # debugLevel: panic|fatal|error|warn|info|debug|trace + debugLevel: info + ReportCaller: false + + dnn_list: + - dnn: internet + cidr: 10.1.0.0/17 + # [optional] apn_list[*].natifname + natifname: n6 + +upfb: + name: upfb + replicaCount: 1 + image: + name: towards5gs/free5gc-upf + tag: "v3.0.5" + pullPolicy: IfNotPresent + configmap: + name: upfb-configmap + volume: + name: upfb-volume + mount: /free5gc/config/ + + # network paramters + n3if: # GTP-U + ipAddress: 10.100.50.233 + n9if: # GTP-U + ipAddress: 10.100.50.225 + n4if: # PFCP + ipAddress: 10.100.50.241 + n6if: # DN + ipAddress: 10.100.100.12 + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 500m + memory: 512Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + configuration: + configuration: + # debugLevel: panic|fatal|error|warn|info|debug|trace + debugLevel: info + ReportCaller: false + + dnn_list: + - dnn: internet + cidr: 10.1.0.0/17 + # [optional] apn_list[*].natifname + # natifname: n6 diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/.helmignore b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/Chart.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/Chart.yaml new file mode 100644 index 00000000..4d68e2cd --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/Chart.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: free5gc-webui +description: A Helm chart to deploy the Free5GC WEBUI +type: application +version: 0.1.0 +appVersion: v3.0.5 +dependencies: +- name: mongodb + condition: db.enabled +icon: https://camo.githubusercontent.com/915dcf8299b3d2bfe2b2693c5401916cb31e31fb690a73e7da327808000efa37/68747470733a2f2f666f72756d2e667265653567632e6f72672f75706c6f6164732f64656661756c742f6f726967696e616c2f31582f333234363935626663363438316264353536633131303138663238333430383663663565633634352e706e67 +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI + - email: ayoub.bousselmi@orange.com + name: Ayoub BOUSSELMI diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/NOTES.txt new file mode 100644 index 00000000..1760fafa --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/NOTES.txt @@ -0,0 +1,36 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +1. Get the application URL by running these commands: +{{- if .ingress.enabled }} +{{- range $host := .ingress.hosts }} + {{- range .paths }} + http{{ if $.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .service.type }} + export NODE_PORT=$(kubectl get --namespace {{ $.Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ .service.name }}) + export NODE_IP=$(kubectl get nodes --namespace {{ $.Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ .service.name }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ .service.name }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .service.port }} +{{- else if contains "ClusterIP" .service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "app.kubernetes.io/name={{ include "free5gc-webui.name" $ }},app.kubernetes.io/instance={{ $.Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ $.Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/_helpers.tpl b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/_helpers.tpl new file mode 100644 index 00000000..478ef265 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/_helpers.tpl @@ -0,0 +1,75 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "free5gc-webui.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "free5gc-webui.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "free5gc-webui.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "free5gc-webui.labels" -}} +helm.sh/chart: {{ include "free5gc-webui.chart" . }} +{{ include "free5gc-webui.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "free5gc-webui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "free5gc-webui.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +WEBUI Pod Annotations +*/}} +{{- define "free5gc-webui.webuiAnnotations" -}} +{{- with .Values.webui }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/tests/test-connection.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/tests/test-connection.yaml new file mode 100644 index 00000000..d1c26448 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/tests/test-connection.yaml @@ -0,0 +1,29 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "free5gc-webui.fullname" $ }}-test-connection" + labels: + {{- include "free5gc-webui.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ .service.name }}:{{ .service.port }}'] + restartPolicy: Never +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-configmap.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-configmap.yaml new file mode 100644 index 00000000..573667d4 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-configmap.yaml @@ -0,0 +1,31 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.global.projectName }} +data: + webuicfg.yaml: | + info: + version: 1.0.0 + description: WEBUI initial local configuration + + configuration: + mongodb: + name: free5gc + url: mongodb://{{ $.Values.mongodb.service.name }}:{{ $.Values.mongodb.service.port }} + +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-deployment.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-deployment.yaml new file mode 100644 index 00000000..50bfcfef --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-deployment.yaml @@ -0,0 +1,107 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "free5gc-webui.fullname" $ }}-{{ .name }} + labels: + {{- include "free5gc-webui.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + {{- if not .autoscaling.enabled }} + replicas: {{ .replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "free5gc-webui.selectorLabels" $ | nindent 6 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + template: + metadata: + annotations: + {{- include "free5gc-webui.webuiAnnotations" $ | nindent 8 }} + checksum/config: {{ include (print $.Template.BasePath "/webui-configmap.yaml") $ | sha256sum }} + labels: + {{- include "free5gc-webui.selectorLabels" $ | nindent 8 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + initContainers: + - name: wait-mongo + {{- with $.Values.initcontainers.busybox }} + image: {{ .image }}:{{ .tag }} + {{- end }} + env: + - name: DEPENDENCIES + {{- with $.Values.mongodb.service }} + value: {{ .name }}:{{ .port }} + {{- end }} + command: ["sh", "-c", "until nc -z $DEPENDENCIES; do echo waiting for the MongoDB; sleep 2; done;"] + containers: + - name: {{ .name }} + image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ .image.pullPolicy }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + ports: + - containerPort: {{ .service.port }} + command: ["./webconsole"] + args: ["-webuicfg", "../config/webuicfg.yaml"] + env: + - name: GIN_MODE + value: release + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + readinessProbe: + initialDelaySeconds: {{ .readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .readinessProbe.periodSeconds }} + timeoutSeconds: {{ .readinessProbe.timeoutSeconds }} + failureThreshold: {{ .readinessProbe.failureThreshold }} + successThreshold: {{ .readinessProbe.successThreshold }} + httpGet: + scheme: HTTP + port: {{ .service.port }} + livenessProbe: + initialDelaySeconds: {{ .livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .livenessProbe.periodSeconds }} + timeoutSeconds: {{ .livenessProbe.timeoutSeconds }} + failureThreshold: {{ .livenessProbe.failureThreshold }} + successThreshold: {{ .livenessProbe.successThreshold }} + httpGet: + scheme: HTTP + port: {{ .service.port }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + projected: + sources: + - configMap: + name: {{ .configmap.name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-hpa.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-hpa.yaml new file mode 100644 index 00000000..492fe322 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-hpa.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +{{- if .autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "free5gc-webui.fullname" . }}-{{ .name }}-hpa + labels: + {{- include "free5gc-webui.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "free5gc-webui.fullname" . }}-{{ .name }} + minReplicas: {{ .autoscaling.minReplicas }} + maxReplicas: {{ .autoscaling.maxReplicas }} + metrics: + {{- if .autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-ingress.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-ingress.yaml new file mode 100644 index 00000000..00bfa3fb --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-ingress.yaml @@ -0,0 +1,55 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +{{- if .ingress.enabled -}} +{{- $fullName := .service.name -}} +{{- $svcPort := .service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "free5gc-webui.labels" . | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} + annotations: + {{- toYaml .ingress.annotations | nindent 4 }} +spec: + {{- if .ingress.tls }} + tls: + {{- range .ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-service.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-service.yaml new file mode 100644 index 00000000..f83c1d87 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/templates/webui-service.yaml @@ -0,0 +1,34 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.webui }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.name }} + labels: + {{- include "free5gc-webui.labels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +spec: + type: {{ .service.type }} + ports: + - port: {{ .service.port }} + targetPort: {{ .service.port }} + nodePort: {{ .service.nodePort }} + protocol: TCP + name: http + selector: + {{- include "free5gc-webui.selectorLabels" $ | nindent 4 }} + project: {{ $.Values.global.projectName }} + nf: {{ .name }} +{{- end }} \ No newline at end of file diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/values.yaml new file mode 100644 index 00000000..d49bfaa9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/charts/free5gc-webui/values.yaml @@ -0,0 +1,112 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gcControlPlane chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +global: + projectName: free5gc + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + +initcontainers: + curl: + registry: towards5gs + image: initcurl + tag: "1.0.0" + busybox: + image: busybox + tag: "1.32.0" + +db: + enabled: false +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" + +webui: + name: webui + replicaCount: 1 + image: + name: towards5gs/free5gc-webui + tag: "v3.0.5" + pullPolicy: IfNotPresent + service: + name: webui-service + type: NodePort + port: 5000 + nodePort: 30500 + configmap: + name: webui-configmap + volume: + name: webui-volume + mount: /free5gc/config/ + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: {} + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + initialDelaySeconds: 0 + periodSeconds: 1 + timeoutSeconds: 1 + failureThreshold: 40 + successThreshold: 1 + livenessProbe: + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 10 + failureThreshold: 3 + successThreshold: 1 + nodeSelector: {} + tolerations: [] + affinity: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + configuration: {} diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/services-enabled-values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/services-enabled-values.yaml new file mode 100644 index 00000000..d8ad9ed7 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/services-enabled-values.yaml @@ -0,0 +1,30 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + amf: + service: + ngap: + enabled: true + name: amf-n2 + port: 38412 + nodeport: 31412 + protocol: SCTP + type: NodePort + n2network: + enabled: false + + + + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/templates/NOTES.txt b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/templates/NOTES.txt new file mode 100644 index 00000000..1a2dc926 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/templates/NOTES.txt @@ -0,0 +1,18 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# +# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm +# + +1. Get the list of created Pods by running: + kubectl get pods --namespace {{ $.Release.Namespace }} -l "project={{ $.Values.global.projectName }}" diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/ulcl-enabled-values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/ulcl-enabled-values.yaml new file mode 100644 index 00000000..26af0954 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/ulcl-enabled-values.yaml @@ -0,0 +1,120 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + userPlaneArchitecture: ulcl # possible values are "single" and "ulcl" + +free5gc-smf: + smf: + configuration: + configuration: |- + smfName: SMF + serviceNameList: + - nsmf-pdusession + - nsmf-event-exposure + - nsmf-oam + snssaiInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.0.0/17 # should be CIDR type + - sNssai: + sst: 1 + sd: 112233 + dnnInfos: # DNN information list + - dnn: internet # Data Network Name + dns: # the IP address of DNS + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.1.128.0/17 # should be CIDR type ????? + - sNssai: + sst: 2 + sd: 112234 + dnnInfos: + - dnn: internet + dns: + ipv4: 8.8.8.8 + ipv6: 2001:4860:4860::8888 + ueSubnet: 10.2.0.0/16 + userplane_information: + up_nodes: + gNB1: + type: AN + an_ip: 10.100.50.236 + BranchingUPF: + type: UPF + node_id: 10.100.50.241 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + - sNssai: + sst: 1 + sd: 112233 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N3 + endpoints: + - 10.100.50.233 + networkInstance: internet + - interfaceType: N9 + endpoints: + - 10.100.50.225 + networkInstance: internet + AnchorUPF1: + type: UPF + node_id: 10.100.50.242 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N9 + endpoints: + - 10.100.50.226 # UPF1 N9 address + networkInstance: internet + AnchorUPF2: + type: UPF + node_id: 10.100.50.243 # PFCP address + sNssaiUpfInfos: + - sNssai: + sst: 1 + sd: 010203 + dnnUpfInfoList: + - dnn: internet + interfaces: + - interfaceType: N9 + endpoints: + - 10.100.50.227 # UPF2 N9 address + networkInstance: internet + links: + - A: gNB1 + B: BranchingUPF + - A: BranchingUPF + B: AnchorUPF1 + - A: BranchingUPF + B: AnchorUPF2 + + + + + diff --git a/tutorials/xNF_5G/free5gc/templates/helm/free5gc/values.yaml b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/values.yaml new file mode 100644 index 00000000..ca1f20f9 --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/helm/free5gc/values.yaml @@ -0,0 +1,123 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for free5gc-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + name: free5gc + userPlaneArchitecture: single # possible values are "single" and "ulcl" + nrf: + service: + name: nrf-nnrf + type: ClusterIP + port: "8000" + nodePort: "30800" + sbi: + scheme: http + amf: + n2if: # NGAP + ipAddress: 10.100.50.249 + service: + ngap: + enabled: true + name: amf-n2 + port: 38412 + nodeport: 38412 + protocol: SCTP + type: NodePort + smf: + n4if: + ipAddress: 10.100.50.244 + upf: + n6if: + ipAddress: 192.169.110.112 + service: + enabled: false + name: upf-service + type: NodePort + protocol: UDP + port: 21522 + nodeport: 2152 + + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + n4network: + name: n4network + masterIf: eth0 + subnetIP: 10.100.50.240 + cidr: 29 + gatewayIP: 10.100.50.246 + excludeIP: 10.100.50.246 + n6network: + name: n6network + masterIf: eth1 + subnetIP: 192.169.110.0 + cidr: 24 + gatewayIP: 192.169.110.1 + excludeIP: 192.169.110.254 + n9network: + name: n9network + masterIf: eth0 + subnetIP: 10.100.50.224 + cidr: 29 + gatewayIP: 10.100.50.230 + excludeIP: 10.100.50.230 + + +# These parameters can be used to enable/disable deployment of subcharts +deployMongoDB: true +deployAMF: true +deployAUSF: true +deployN3IWF: true +deployNRF: true +deployNSSF: true +deployPCF: true +deploySMF: true +deployUDM: true +deployUDR: true +deployUPF: true +deployWEBUI: true + +# Disable the deployment of mongodb as an NRF subchart +free5gc-nrf: + db: + enabled: false + +# This section can be used to override the default values in the MongoDB chart (remember MongoDB is a subchart of the free5gcControlplane chart since control plane NFs rely on it. +mongodb: + fullnameOverride: "mongodb" + useStatefulSet: true + auth: + enabled: false + persistence: + size: 6Gi + mountPath: /bitnami/mongodb/data/db/ + service: + name: mongodb + type: ClusterIP + port: 27017 + nodePort: "30017" diff --git a/tutorials/xNF_5G/free5gc/templates/tools/tail_all.sh b/tutorials/xNF_5G/free5gc/templates/tools/tail_all.sh new file mode 100644 index 00000000..d18674ea --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/tools/tail_all.sh @@ -0,0 +1,161 @@ +#!/bin/bash +# COPYRIGHT NOTICE STARTS HERE + +# Copyright 2020 . Samsung Electronics Co., Ltd. +# +# 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 NOTICE ENDS HERE + +set -e + +get_pod_name() { + kubectl -n ${NAMESPACE} get pod -l app="$1" -o jsonpath='{ .items[0].metadata.name }' +} + +exec_in_pod() { + local pod="$1" + local container="$2" + shift 2 + local cmd="$@" + kubectl --namespace ${NAMESPACE} exec ${pod} --container ${container} -- sh -c "${cmd}" +} + +pod_logs() { + local pod="$1" + local container="$2" + local options="$3" + shift 3 + kubectl --namespace ${NAMESPACE} logs ${pod} --container ${container} ${options:+"${options}"} +} + +k8s_tail() { + local operation="$1" + local file_to_tail="$2" + local pod_label="$3" + local container="$4" + if [ -z ${container} ]; then + container=${pod_label} + fi + mkdir -p ${CACHE_FILE_DIR} + local pod=$(get_pod_name ${pod_label}) + file_path_savable_form="$(sed 's#/#__#g' <<<"$file_to_tail")" + LINECOUNT_CACHE_FILE=${CACHE_FILE_DIR}/${pod}-${container}-${file_path_savable_form} + local line_count=0 + if [ "${operation}" == "start" ]; then + if [ "${file_to_tail}" == "POD_LOG" ]; then + line_count=$(pod_logs ${pod} ${container} "" | wc -l) + else + if ! line_count=$(exec_in_pod ${pod} ${container} "wc -l ${file_to_tail}"); then + echo "Failed to get file ${file_to_tail} line count, maybe it does not exist. Using linecount 0." >&2 + line_count=0 + else + # parse out linecount from wc -l output + line_count=$(echo -e "${line_count}" | tail -1 | cut -d' ' -f1) + fi + fi + echo "${line_count}" > ${LINECOUNT_CACHE_FILE} + echo "Saved file ${file_to_tail} of POD ${pod_label} linecount ${line_count} into file ${LINECOUNT_CACHE_FILE}" + fi + if [ "${operation}" == "collect" ]; then + if [ ! -f ${LINECOUNT_CACHE_FILE} ]; then + echo "Linecount cache file ${LINECOUNT_CACHE_FILE} not found. Either tailing was not started or POD has restarted. Colected from log beginning." >&2 + start_line=0 + else + start_line=$(cat ${LINECOUNT_CACHE_FILE}) + fi + echo "Tail pod's ${pod_label} container ${container} file ${file_to_tail} starting from line ${start_line} onwards" >&2 + if [ "${file_to_tail}" == "POD_LOG" ]; then + current_line_count=$(pod_logs ${pod} ${container} "" | wc -l) + lines_from_end=$(( ${current_line_count}-${start_line} )) + echo "Execute kubectl logs for ${pod} POD's ${container} container. Log ${lines_from_end} lines from end" + pod_logs ${pod} ${container} --tail=${lines_from_end} + else + echo "Execute cmd "tail -n +${start_line} ${file_to_tail}" inside ${pod} POD's ${container} container" + exec_in_pod ${pod} ${container} "tail -n +${start_line} ${file_to_tail}" + fi + fi +} + +tail_it() { + local operation=$1 + for tail in "${TAILS[@]}" + do + tailarray=(${tail}) + result=$(k8s_tail ${operation} ${tailarray[@]}) + if [ "${operation}" == "collect" ]; then + mkdir -p ${RESULT_DIR} + log_file=$(basename ${tailarray[0]}) + if [ "${log_file}" == "POD_LOG" ]; then + log_file=${log_file}.log + fi + pod=${tailarray[1]} + container="${pod:-tailarray[2]}" + out_file=${RESULT_DIR}/${pod}_${container}_${log_file} + echo -e "${result}" > ${out_file} + echo "Saved tail content to log file ${out_file}" + else + echo -e "${result}" + fi + done +} + + +##### MAIN ##### +if [ -f ./tail_config ]; then +. ./tail_config +fi +NAMESPACE=${NAMESPACE:-onap} +CACHE_FILE_DIR=${CACHE_FILE_DIR:-.k8s_tail} +RESULT_DIR=${RESULT_DIR:-./tail_results} +DEFAULT_TAILS=() +TAILS=("${TAILS[@]:-${DEFAULT_TAILS[@]}}") + +case "$1" in + -h|--help|help|?|"") + echo "Script usage:" + echo "$0 start - Start pods' log tailing" + echo "$0 collect - Collect all logs currently tailed or get all logs as whole" + echo "" + echo "If start is not called before collect is called, collect gathers all logs completely. " + echo "Otherwise logs are collected only from the linecount of the time of start call." + echo "" + echo "Log files collected is configured with 'tail_config' file in the same directory with the script." + echo "Config file needs to fontain bash array variable named TAILS=() and format of each entry in array is" + echo " []" + echo "where is actual file path inside the pod or special string 'POD_LOG' that means kubectl logs" + echo "where optional is to specify POD's container if many containers in the pod. By default same name as pod is used." + echo "" + echo 'Example: TAILS=(' + echo ' "/app/logs/apih/metrics.log so"' + echo ' "/app/logs/bpmn/debug.log so-bpmn-infra"' + echo ' "/app/logs/vnfm-adapter/debug.log so-vnfm-adapter"' + echo ' "/var/log/onap/sdnc/karaf.log sdnc"' + echo ' "/tmp/app.out network-name-gen"' + echo ' "POD_LOG cds-blueprints-processor"' + echo ' "POD_LOG multicloud multicloud"' + echo ' "POD_LOG multicloud-k8s multicloud-k8s"' + echo ' "POD_LOG multicloud-k8s framework-artifactbroker"' + echo ' "/app/logs/openstack/error.log so-openstack-adapter"' + echo ' "/app/logs/openstack/debug.log so-openstack-adapter"' + echo ' )' + echo "" + ;; + start|collect) + tail_it $1 + ;; + *) + echo "Wrong usage, check '$0 -h'" >&2 + exit 1 + ;; +esac diff --git a/tutorials/xNF_5G/free5gc/templates/tools/tail_config b/tutorials/xNF_5G/free5gc/templates/tools/tail_config new file mode 100644 index 00000000..ca49793c --- /dev/null +++ b/tutorials/xNF_5G/free5gc/templates/tools/tail_config @@ -0,0 +1,18 @@ +#!/bin/false + +NAMESPACE="onap" + +TAILS=( + "/app/logs/apih/debug.log so" + "/app/logs/apih/error.log so" + "/app/logs/bpmn/debug.log so-bpmn-infra" + "/app/logs/openstack/error.log so-openstack-adapter" + "/app/logs/openstack/debug.log so-openstack-adapter" + "/var/log/onap/sdnc/karaf.log sdnc" + "POD_LOG network-name-gen" + "POD_LOG cds-blueprints-processor" + "POD_LOG multicloud multicloud" + "POD_LOG multicloud-k8s multicloud-k8s" + "POD_LOG multicloud-k8s framework-artifactbroker" + "POD_LOG msb-iag msb-iag" +) diff --git a/tutorials/xNF_5G/ueransim/README.txt b/tutorials/xNF_5G/ueransim/README.txt new file mode 100644 index 00000000..d1130908 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/README.txt @@ -0,0 +1,13 @@ +Demo directory structure: + +/templates/ #Base directory containing vFW resources + |- /base_dummy #Directory containing base payload of VSP package in OpenStack VSP format, doesn't need further proceeding + |- /base_native #Directory containing base payload of VSP package in Helm VSP, doesn't need further proceeding + |- /helm #Directory containing helm charts that need to be packaged and attached to VSP package + \- /cba #Directory containing CBA content to be included to csar package. It is prepared for +/examples/ #Directory with context-specific overrides over general resources +/automation/ #Directory with automation scripts. For more details read README file inside. + +Note: Makefile script generates two VSP packages, one in Frankfurt format with helm associated with dummy heat templates and second +with native Helm VSP format where helm packages are standalone. CBA folder contains CBA Definition for native VSP format but +make is coverting the definition into Frankfurt format for Frankfurt VSP. Frankfurt VSP is still supported in Guilin. diff --git a/tutorials/xNF_5G/ueransim/automation/Pipfile b/tutorials/xNF_5G/ueransim/automation/Pipfile new file mode 100644 index 00000000..e038fbed --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/Pipfile @@ -0,0 +1,13 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +onapsdk = "9.0.0" +kubernetes = "*" + +[requires] +python_version = "3.8" diff --git a/tutorials/xNF_5G/ueransim/automation/README.md b/tutorials/xNF_5G/ueransim/automation/README.md new file mode 100644 index 00000000..41eb4f06 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/README.md @@ -0,0 +1,33 @@ +# CNF automation + +0. Make sure you have python 3.8.x installed and default interpreter, what is required by onap-pythonsdk +1. Install required packages with pipenv `pipenv install` +2. Run virtual environment `pipenv shell`. In case of problems use `--fancy` option + + **In case of problems with pipenv:** `venv` can be used as well. In that case, please install all required python packages in correct version according the list in `Pipfile` +3. Add kubeconfig file for k8s cluster that will host your CNF + - `artifacts/cluster_kubeconfig` +4. Prepare onboarding packages `cd ../templates/ && make && cd ../automation/` +5. Modify `config.py`: + - NATIVE - enables native helm orchestration path in SO + - SKIP_POST_INSTANTIATION - whether post instantiation configuration should be run + - MACRO_INSTANTIATION - instantiation method used: macro or a'la carte + - K8S_NAMESPACE - k8s namespace to use for deployment of CNF + - K8S_VERSION - version of the k8s cluster + - K8S_REGION - name of the k8s region from the CLOUD_REGIONS + - CLOUD_REGIONS - configuration of k8s or Openstack regions + - GLOBAL_CUSTOMER_ID + - VENDOR + - SERVICENAME + - VNF_PARAM_LIST - list of parameters to pass for VNF creation process + - VF_MODULE_PARAM_LIST - list of parameters to pass for VF Module creation +6. __Important:__ Before running python scripts, some settings for `onapsdk` with information about ONAP endpoints (and socks) have to be exported. + All settings for ONAP instance are located in `automation/onap_settings.py` file. To export that settings please run command inside `pipenv` or `venv` shell + ```shell + (automation) ubuntu@onap:~/automation$ export ONAP_PYTHON_SDK_SETTINGS="onap_settings" + ``` +7. Run script `python create_cloud_regions.py` in order to create **k8s or openstack cloud region** +8. Onboard CNF `python onboard.py` +9. Instantiate CNF `python instantiate.py` +10. Once test is done, CNF service instance can be deleted with `python delete.py` command + diff --git a/tutorials/xNF_5G/ueransim/automation/__init__.py b/tutorials/xNF_5G/ueransim/automation/__init__.py new file mode 100644 index 00000000..9525040e --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/__init__.py @@ -0,0 +1,19 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +from .config import Config +from .k8s_client import K8sClient diff --git a/tutorials/xNF_5G/ueransim/automation/artifacts/cluster_kubeconfig b/tutorials/xNF_5G/ueransim/automation/artifacts/cluster_kubeconfig new file mode 100644 index 00000000..e69de29b diff --git a/tutorials/xNF_5G/ueransim/automation/config.py b/tutorials/xNF_5G/ueransim/automation/config.py new file mode 100644 index 00000000..dc15582d --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/config.py @@ -0,0 +1,113 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= +from typing import Dict, Union, List +import oyaml as yaml +import os +from jinja2 import Template + + +class VariablesDict: + env_variable = { + "CI_PIPELINE_ID": os.getenv("CI_PIPELINE_ID", "2000000"), + "USER": os.getenv("USER", "default"), + "NAME_SUFFIX": os.getenv("TEST", os.getenv("CI_PIPELINE_ID")) + } + + +class Config: + def __init__(self, filename: str = "service_config.yaml", env_dict=None): + if env_dict is None: + env_dict = {} + self.filepath = os.path.join(os.path.dirname(os.path.dirname( + os.path.realpath(__file__))), filename) + # self.filepath = os.path.join(os.path.dirname( + # os.path.realpath(__file__)), '..', filename) + self.content_env: Dict = {**self._load_file(), **env_dict} + self.service_instance: Union[None, Dict] = None + self.service_model: Union[None, Dict] = None + self.user_params: Union[None, Dict] = None + self.cloud_regions: Union[None, List] = None + self.so_input: Union[None, Dict] = None + self.render() + self.so_input = self.create_so_input() + + def _load_file(self) -> dict: + with open(self.filepath) as file: + file_content = yaml.safe_load(file) + return file_content + + @staticmethod + def templating(rend_dict: dict, render_keys: dict): + for k, v in rend_dict.items(): + if isinstance(v, str): + t = Template(v) + rend_dict[k] = t.render(**render_keys) + elif isinstance(v, dict): + Config.templating(rend_dict=v, render_keys=render_keys) + elif isinstance(v, list): + for i in v: + Config.templating(rend_dict=i, render_keys=render_keys) + else: + pass + return rend_dict + + def render(self): + raw_file = self._load_file() + config_dict = self.templating( + rend_dict=raw_file, + render_keys=self.content_env) + + self.__dict__.update(**config_dict) + + def create_so_input(self) -> dict: + so_input_dict = dict() + so_input_dict["subscription_service_type"] = self.service_instance.get("model_name") + _vnfs = self.service_instance.get("vnfs") + vnfs = list() + + for vnf in _vnfs: + _vnf_raw = dict() + _vnf_raw["model_name"] = vnf.get("model_name") + if vnf.get("vnf_name_suffix"): + _vnf_raw["vnf_name"] = "Instance_" + vnf.get("model_name") + "_" + vnf.get("vnf_name_suffix") + else: + _vnf_raw["vnf_name"] = "Instance_" + vnf.get("model_name") + "_" + str(_vnfs.index(vnf)) + if vnf.get("processing_priority"): + _vnf_raw["processing_priority"] = vnf.get("processing_priority") + _vnf_raw["parameters"] = vnf.get("parameters") + _vnf_raw["vf_modules"] = list() + _vf_modules = vnf.get("vf_modules") + for vf_module in _vf_modules: + _vf_module_raw = dict() + _vf_module_raw["model_name"] = vf_module.get("model_name") + if vf_module.get("vf_module_name_suffix"): + _vf_module_raw["vf_module_name"] = \ + "Instance_" + vf_module.get("model_name") + "_" + vf_module.get("vf_module_name_suffix") + else: + _vf_module_raw["vf_module_name"] = \ + "Instance_" + vf_module.get("model_name") + "_" + str(_vf_modules.index(vf_module)) + if _vf_module_raw.get("processing_priority"): + _vf_module_raw["processing_priority"] = vf_module["processing_priority"] + _vf_module_raw["parameters"] = vf_module.get("parameters") + _vnf_raw["vf_modules"].append(_vf_module_raw) + vnfs.append(_vnf_raw) + so_input_dict["vnfs"] = vnfs + + return so_input_dict + + +config = Config(env_dict=VariablesDict.env_variable) diff --git a/tutorials/xNF_5G/ueransim/automation/create_cloud_regions.py b/tutorials/xNF_5G/ueransim/automation/create_cloud_regions.py new file mode 100644 index 00000000..461ce863 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/create_cloud_regions.py @@ -0,0 +1,202 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import os +from uuid import uuid4 + +from onapsdk.so.so_db_adapter import SoDbAdapter, IdentityService + +from config import Config +from onapsdk.exceptions import ResourceNotFound, APIError +from onapsdk.aai.cloud_infrastructure import Complex, CloudRegion +from onapsdk.msb.k8s import ConnectivityInfo + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def create_complex(complex_id): + logger.info("******** Complex *******") + try: + region_complex = next(Complex.get_all(physical_location_id=complex_id)) + logger.info("Complex exists") + return region_complex + except ResourceNotFound: + logger.info("Complex does not exist") + region_complex = Complex.create(physical_location_id=complex_id, + name=complex_id, + physical_location_type="office", + street1="DummyStreet 1", + city="DummyCity", + postal_code="00-000", + country="DummyCountry", + region="DummyRegion") + logger.info("Complex created") + return region_complex + + +def create_cloud_region(cloud_region): + logger.info("******** Cloud Region *******") + region_id = cloud_region["name"] + cloud_owner = cloud_region["cloud_owner"] + cloud_type = cloud_region["cloud_type"] + complex_id = cloud_region["complex_id"] + cloud_region_version = "1.0" if cloud_type == "k8s" else "v2.5" + try: + region = next(CloudRegion.get_all(cloud_owner=cloud_owner, cloud_region_id=region_id)) + logger.info("Cloud region exists") + return region + except ResourceNotFound: + logger.info("Cloud region does not exist") + region = CloudRegion.create(cloud_owner=cloud_owner, + cloud_region_id=region_id, + cloud_type=cloud_type, + owner_defined_type="t1", + cloud_region_version=cloud_region_version, + complex_name=complex_id, + cloud_zone="CloudZone", + sriov_automation="false", + orchestration_disabled=False, + in_maint=False) + logger.info("Cloud region created") + return region + + +def link_region_to_complex(cloud_region, complx): + logger.info("******** Cloud region <-> Complex *******") + cloud_region.link_to_complex(complex_object=complx) + + +def add_tenant(cloud_region, tenant_id, tenant_name): + logger.info("Tenant does not exist") + cloud_region.add_tenant(tenant_id=tenant_id, + tenant_name=tenant_name) + logger.info(f"Tenant {tenant_name} added to region") + + +def add_tenants(cloud_region, k8s_region, tenants): + logger.info("******** Tenants *******") + for tenant in tenants: + tenant_name = tenant["name"] + if k8s_region: + try: + next(_tenant for _tenant in cloud_region.tenants if _tenant.name == tenant_name) + logger.info("Tenant exists") + except (StopIteration, ResourceNotFound): + tenant_id = str(uuid4()) + add_tenant(cloud_region=cloud_region, tenant_id=tenant_id, tenant_name=tenant_name) + else: + tenant_id = tenant["id"] + try: + cloud_region.get_tenant(tenant_id) + logger.info("Tenant exists") + except ResourceNotFound: + add_tenant(cloud_region=cloud_region, tenant_id=tenant_id, tenant_name=tenant_name) + + +def update_connectivity_info(region): + logger.info("******** Connectivity Info *******") + kubeconfig_path = region["kubeconfig_file"] + cloud_owner = region["cloud_owner"] + region_id = region["name"] + try: + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), kubeconfig_path), 'rb') as kubeconfig_file: + kubeconfig = kubeconfig_file.read() + + connectivity_info = ConnectivityInfo.get_connectivity_info_by_region_id(cloud_region_id=region_id) + logger.info("Connectivity Info exists ") + logger.info("Delete Connectivity Info ") + connectivity_info.delete() + ConnectivityInfo.create(cloud_region_id=region_id, + cloud_owner=cloud_owner, + kubeconfig=kubeconfig) + logger.info("Connectivity Info created ") + except (APIError, ResourceNotFound): + logger.info("Connectivity Info does not exists ") + ConnectivityInfo.create(cloud_region_id=region_id, + cloud_owner=cloud_owner, + kubeconfig=kubeconfig) + logger.info("Connectivity Info created ") + except FileNotFoundError: + logger.error("Error - File Not Found") + logger.info("Please check if kubeconfig file exists") + exit(1) + + +def add_region_to_so_db(region): + logger.info("******** SO Database *******") + if is_k8s_region(region): + identity_service = IdentityService(identity_id="Keystone_K8s", + url="http://test:5000/v3", + mso_id="onapsdk_user", + mso_pass="mso_pass_onapsdk", + project_domain_name="NULL", + user_domain_name="NULL", + identity_server_type="KEYSTONE") + + SoDbAdapter.add_cloud_site(cloud_region_id=region["name"], + complex_id=region["complex_id"], + identity_service=identity_service, + orchestrator="multicloud") + else: + identity_url = region["identity_url"] + mso_id = region["mso_id"] + mso_pass = region["mso_pass"] + identity_server_type = region["identity_server_type"] + identity_service = IdentityService(identity_id=region["name"] + "_KEYSTONE", + url=identity_url, + mso_id=mso_id, + mso_pass=mso_pass, + project_domain_name="Default", + user_domain_name="Default", + identity_server_type=identity_server_type) + + SoDbAdapter.add_cloud_site(cloud_region_id=region["name"], + complex_id=region["complex_id"], + identity_service=identity_service, + orchestrator="NULL") + + +def is_k8s_region(region): + is_k8s = False + if region["cloud_type"] == "k8s": + is_k8s = True + return is_k8s + + +######################################################################################################################## +def main(): + config = Config() + + for region in config.cloud_regions: + complx = create_complex(region["complex_id"]) + cloud_region = create_cloud_region(region) + link_region_to_complex(cloud_region, complx) + add_tenants(cloud_region, is_k8s_region(region), region.get("tenants")) + if is_k8s_region(region): + update_connectivity_info(region) + add_region_to_so_db(region) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/delete.py b/tutorials/xNF_5G/ueransim/automation/delete.py new file mode 100644 index 00000000..817ba786 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/delete.py @@ -0,0 +1,96 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +from config import Config + +from instantiate import get_customer, check_orchestration_status + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def get_service_subscription(customer, service_type): + try: + service_subscription = next( + service_sub for service_sub in customer.service_subscriptions if service_sub.service_type == service_type) + return service_subscription + except StopIteration: + logger.error("Service Subscription not found") + exit(1) + + +def get_service_instance(service_subscription, service_instance_name): + try: + service_instance = next(instance for instance in service_subscription.service_instances + if instance.instance_name == service_instance_name) + return service_instance + except StopIteration: + logger.error("Service Instance not found") + exit(1) + + +def delete_service_macro(service_instance): + service_deletion = service_instance.delete(a_la_carte=False) + check_orchestration_status(service_deletion) + + +def delete_service_alacarte(service_instance): + for vnf in service_instance.vnf_instances: + for vf_module in vnf.vf_modules: + vf_module_deletion = vf_module.delete() + check_orchestration_status(vf_module_deletion) + vnf_deletion = vnf.delete() + check_orchestration_status(vnf_deletion) + service_deletion = service_instance.delete(a_la_carte=True) + check_orchestration_status(service_deletion) + + +def main(): + logger.info("*******************************") + logger.info("**** SERVICE DELETION ****") + logger.info("*******************************") + + config = Config() + logger.info("******** GET Customer *******") + customer = get_customer(config.service_instance["customer_id"]) + + logger.info("******** Check Service Subscription *******") + service_subscription = get_service_subscription(customer, config.service_instance["model_name"]) + + logger.info("******** Get Service Instance details *******") + service_instance = get_service_instance(service_subscription, config.service_instance["instance_name"]) + + logger.info("******** Delete Service %s *******", service_instance.instance_name) + if config.service_model["macro_orchestration"]: + delete_service_macro(service_instance) + else: + logger.error("A_la_carte orchestration method not updated") + if config.service_model["pnfs"] is not None: + raise NotImplementedError + else: + delete_service_alacarte(service_instance) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/healthcheck.py b/tutorials/xNF_5G/ueransim/automation/healthcheck.py new file mode 100644 index 00000000..5e95815a --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/healthcheck.py @@ -0,0 +1,91 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Samsung +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import zipfile + +from onapsdk.aai.business import Customer +from onapsdk.cds.blueprint import Workflow, Blueprint + +from config import Config + +#FIXME remove from global scope +logger = logging.getLogger("") +logger.setLevel(logging.INFO) +fh = logging.StreamHandler() +fh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') +fh.setFormatter(fh_formatter) +logger.addHandler(fh) + +def resolve_hc_inputs(): + logger.info("******** Check Customer *******") + customer = None + for found_customer in list(Customer.get_all()): + logger.debug("Customer %s found", found_customer.subscriber_name) + if found_customer.subscriber_name == Config.GLOBAL_CUSTOMER_ID: + logger.info("Customer %s found", found_customer.subscriber_name) + customer = found_customer + break + if customer is None: + raise Exception("Customer %s wasn't found in ONAP" % Config.GLOBAL_CUSTOMER_ID) + logger.info("******** Check Service Subscription *******") + service_subscription = None + for service_sub in customer.service_subscriptions: + logger.debug("Service subscription %s is found", service_sub.service_type) + if service_sub.service_type == Config.SERVICENAME: + logger.info("Service %s subscribed", Config.SERVICENAME) + service_subscription = service_sub + break + logger.info("******** Retrieve Service Metadata *******") + service_instance = None + for single_service in service_subscription.service_instances: + if single_service.instance_name == Config.SERVICE_INSTANCE_NAME: + service_instance = single_service + break + service_id = service_instance.instance_id + vnfs = list(service_instance.vnf_instances) + if len(vnfs) > 1: + raise NotImplementedError("Service %s is composed of more than one vnf!" % service_id) + if not vnfs: + raise Exception("Service %s doesn't contain any vnfs" % service_id) + vnf_id = vnfs[0].vnf_id + return service_id, vnf_id + +def main(): + blueprint = None + with zipfile.ZipFile(Config.VSPFILE, 'r') as package: + with package.open("CBA.zip", 'r') as cba: + blueprint = Blueprint(cba.read()) + + healthcheck = Workflow('health-check', None, blueprint) + serv_id, vnf_id = resolve_hc_inputs() + cds_input = {"health-check-properties": + { + "service-instance-id": serv_id, + "vnf-id": vnf_id + } + } + logger.info("Requesting Healthcheck for CBA %s:%s with inputs:\n%s", + blueprint.metadata.template_name, + blueprint.metadata.template_version, + cds_input) + result = healthcheck.execute(cds_input) + logger.info("Healthcheck process completed with result: %s", result) + logger.info("Please check cds-blueprints-processor logs to see exact status") + +if __name__ == "__main__": + main() diff --git a/tutorials/xNF_5G/ueransim/automation/instantiate.py b/tutorials/xNF_5G/ueransim/automation/instantiate.py new file mode 100644 index 00000000..aac82155 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/instantiate.py @@ -0,0 +1,418 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +from time import sleep + +from config import Config +from onapsdk.aai.cloud_infrastructure import ( + CloudRegion +) +from onapsdk.aai.business import ( + Customer, + OwningEntity as AaiOwningEntity +) +from onapsdk.exceptions import ResourceNotFound, APIError +from onapsdk.msb.k8s import Definition + +from onapsdk.so.instantiation import ( + ServiceInstantiation, + InstantiationParameter) +from onapsdk.sdc.service import Service +from onapsdk.so.so_element import OrchestrationRequest +from onapsdk.aai.service_design_and_creation import Service as AaiService + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def get_customer(global_customer_id: str = "customer_cnf"): + logger.info("******** Customer *******") + try: + customer = Customer.get_by_global_customer_id(global_customer_id) + logger.info("Customer exists") + except ResourceNotFound: + logger.info("Customer does not exist") + customer = Customer.create(global_customer_id, global_customer_id, "INFRA") + logger.info("Customer created") + return customer + + +def get_service_model(model_name): + try: + service_model = next(model for model in Service.get_all() if model.name == model_name) + logger.info( + f"Found Service {service_model.name} in SDC, distribution status: {service_model.distribution_status}") + return service_model + except StopIteration: + logger.error(f"Service model {model_name} not found in SDC") + exit(1) + + +def check_service_customer_subscription(customer, service): + try: + next(subscription for subscription in customer.service_subscriptions + if subscription.service_type == service.name) + except StopIteration: + return False + + logger.info(f"Customer {customer.subscriber_name} subscribed for {service.name}") + return True + + +def subscribe_service_customer(customer, service): + if not check_service_customer_subscription(customer, service): + logger.info("******** Subscribe Service *******") + customer.subscribe_service(service) + + +def get_cloud_region(cloud_owner, cloud_region): + return CloudRegion(cloud_owner=cloud_owner, cloud_region_id=cloud_region, + orchestration_disabled=True, in_maint=False) + + +def get_tenant(cloud_region, tenant_name): + try: + tenant = next(tenant for tenant in cloud_region.tenants if tenant.name == tenant_name) + return tenant + except StopIteration: + logger.error(f"Tenant {tenant_name} not found") + exit(1) + + +def add_owning_entity(owning_entity): + logger.info("******** Add Owning Entity to AAI *******") + try: + aai_owning_entity = AaiOwningEntity.get_by_owning_entity_name(owning_entity) + except ResourceNotFound: + logger.info("******** Owning Entity not existing: create *******") + aai_owning_entity = AaiOwningEntity.create(owning_entity) + + return aai_owning_entity + + +def delete_old_profiles(service, service_config): + for vnf in service.vnfs: + vnf_config_details = next(_vnf for _vnf in service_config["vnfs"] if _vnf["model_name"] == vnf.metadata["name"]) + for vf_module in vnf.vf_modules: + vf_module_label = vf_module.properties["vf_module_label"] + if vf_module_label == "base_template_dummy_ignore": + continue + vf_module_config_details = next(_vf_module for _vf_module in vnf_config_details["vf_modules"] if + _vf_module["model_name"] == vf_module_label) + if "k8s-rb-profile-name" not in vf_module_config_details["parameters"]: + continue + try: + definition = Definition.get_definition_by_name_version( + rb_name=vf_module.metadata["vfModuleModelInvariantUUID"], + rb_version=vf_module.metadata["vfModuleModelCustomizationUUID"]) + except APIError: + definition = Definition.get_definition_by_name_version( + rb_name=vf_module.metadata["vfModuleModelInvariantUUID"], + rb_version=vf_module.metadata["vfModuleModelUUID"]) + profile_name = vf_module_config_details["parameters"]["k8s-rb-profile-name"] + try: + profile = definition.get_profile_by_name(profile_name) + namespace = None + if "k8s-rb-profile-namespace" in vnf_config_details["parameters"]: + namespace = vnf_config_details["parameters"]["k8s-rb-profile-namespace"] + if "k8s-rb-profile-namespace" in vf_module_config_details["parameters"]: + namespace = vf_module_config_details["parameters"]["k8s-rb-profile-namespace"] + if namespace is not None and profile.namespace != namespace: + profile.delete() + logger.info("Profile: " + profile_name + " for " + vf_module.name + " deleted") + else: + logger.info("No need to delete Profile " + profile_name + + " for " + vf_module.name + ". Namespace is fine") + except ResourceNotFound: + logger.info("Profile: " + profile_name + " for " + vf_module.name + " not found") + + +def check_service_instance_exists(service_subscription, service_instance_name): + try: + service_instance = next((instance for instance in service_subscription.service_instances + if instance.instance_name == service_instance_name), None) + return service_instance + except ResourceNotFound: + return None + + +def get_instantiation_parameters(properties, vnf_vf_module_config): + instantiation_parameters = [] + for property_name, property_value in properties: + instantiation_parameters.append(InstantiationParameter(name=property_name, value=property_value)) + + for instantiation_parameter_key, instantiation_parameter_value in vnf_vf_module_config["parameters"]: + instantiation_parameters.append(InstantiationParameter(name=instantiation_parameter_key, + value=instantiation_parameter_value)) + + return instantiation_parameters + + +def check_orchestration_status(instantiation): + status = None + while not (status == OrchestrationRequest.StatusEnum.COMPLETED + or status == OrchestrationRequest.StatusEnum.FAILED): + sleep(10) + status = instantiation.status + logger.info(f"Orchestration status is: {status.value}") + + if status == OrchestrationRequest.StatusEnum.FAILED: + logger.error("Orchestration was failed!") + exit(1) + else: + logger.info("Orchestration was succeed") + return + + +def get_aai_service(service_type): + logging.info("******** Retrieve product family for service *******") + try: + aai_service = next(service for service in AaiService.get_all() if service.service_id == service_type) + except (ResourceNotFound, StopIteration): + logging.info("******** Service design and creation in AAI not existing: create *******") + AaiService.create(service_id=service_type, service_description=service_type) + aai_service = next(service for service in AaiService.get_all() if service.service_id == service_type) + + return aai_service + + +def instantiate_service_macro(config, service, cloud_region, tenant, customer, owning_entity, + vid_project, vid_line_of_business, vid_platform): + service_instance_name = config.service_instance["instance_name"] + so_input = config.so_input + for vnf in so_input["vnfs"]: + _vnf = next(nf for nf in service.vnfs if nf.metadata["name"] == vnf["model_name"]) + sdnc_model_name = _vnf.properties["sdnc_model_name"] + sdnc_model_version = _vnf.properties["sdnc_model_version"] + sdnc_artifact_name = _vnf.properties["sdnc_artifact_name"] + vnf["parameters"]["sdnc_model_name"] = sdnc_model_name + vnf["parameters"]["sdnc_model_version"] = sdnc_model_version + vnf["parameters"]["sdnc_artifact_name"] = sdnc_artifact_name + for vf_module in vnf["vf_modules"]: + vf_module_label = vf_module["model_name"] + vf_module["parameters"]["sdnc_model_name"] = sdnc_model_name + vf_module["parameters"]["sdnc_model_version"] = sdnc_model_version + vf_module["parameters"]["vf_module_label"] = vf_module_label + + # TODO: PNF support in so_input -> first ONAPSDK + + aai_service = get_aai_service(service.name) + service_instantiation = ServiceInstantiation.instantiate_macro( + sdc_service=service, + cloud_region=cloud_region, + tenant=tenant, + customer=customer, + owning_entity=owning_entity, + project=vid_project, + line_of_business=vid_line_of_business, + platform=vid_platform, + service_instance_name=service_instance_name, + aai_service=aai_service, + so_service=so_input + ) + check_orchestration_status(service_instantiation) + + +def get_base_vf_module(vf_modules): + base_vf_module = next(vf_module for vf_module in vf_modules if vf_module.properties["isBase"]) + return base_vf_module + + +def is_base(vf_module): + if vf_module.properties["isBase"]: + return True + return False + + +def instantiate_vf_module(vf_module, vf_module_param_list, vnf_instance, sdnc_model_name, sdnc_model_version): + vf_module_label = vf_module.properties["vf_module_label"] + region_id = vf_module_param_list[vf_module_label]["cloud_configuration"] + cloud_region = get_cloud_region( + Config.CLOUD_REGIONS[region_id]["cloud_owner"], + region_id) + tenant = get_tenant(cloud_region, Config.CLOUD_REGIONS[region_id]["tenant"]["name"]) + + vfmodule_instantiation_parameters = vf_module_param_list[vf_module_label]["instantiation_parameters"].items() + + base_parameters = [ + InstantiationParameter(name="sdnc_model_name", value=sdnc_model_name), + InstantiationParameter(name="sdnc_model_version", value=sdnc_model_version), + InstantiationParameter(name="vf_module_label", value=vf_module_label)] + + for instantiation_parameter_key, instantiation_parameter_value in vfmodule_instantiation_parameters: + base_parameters.append(InstantiationParameter(name=instantiation_parameter_key, + value=instantiation_parameter_value)) + + vf_module_instantiation = vnf_instance.add_vf_module( + vf_module=vf_module, + cloud_region=cloud_region, + tenant=tenant, + vnf_parameters=base_parameters, + use_preload=False + ) + check_orchestration_status(vf_module_instantiation) + + +def check_vf_module_list_correct(vf_modules, vf_modules_config_list): + model_labels = set() + config_labels = set() + for vf_module in vf_modules: + model_labels.add(vf_module.properties["vf_module_label"]) + for vf_module in vf_modules_config_list: + config_labels.add(vf_module["model_name"]) + if model_labels == config_labels: + return True + else: + return False + + +def get_properties(vnf): + properties = dict() + + properties["sdnc_model_name"] = vnf["properties"]["sdnc_model_name"] + properties["sdnc_model_version"] = vnf["properties"]["sdnc_model_version"] + properties["sdnc_artifact_name"] = vnf["properties"]["sdnc_artifact_name"] + + return properties + + +def instantiate_service_alacarte(config, service_subscription, service_model, cloud_region, tenant, customer, + owning_entity, + vid_project, vid_line_of_business, vid_platform): + service_instance_name = config.service_instance["instance_name"] + # Service creation + service_instantiation = ServiceInstantiation.instantiate_ala_carte( + sdc_service=service_model, + cloud_region=cloud_region, + tenant=tenant, + customer=customer, + owning_entity=owning_entity, + project=vid_project, + service_instance_name=service_instance_name + ) + check_orchestration_status(service_instantiation) + # End of service creation + + service_instance = service_subscription.get_service_instance_by_name(service_instance_name) + # Add VNFs + for vnf in service_model.vnfs: + # TODO: priority + properties = get_properties(vnf) + vnf_config = next(_vnf for _vnf in config.service_instance["vnfs"] + if config.service_instance["vnfs"]["model_name"] == vnf.name) + vnf_parameters = get_instantiation_parameters(properties, vnf_config) + # TODO: instance name + vnf_instantiation = service_instance.add_vnf( + vnf=vnf, + line_of_business=vid_line_of_business, + platform=vid_platform, + vnf_parameters=vnf_parameters + ) + check_orchestration_status(vnf_instantiation) + + # Add vf_modules + vnf_type = service_model.name + "/" + vnf.name + vnf_instance = next((vnf for vnf in service_instance.vnf_instances if vnf.vnf_type == vnf_type), None) + + if check_vf_module_list_correct(vnf.vf_modules, vnf_config["vf_modules"]): + for vf_module in vnf.vf_modules: + vf_module_config = next(_vf for _vf in vnf_config["vf_modules"] + if _vf["model_name"] == vf_module.properties["vf_module_label"]) + vf_module_parameters = get_instantiation_parameters(properties, vf_module_config) + vf_module_instantiation = vnf_instance.add_vf_module( + vf_module=vf_module, + cloud_region=cloud_region, + tenant=tenant, + vnf_parameters=vf_module_parameters, + use_preload=False + ) + check_orchestration_status(vf_module_instantiation) + else: + logger.error("VF_MODULE_PARAM_LIST error. ") + # End of vf_modules + # End of VNFs + + +def main(): + logger.info("*******************************") + logger.info("**** SERVICE INSTANTIATION ****") + logger.info("*******************************") + + config = Config() + + logger.info("******** GET Customer *******") + customer = get_customer(config.service_instance["customer_id"]) + + logger.info("******** GET Service Model from SDC *******") + service = get_service_model(config.service_instance["model_name"]) + + logger.info("******** Subscribe Customer for Service *******") + subscribe_service_customer(customer, service) + + logger.info("******** Get Tenant *******") + region_details = next( + region for region in config.cloud_regions if region["name"] == config.service_instance["cloud_region"]) + cloud_region = get_cloud_region(region_details["cloud_owner"], region_details["name"]) + tenant = get_tenant(cloud_region, + config.service_instance["tenant_name"]) + + ###### + logger.info("******** Connect Service to Tenant *******") + service_subscription = None + for service_sub in customer.service_subscriptions: + if service_sub.service_type == config.service_instance["model_name"]: + logger.info("Service %s subscribed", config.service_instance["model_name"]) + service_subscription = service_sub + break + if not service_subscription: + logger.error("Service subscription %s is not found", config.service_instance["model_name"]) + exit(1) + + service_subscription.link_to_cloud_region_and_tenant(cloud_region, tenant) + #### + + logger.info("******** Business Objects (OE, P, Pl, LoB) *******") + project = "Project-Demonstration" + platform = "Platform-test" + line_of_business = "Orange-LOB" + owning_entity = add_owning_entity("Orange") + + logger.info("******** Delete old profiles ********") + delete_old_profiles(service, config.service_instance) + + logger.info("******** Instantiate Service *******") + service_instance = check_service_instance_exists(service_subscription, config.service_instance["instance_name"]) + if service_instance: + logger.info("******** Service Instance exists, do not instantiate *******") + else: + logger.info("******** Service Instance not existing: Instantiate *******") + if config.service_model["macro_orchestration"]: + instantiate_service_macro(config, service, cloud_region, tenant, customer, owning_entity, + project, line_of_business, platform) + else: + instantiate_service_alacarte(config, service_subscription, service, cloud_region, tenant, customer, + owning_entity, project, line_of_business, platform) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/k8s_client.py b/tutorials/xNF_5G/ueransim/automation/k8s_client.py new file mode 100644 index 00000000..98b451bc --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/k8s_client.py @@ -0,0 +1,59 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import os +from pprint import pprint + +import oyaml as yaml +from kubernetes import config, client +from kubernetes.client import OpenApiException + + +class K8sClient: + def __init__(self, kubeconfig_path): + self.mypath = os.path.dirname(os.path.realpath(__file__)) + config.load_kube_config(config_file=os.path.join(self.mypath, kubeconfig_path)) + self.api_instance = client.CustomObjectsApi() + + def read_custom_object_file(self, file_path): + with open(file_path) as crd_file: + crd_body = yaml.load(crd_file, Loader=yaml.FullLoader) + return crd_body + + def get_custom_object_details(self, crd_body): + group = crd_body["apiVersion"].split("/")[0] + version = crd_body["apiVersion"].split("/")[1] + plural = crd_body["kind"].lower() + "s" + #name = crd_body["metadata"]["name"] + + return group, version, plural #, name + + def create_custom_object(self, file_path): + crd_body = self.read_custom_object_file(file_path) + #group, version, plural, name = self.get_custom_object_details(crd_body) + group, version, plural = self.get_custom_object_details(crd_body) + api_response = None + try: + api_response = self.api_instance.create_cluster_custom_object(group=group, + version=version, + plural=plural, + body=crd_body, + pretty="true") + except OpenApiException as error: + print(str(error.status) + " " + error.reason) + pprint(error.body) + return api_response diff --git a/tutorials/xNF_5G/ueransim/automation/onap_settings.py b/tutorials/xNF_5G/ueransim/automation/onap_settings.py new file mode 100644 index 00000000..55a246f4 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/onap_settings.py @@ -0,0 +1,47 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +"""Global settings module.""" # pylint: disable=bad-whitespace +# uncomment if socks is used +#from onapsdk.onap_service import OnapService + +###################### +# # +# ONAP SERVICES URLS # +# # +###################### + +AAI_URL = "https://aai.api.sparky.simpledemo.onap.org:30233" +AAI_API_VERSION = "v20" +CDS_URL = "http://portal.api.simpledemo.onap.org:30449" +MSB_URL = "https://msb.api.simpledemo.onap.org:30283" +SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204" +SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207" +SDNC_URL = "https://sdnc.api.simpledemo.onap.org:30267" +SO_URL = "http://so.api.simpledemo.onap.org:30277" +SO_API_VERSION = "v7" +VID_URL = "https://vid.api.simpledemo.onap.org:30200" +VID_API_VERSION = "/vid" +CLAMP_URL = "https://clamp.api.simpledemo.onap.org:30258" +VES_URL = "https://ves.api.simpledemo.onap.org:30417" +DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904" + +# uncomment if socks is used +#OnapService.set_proxy({'http': 'socks5h://127.0.0.1:8081', 'https': 'socks5h://127.0.0.1:8081'}) + +# execute in the shell to apply these settings +# export ONAP_PYTHON_SDK_SETTINGS="onap_settings" diff --git a/tutorials/xNF_5G/ueransim/automation/onboard.py b/tutorials/xNF_5G/ueransim/automation/onboard.py new file mode 100644 index 00000000..488c54e6 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/onboard.py @@ -0,0 +1,200 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +import time +import zipfile +from io import BytesIO + +import yaml + +from config import Config +import onapsdk.constants as const + +from onapsdk.sdc.vendor import Vendor +from onapsdk.sdc.vsp import Vsp +from onapsdk.sdc.vf import Vf +from onapsdk.sdc.pnf import Pnf +from onapsdk.sdc.service import Service, ServiceInstantiationType + +import os + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def retrieve_service(service_name: str): + logger.info("Retrieve service from SDC before onboarding") + services = Service.get_all() + + for found_service in services: + if found_service.name == service_name: + logging.info(f"Service {found_service.name} found in SDC, onboarding will not be executed") + exit(0) + return + + +def onboard_vendor(vendor_name: str = "demo_vendor"): + logger.info("******** Onboard Vendor *******") + vendor = Vendor(vendor_name) + vendor.onboard() + return vendor + + +def onboard_vsp(vsp_name, vsp_file, vendor): + logger.info(f"******** Onboard VSP - {vsp_name} *******") + mypath = os.path.dirname(os.path.realpath(__file__)) + vsp_path = os.path.join(mypath, vsp_file) + vsp = None + try: + vsp = Vsp(name=vsp_name, vendor=vendor, package=open(vsp_path, 'rb')) + except FileNotFoundError: + logger.error(f"No vsp file was found for {vsp_name}!") + exit(1) + vsp.onboard() + return vsp + + +def onboard_pnf(pnf_name, vsp_name, vsp_file, vendor_name): + logger.info(f"******** Onboard PNF - {pnf_name} *******") + vendor = onboard_vendor(vendor_name=vendor_name) + pnf_vsp = onboard_vsp(vsp_name=vsp_name, vsp_file=vsp_file, vendor=vendor) + pnf = Pnf(name=pnf_name, vsp=pnf_vsp) + pnf.onboard() + return pnf + + +def onboard_vnf(vnf_name, vsp_name, vsp_file, vendor_name): + logger.info(f"******** Onboard VNF - {vnf_name} *******") + vendor = onboard_vendor(vendor_name=vendor_name) + vnf_vsp = onboard_vsp(vsp_name=vsp_name, vsp_file=vsp_file, vendor=vendor) + vnf = Vf(name=vnf_name, vsp=vnf_vsp) + vnf.create() + vnf.onboard() + return vnf + + +def create_service(service_name, is_macro: bool = True): + logger.info("******** Create Service *******") + if is_macro: + service = Service(name=service_name, + instantiation_type=ServiceInstantiationType.MACRO) + else: + service = Service(name=service_name, + instantiation_type=ServiceInstantiationType.A_LA_CARTE) + service.create() + return service + + +def read_sdnc_model_details(file): + mypath = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(mypath, file) + try: + with zipfile.ZipFile(file_path, 'r') as package: + try: + cba_io = BytesIO(package.read("CBA.zip")) + with zipfile.ZipFile(cba_io) as cba: + with cba.open('TOSCA-Metadata/TOSCA.meta') as meta_file: + tosca_meta = yaml.load(meta_file, Loader=yaml.FullLoader) + sdnc_model_name = tosca_meta.get("Template-Name") + sdnc_model_version = tosca_meta.get("Template-Version") + return sdnc_model_name, sdnc_model_version + except KeyError: + logger.info("No CBA file was found") + return None, None + except FileNotFoundError: + logger.error("No vsp file was found!") + exit(1) + + +def set_properties(service, xnf, vsp_details): + sdnc_model_name, sdnc_model_version = read_sdnc_model_details(vsp_details["vsp_file"]) + if sdnc_model_name and sdnc_model_version: + if service.status == const.DRAFT: + logger.info("******** Set SDNC properties for VF ********") + component = service.get_component(xnf) + prop = component.get_property("sdnc_model_name") + prop.value = sdnc_model_name + prop = component.get_property("sdnc_model_version") + prop.value = sdnc_model_version + prop = component.get_property("controller_actor") + prop.value = "CDS" + prop = component.get_property("sdnc_artifact_name") + prop.value = vsp_details["sdnc_artifact_name"] + prop = component.get_property("skip_post_instantiation_configuration") + prop.value = vsp_details["skip_post_instantiation_configuration"] + + +def check_distribution_status(service): + logger.info("******** Check Service Distribution *******") + distribution_completed = False + nb_try = 0 + nb_try_max = 10 + while distribution_completed is False and nb_try < nb_try_max: + distribution_completed = service.distributed + if distribution_completed is True: + logger.info(f"Service Distribution for {service.name} is successfully finished") + break + logger.info(f"Service Distribution for {service.name} ongoing, Wait for 60 s") + time.sleep(60) + nb_try += 1 + + if distribution_completed is False: + logger.error(f"Service Distribution for {service.name} failed !!", ) + exit(1) + + +def main(): + config = Config() + retrieve_service(service_name=config.service_model["model_name"]) + + logger.info("******** SERVICE DESIGN *******") + service = create_service(service_name=config.service_model["model_name"], + is_macro=config.service_model["macro_orchestration"]) + vnfs = config.service_model.get("vnfs") + if vnfs: + for vnf in vnfs: + new_vnf = onboard_vnf(vnf_name=vnf["model_name"], + vsp_name="VSP" + "_" + vnf["model_name"], + vsp_file=vnf["vsp"]["vsp_file"], + vendor_name=vnf["vsp"]["vendor"]) + service.add_resource(new_vnf) + set_properties(service=service, xnf=new_vnf, vsp_details=vnf["vsp"]) + + pnfs = config.service_model.get("pnfs") + if pnfs: + for pnf in pnfs: + new_pnf = onboard_pnf(pnf_name=pnf["model_name"], + vsp_name="VSP" + "_" + pnf["model_name"], + vsp_file=pnf["vsp"]["vsp_file"], + vendor_name=pnf["vsp"]["vendor"]) + service.add_resource(new_pnf) + set_properties(service=service, xnf=new_pnf, vsp_details=pnf["vsp"]) + + service.checkin() + service.onboard() + check_distribution_status(service) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/update_cba.py b/tutorials/xNF_5G/ueransim/automation/update_cba.py new file mode 100644 index 00000000..316c0d75 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/update_cba.py @@ -0,0 +1,57 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging +import os +import zipfile +from io import BytesIO + +from onapsdk.cds import Blueprint + +from config import Config + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def update_cba(file): + mypath = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(mypath, file) + try: + with zipfile.ZipFile(file_path, 'r') as package: + cba_io = BytesIO(package.read("CBA.zip")) + + blueprint = Blueprint(cba_io) + blueprint.deploy() + except FileNotFoundError: + logger.error("Error - File Not Found") + exit(1) + + +def main(): + config = Config() + for vnf in config.service_model["vnfs"]: + update_cba(vnf["vsp"]["vsp_file"]) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/update_connectivity_info.py b/tutorials/xNF_5G/ueransim/automation/update_connectivity_info.py new file mode 100644 index 00000000..4b279aba --- /dev/null +++ b/tutorials/xNF_5G/ueransim/automation/update_connectivity_info.py @@ -0,0 +1,40 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +import logging + +from config import Config +from create_cloud_regions import update_connectivity_info, is_k8s_region + +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + + +def main(): + config = Config() + for region in config.cloud_regions: + if is_k8s_region(region): + update_connectivity_info(region) + + +if __name__ == "__main__": + sh = logging.StreamHandler() + sh_formatter = logging.Formatter('%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s') + sh.setFormatter(sh_formatter) + logger.addHandler(sh) + + main() diff --git a/tutorials/xNF_5G/ueransim/automation/vsp/.gitkeep b/tutorials/xNF_5G/ueransim/automation/vsp/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tutorials/xNF_5G/ueransim/service_config.yaml b/tutorials/xNF_5G/ueransim/service_config.yaml new file mode 100644 index 00000000..10db7495 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/service_config.yaml @@ -0,0 +1,57 @@ +user_params: + k8s_namespace: free5gc + profile_name: ueransim-cnf-cds-base-profile + profile_source: ueransim-cnf-cds-base-profile + release_name: rel-1 + name_suffix: instance_1 + +cloud_regions: + - name: orange_k8s_free5gc + cloud_owner: K8sCloudOwner + cloud_type: k8s + complex_id: complex1 + tenants: + - name: &tenant1 orange-free5gc-tenant + k8s_version: 1.21.1 + kubeconfig_file: artifacts/cluster_kubeconfig + +service_model: + macro_orchestration: True + model_name: &service_model_name ueransim_demo + vnfs: + - model_name: &vnf_1_model_name ueransim + vsp: + vsp_file: vsp/native_ueransim_k8s_demo.zip + vendor: orange + sdnc_artifact_name: vnf + skip_post_instantiation_configuration: False + pnfs: + +service_instance: + model_name: *service_model_name + instance_name: "{{ service_model.model_name }}_{{ user_params.name_suffix }}" + customer_id: orange + cloud_region: "{{ cloud_regions[0].name }}" + tenant_name: *tenant1 #"{{ cloud_regions[0].tenants[0].name }}" + service_type: ueransim + vnfs: + - model_name: *vnf_1_model_name + #vnf_name_suffix: "001" #optional parameter + parameters: + k8s-rb-profile-namespace: "{{ user_params.k8s_namespace }}" + k8s-rb-profile-k8s-version: "{{ cloud_regions[0].tenants[0].k8s_version }}" + processing_priority: 1 + vf_modules: + - model_name: helm_ueransim + vf_module_name_suffix: "001" + processing_priority: 1 + parameters: + k8s-rb-profile-name: "{{ user_params.profile_name }}" + k8s-rb-profile-source: "{{ user_params.profile_source }}" + k8s-rb-instance-release-name: "{{ user_params.release_name }}-ueransim" + core-instance-name: free5GC_demo__1 + k8s-rb-config-template-name: ue-reconfiguration-template #trzeba zmieniac + k8s-rb-config-template-source: ue-reconfiguration-template + k8s-rb-config-name: ue-reconfiguration-template + k8s-rb-config-value-source: ue-reconfiguration-template + pnfs: diff --git a/tutorials/xNF_5G/ueransim/templates/.gitattributes b/tutorials/xNF_5G/ueransim/templates/.gitattributes new file mode 100644 index 00000000..4ad2a524 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/.gitattributes @@ -0,0 +1 @@ +/cba/Templates/k8s-profiles/*.tar.gz binary diff --git a/tutorials/xNF_5G/ueransim/templates/.gitignore b/tutorials/xNF_5G/ueransim/templates/.gitignore new file mode 100644 index 00000000..f88e099b --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/.gitignore @@ -0,0 +1,2 @@ +package/ +vfw_k8s_demo.zip diff --git a/tutorials/xNF_5G/ueransim/templates/Makefile b/tutorials/xNF_5G/ueransim/templates/Makefile new file mode 100644 index 00000000..b302e11d --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/Makefile @@ -0,0 +1,45 @@ +.PHONY: all clean helm base clean_all package cba jsonlint_cba +NATIVE_ONBOARDING_PACKAGE_NAME ?= native_ueransim_k8s_demo +CBA_NAME ?= CBA +_type_files = $(wildcard cba/Definitions/*_types.json) + + +clean_all: + $(MAKE) clean + $(MAKE) all + +#Can't use .csar extension or SDC will panic +all: package helm base cba + cd package_native/ && zip -r $(NATIVE_ONBOARDING_PACKAGE_NAME).zip . + mv package_native/$(NATIVE_ONBOARDING_PACKAGE_NAME).zip . + cp $(NATIVE_ONBOARDING_PACKAGE_NAME).zip ../automation/vsp/ + +helm: package + $(MAKE) -C helm + mv helm/helm_*.tgz package_native/ + +base: package + cp base_native/* package_native/ + +cba: package + cp ../../free5gc/templates/cba/* cba/ + cd cba/ && zip -r $(CBA_NAME).zip . -x pom.xml .idea/\* target/\* + mv cba/$(CBA_NAME).zip package_native/ + +package: + mkdir package_native/ + +clean: + rm -rf package_native/ + rm -f $(NATIVE_ONBOARDING_PACKAGE_NAME).zip + rm -fr onap-automation + find cba/* ! -name pom.xml -delete + +jsonlint_cba: $(_type_files) + @: + +#This shouldn't be PHONY, but it's easier now to define this way +.PHONY: $(_type_files) +$(_type_files): + @which jq expand unexpand sponge >/dev/null + jq -S . <$@ | unexpand -t 2 | expand -t 4 | sponge $@ diff --git a/tutorials/xNF_5G/ueransim/templates/README.txt b/tutorials/xNF_5G/ueransim/templates/README.txt new file mode 100644 index 00000000..3d7c29cf --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/README.txt @@ -0,0 +1 @@ +cba-dd.json file is Data Dictionary file used to enrich cba model. diff --git a/tutorials/xNF_5G/ueransim/templates/base_native/MANIFEST.json b/tutorials/xNF_5G/ueransim/templates/base_native/MANIFEST.json new file mode 100644 index 00000000..05593e71 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/base_native/MANIFEST.json @@ -0,0 +1,15 @@ +{ + "name": "fueransim", + "description": "", + "data": [ + { + "file": "CBA.zip", + "type": "CONTROLLER_BLUEPRINT_ARCHIVE" + }, + { + "file": "helm_ueransim.tgz", + "type": "HELM", + "isBase": "true" + } + ] +} diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/bootstrap.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/bootstrap.sh new file mode 100644 index 00000000..74ec06a0 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/bootstrap.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/bootstrap' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data '{"loadModelType": true, "loadResourceDictionary": true, "loadCBA": false}' | jq diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/build.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/build.sh new file mode 100644 index 00000000..a7a34061 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/build.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +cd ../cba/ + +mvn clean install + +if [ $? -eq 1 ] +then + echo "----------------" + echo "CBA BUILD FAILED" + echo "----------------" + exit 1 +fi + +CBA_NAME=`ls target/*.zip` +cp $CBA_NAME ../cba-dev/cba.zip + +echo "-----------------" +echo "CBA BUILD SUCCESS" +echo "-----------------" + +cd ../cba-dev diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/deploy.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/deploy.sh new file mode 100644 index 00000000..8ddbe493 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/publish' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form 'file=@cba.zip' | jq diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/enrich.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/enrich.sh new file mode 100644 index 00000000..632cb89f --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/enrich.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/enrich' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +-o 'cba.zip' \ +--form 'file=@../package_native/CBA.zip' | jq diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-base-ra.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-base-ra.sh new file mode 100644 index 00000000..3046cfd8 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-base-ra.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="helm_base_template" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "564e55dc-3b90-4c9c-9e97-42f2c97d8f11", + "vf-module-model-version": "3d55e2a6-7634-4ceb-98e9-2852d621a544", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vfw-cnf-cds-base-profile", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-pkg-ra.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-pkg-ra.sh new file mode 100644 index 00000000..a80238db --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vf-pkg-ra.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="helm_vpkg" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "95e56eee-eeef-4a18-a032-8dbd757544b5", + "vf-module-model-version": "de66174a-d401-4b31-9331-3a44ad3ba01b", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vfw-cnf-cds-base-profile", + "k8s-rb-profile-source": "vfw-cnf-cds-base-profile", + "k8s-rb-profile-namespace": "vfirewall", + "k8s-rb-profile-k8s-version": "1.18.9", + "k8s-rb-config-template-name": "ssh-service-config", + "k8s-rb-config-template-source": "ssh-service-config", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-config.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-config.sh new file mode 100644 index 00000000..aa858145 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-config.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= +# ./run-vnf-config.sh assign/deploy +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +ACTION=$1 +curl --location --request POST 'http://10.254.184.164:30449/api/v1/execution-service/process' \ +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "free5GC", + "blueprintVersion": "1.1.1", + "actionName": "'config-$ACTION'", + "mode": "sync" + }, + "payload": { + "'config-$ACTION-request'": { + "resolution-key": "VF_ueransim_CNF_automated", + "'config-$ACTION-properties'": { + "service-instance-id": "6178e706-fbfc-42c9-a807-79cd8e4a1898", + "vnf-id": "065ee10b-e56e-41bc-ae68-2c2ba8a25e8e", + "vnf-name": "VF_ueransim_CNF_automated", + "vnf-customization-uuid": "5e4fb0a9-e4ff-4c95-859e-4615fee88d3e" + } + } + } +}' | jq '.payload | .["'config-$ACTION-response'"]' + diff --git a/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-ra.sh b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-ra.sh new file mode 100644 index 00000000..2d64bac7 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba-dev/run-vnf-ra.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# 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. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "8.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "vnf" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "51274ece-55ca-4cbc-b7c4-0da0dcc65d38", + "vnf_name": "sample-vnf-name", + "k8s-rb-profile-namespace": "vfw-namespace", + "k8s-rb-profile-k8s-version": "1.18.9", + "int_private1_net_cidr" : "192.168.10.0/24", + "int_private2_net_cidr" : "192.168.20.0/24", + "onap_private_net_cidr" : "10.0.0.0/16", + "private1-prefix-id" : 2, + "private2-prefix-id" : 1 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .vnf | fromjson | .["resource-accumulator-resolved-data"] ' + diff --git a/tutorials/xNF_5G/ueransim/templates/cba/pom.xml b/tutorials/xNF_5G/ueransim/templates/cba/pom.xml new file mode 100644 index 00000000..c36214cb --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba/pom.xml @@ -0,0 +1,64 @@ + + + + + 4.0.0 + + + org.onap.ccsdk.cds.components.cba + test-blueprint-kotlin-parent + 1.1.4-SNAPSHOT + + + free5gc + 1.1.4-SNAPSHOT + pom + + + + ccsdkapps + ccsdkapps + + + + + + org.onap.ccsdk.cds.blueprintsprocessor.modules + processor-core + 1.1.4-SNAPSHOT + compile + + + org.onap.ccsdk.cds.blueprintsprocessor.functions + k8s-connection-plugin + 1.1.4-SNAPSHOT + compile + + + com.att.aft + dme2 + 3.1.200-oss + compile + + + diff --git a/tutorials/xNF_5G/ueransim/templates/cba2dd.py b/tutorials/xNF_5G/ueransim/templates/cba2dd.py new file mode 100644 index 00000000..02cf6085 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/cba2dd.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# COPYRIGHT NOTICE STARTS HERE + +# Copyright 2020 . Samsung Electronics Co., Ltd. +# +# 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 NOTICE ENDS HERE + +import os +import argparse +import json + +# +# Script to convert given Enriched CDS CBA model to Data Dictionary output +# Usage: +# ./cba2dd.py --cba_dir | python3 -m json.tool +# + +def get_resources_definition_file(cba_dir): + definitions_dir = cba_dir + os.sep + "Definitions" + resource_definition_file = definitions_dir + os.sep + "resources_definition_types.json" + if not os.path.exists(definitions_dir): + raise RuntimeError("'%s' directory does not exists or is not CBA directory" % cba_dir) + if not os.path.exists(resource_definition_file): + raise RuntimeError("'%s' file does not exists in CBA Definitions directory. CBA is not Enriched!" % resource_definition_file) + return resource_definition_file + +def create_dd(cba_dir): + with open(get_resources_definition_file(cba_dir)) as f: + output_json = json.load(f) + dd = [] + for _, entry in output_json.items(): + dd.append(build_dd_entry(entry)) + print(json.dumps(dd)) + +def build_dd_entry(definition_entry): + """Builds Data Dictionary entry from given dictionary entry. Given entry + itself is added as value for "definition" key. + { + "name": "", + "tags": "", + "data_type": "", + "description": "", + "entry_schema": "", + "updatedBy": "", + "definition": definition_entry + } + """ + out_dict = {} + out_dict["name"] = definition_entry["name"] + out_dict["tags"] = definition_entry["tags"] + out_dict["data_type"] = definition_entry["property"]["type"] + out_dict["description"] = definition_entry["property"]["description"] + out_dict["entry_schema"] = definition_entry["property"]["type"] + out_dict["updatedBy"] = definition_entry["updated-by"] + out_dict["definition"] = definition_entry + return out_dict + +def main(): + description = """Script to convert given Enriched CDS CBA model to Data Dictionary output. +Example: + ./cba2dd.py --cba_dir cba | python3 -m json.tool + """ + parser = argparse.ArgumentParser(description=description, + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument('--cba_dir', + help='Path to CDS CBA model main directory', + default='') + args = parser.parse_args() + try: + create_dd(args.cba_dir) + except Exception as e: + print(e) + parser.print_help() + exit(1) + +if __name__ == '__main__': + main() diff --git a/tutorials/xNF_5G/ueransim/templates/helm/.gitignore b/tutorials/xNF_5G/ueransim/templates/helm/.gitignore new file mode 100644 index 00000000..17d6b367 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/.gitignore @@ -0,0 +1 @@ +/*.tgz diff --git a/tutorials/xNF_5G/ueransim/templates/helm/Makefile b/tutorials/xNF_5G/ueransim/templates/helm/Makefile new file mode 100644 index 00000000..1e8d8cd8 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/Makefile @@ -0,0 +1,18 @@ +vf-modules = ueransim +.PHONY: build clean $(vf-modules:=-build) $(vf-modules:-clean) $(vf-modules:=-package) + +package: $(vf-modules:=-package) +build: $(vf-modules:=-build) +clean: $(vf-modules:=-clean) + +$(vf-modules:=-package): %-package: %-build + mv $(@:package=)*.tgz helm_$(@:-package=).tgz + cp helm_$(@:-package=).tgz $(@:-package=)_cloudtech_k8s_charts.tgz + +$(vf-modules:=-build): %-build: %-clean + helm package $(@:-build=) + +$(vf-modules:=-clean): + rm -f $(@:-clean=)-*.tgz + rm -f helm_$(@:-clean=).tgz + rm -f $(@:-clean=)_cloudtech_k8s_charts.tgz diff --git a/tutorials/xNF_5G/ueransim/templates/helm/README.txt b/tutorials/xNF_5G/ueransim/templates/helm/README.txt new file mode 100644 index 00000000..63429e91 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/README.txt @@ -0,0 +1,7 @@ +Helm content of onboarding package + +To create necessary archives, please ensure you have [helm] and [make] installed first. + +In case it's your first time you're using helm, please issue `helm init -c` command to initialize your helm client + +To create necessary artifacts, issue `make` command diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/Chart.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/Chart.yaml new file mode 100644 index 00000000..e02f2aca --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/Chart.yaml @@ -0,0 +1,23 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: v2 +name: ueransim +description: A Helm chart to deploy UERANSIM +version: 2.0.0 +appVersion: v3.1.3 +icon: https://raw.githubusercontent.com/aligungr/UERANSIM/master/.github/logo.png +maintainers: + - email: abderaouf.khichane@orange.com + name: Abderaouf KHICHANE + - email: ilhem.fajjari@orange.com + name: Ilhem FAJJARI diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/README.md b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/README.md new file mode 100644 index 00000000..8f90283e --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/README.md @@ -0,0 +1,157 @@ +# UERANSIM Helm chart + +This is a Helm chart for deploying [UERANSIM](https://github.com/aligungr/UERANSIM) on Kubernetes. It has been tested only with [free5GC](../chart/free5gc) but should also run with [open5gs](https://github.com/open5gs/open5gs). + +## Prerequisites + - A Kubernetes cluster ready to use. You can use [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/) to create it. + - [Multus-CNI](https://github.com/intel/multus-cni). + - [Helm3](https://helm.sh/docs/intro/install/). + - [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (optional). + - A physical network interface on each Kubernetes node named `eth0`. +**Note:** If the name of network interfaces on your Kubernetes nodes is different from `eth0`, see [Networks configuration](#networks-configuration). + +## Quickstart guide + +### Install UERANSIM +```console +kubectl create ns +helm -n install ./ueransim/ +``` + +Note that if you have already installed the N3iwf on the same cluster, you should disable the creation of the N2 network as it has already been created for the N3iwf. +```console +helm -n install --set global.n2network.enabled=false ./ueransim/ +``` + +### Check the state of the created pod +```console +kubectl -n get pods -l "app=ueransim" +``` + +### Uninstall UERANSIM +```console +helm -n delete +``` +Or... +```console +helm -n uninstall +``` + +## Configuration + +### Testing with another 5G core network +This Helm chart has been tested only with [free5GC](../chart/free5gc) but should also run with [open5gs](https://github.com/open5gs/open5gs). If you want to test it with open5gs then you should only use the `open5gs-values.yaml` file to override the Helm chart default values. +```console +helm -n install -f ./ueransim/open5gs-values.yaml ./ueransim/ +``` + + +### Networks configuration +In this section, we'll suppose that you have at least one interface on each Kubernetes node and its name is `toto`. Then you have to set these parameters to `toto`: + - `global.n2network.masterIf` + - `global.n4network.masterIf` +Please see [NETWORKS5G's README](../networks5g) for more details. + +## Usage information +Once this helm chart installed, a PDU session will be crated automatically. Furthermore, a TUN interface will be created on the UE POD. This interface can be used to test the connectivity: +```console +kubectl -n exec -it -- bash +``` +Whithin the POD: + - Verify that the TUN interface has been created. Its name should be `uesimtun0`. +```console +ip address +... +5: uesimtun0: mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500 + link/none + inet 10.1.0.1/32 scope global uesimtun0 + valid_lft forever preferred_lft forever +``` + - Use the TUN interface. +```console +ping -I uesimtun0 www.google.com +traceroute -i uesimtun0 www.google.com +curl --interface uesimtun0 www.google.com +``` + +## Customized installation +This chart allows you to customize its installation. The table below shows the parameters that can be modified before installing the chart or when upgrading it as well as their default values. + +### Global parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.multiCluster` | Must be set to `true` if you are deploying the the N3IWF in a different cluster from the one where the control plane is deployed and `global.amf.service.ngap.enabled` is set to true. | `false` | +| `global.cpClusterIP` | The IP address of one of the cluster nodes where the control plane is deployed. | `nil` | + +| `global.amf.service.ngap.name` | The name of the AMF NGAP service. | `amf-n2` | +| `global.amf.service.ngap.type` | The type of the AMF NGAP service. | `ClusterIP` | +| `global.amf.service.ngap.port` | The AMF NGAP port number. | `38412` | +| `global.amf.service.ngap.nodeport` | The nodePort number to access the AMF NGAP service from outside of cluster. | `31412` | +| `global.amf.service.ngap.protocol` | The protocol used for this service. | `SCTP` | +| `global.gnb.n3if.IpAddress` | The IP address of the UERANSIM’s N3 interface. | `10.100.50.233` | + +### N2 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n2network.name` | N2 network name. | `n2network` | +| `global.n2network.masterIf` | N2 network MACVLAN master interface. | `eth0` | +| `global.n2network.subnetIP` | N2 network subnet IP address. | `10.100.50.248` | +| `global.n2network.cidr` | N2 network cidr. | `29` | +| `global.n2network.gatewayIP` | N2 network gateway IP address. | `10.100.50.254` | + +### N3 Network parameters +| Parameter | Description | Default value | +| --- | --- | --- | +| `global.n3network.name` | N3 network name. | `n3network` | +| `global.n3network.masterIf` | N3 network MACVLAN master interface. | `eth0` | +| `global.n3network.subnetIP` | N3 network subnet IP address. | `10.100.50.232` | +| `global.n3network.cidr` | N3 network cidr. | `29` | +| `global.n3network.gatewayIP` | N3 network gateway IP address. | `10.100.50.238` | + +### Main chart parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `projectName` | The name of UERANSIM application (used in labels). | `ueransim` | + +### gNB parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `gnb.enabled` | If `true` then deploy the UERANSIM gNB. | `true` | +| `gnb.name` | Th name of the gNB (used in labels and when naming the deployment). | `gnb` | +| `gnb.replicaCount` | The number of gNB replicas | `1` | +| `gnb.image.name` | The gNB Docker image name. | `towards5gs/ueransim-gnb` | +| `gnb.image.tag` | The gNB Docker image tag. | `defaults to the chart AppVersion` | +| `gnb.configmap.name` | The name of the configmap to be used to import the configuration to the gNB POD. | `gnb-configmap` | +| `gnb.volume.name` | The name of the volume to be mounted to the gNB POD. | `gnb-volume` | +| `gnb.volume.mount` | The path to the folder where configuration files should be mounted on the gNB POD. | `/ueransim/config` | +| `gnb.service.name` | The name of the service to expose the RADIO interface. | `gnb-service` | +| `gnb.service.type` | The type of the service to expose the RADIO interface. | `ClusterIP` | +| `gnb.service.port` | The port number used for the RADIO interface. | `4997` | +| `gnb.service.protocol` | The protocol used for the RADIO interface. | `UDP` | +| `gnb.configuration` | The UERANSIM gNB [configuration](https://github.com/aligungr/UERANSIM/wiki/Configuration#gnb-configuration) in YAML format. | Check [values.yaml](./values.yaml) | +| `gnb.ipAddress`| The IP address of gNB’s N2 interface. | `10.100.50.250` | +| `gnb.amf.n2if.IpAddress` | The IP address of the AMF’s N2 interface. | `10.100.50.249` | +| `gnb.amf.service.ngap.enabled` | If `true` then a Kubernetes service will be used to access the AMF NGAP service instead of accessing directly the AMF’s N2 interface. `gnb.amf.n2if.IpAddress` must be set to the name of the service or IP address of a node where AMF is deployed. | `false` | + +### UE parameters + +| Parameter | Description | Default value | +| --- | --- | --- | +| `ue.enabled` | If `true` then deploy the UERANSIM UE. | `true` | +| `ue.name` | Th name of the UE (used in labels and when naming the deployment). | `ue` | +| `ue.replicaCount` | The number of UE replicas | `1` | +| `ue.image.name` | The UE Docker image name. | `towards5gs/ueransim-ue` | +| `ue.image.tag` | The UE Docker image tag. | `defaults to the chart AppVersion` | +| `ue.configmap.name` | The name of the configmap to be used to import the configuration to the UE POD. | `ue-configmap` | +| `ue.volume.name` | The name of the volume to be mounted to the UE POD. | `ue-volume` | +| `ue.volume.mount` | The path to the folder where configuration files should be mounted on the UE POD. | `/ueransim/config` | +| `ue.configuration` | The UERANSIM UE [configuration](https://github.com/aligungr/UERANSIM/wiki/Configuration#ue-configuration) in YAML format. | Check [values.yaml](./values.yaml) | +| `ue.command` | The command to be executed to run the UERANSIM UE. | `"../build/nr-ue -c ./ue-config.yaml"` | +| `ue.script` | A script to be executed after running the UERANSIM UE. It may be used to periodically generate traffic for example. | `""` | + +## Reference + - https://github.com/aligungr/UERANSIM/wiki/ + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/multicluster-enabled-values.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/multicluster-enabled-values.yaml new file mode 100644 index 00000000..d8b0532d --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/multicluster-enabled-values.yaml @@ -0,0 +1,17 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + multiCluster: true + cpClusterIP: 192.168.121.16 # set this to the IP of the cluster where control plane is deployed + upClusterIP: 192.168.121.17 # set this to the IP of the cluster where user plane is deployed + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/open5gs-values.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/open5gs-values.yaml new file mode 100644 index 00000000..000139d1 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/open5gs-values.yaml @@ -0,0 +1,60 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +gnb: + configuration: |- + nci: '0x000000010' # NR Cell Identity (36-bit) + idLength: 32 # NR gNB ID length in bits [22...32] + tac: 1 # Tracking Area Code + # List of supported S-NSSAIs by this gNB + # Indicates whether or not SCTP stream number errors should be ignored. + ignoreStreamIds: true + + mcc: '901' + mnc: '70' + slices: + - sst: 1 + sd: 1 +ue: + configuration: |- + supi: 'imsi-901700000000001' + mcc: '901' + mnc: '70' + key: '465B5CE8B199B49FAA5F0A2EE238A6BC' + op: 'E8ED289DEBA952E4283B54E88E6183CA' + opType: 'OPC' + amf: '8000' + imei: '356938035643803' + imeiSv: '4370816125816151' + sessions: + - type: 'IPv4' + apn: 'internet' + slice: + sst: 0x01 + sd: 0x010203 + # Configured NSSAI for this UE by HPLMN + configured-nssai: + - sst: 0x01 + sd: 0x010203 + # Default Configured NSSAI for this UE + default-nssai: + - sst: 1 + sd: 1 + # Supported encryption and integrity algorithms by this UE + integrity: + IA1: true + IA2: true + IA3: true + ciphering: + EA1: true + EA2: true + EA3: true diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/services-enabled-values.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/services-enabled-values.yaml new file mode 100644 index 00000000..d8ad9ed7 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/services-enabled-values.yaml @@ -0,0 +1,30 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +global: + amf: + service: + ngap: + enabled: true + name: amf-n2 + port: 38412 + nodeport: 31412 + protocol: SCTP + type: NodePort + n2network: + enabled: false + + + + + + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/NOTES.txt b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/NOTES.txt new file mode 100644 index 00000000..a97b2588 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/NOTES.txt @@ -0,0 +1,28 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# +# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm +# + +1. Get the UE Pod name by running: + export POD_NAME=$(kubectl get pods --namespace {{ $.Release.Namespace }} -l "component={{ .Values.ue.name }}" -o jsonpath="{.items[0].metadata.name}") + +2. Check that uesimtun0 interface has been created by running these commands: + kubectl --namespace {{ $.Release.Namespace }} logs $POD_NAME + kubectl --namespace {{ $.Release.Namespace }} exec -it $POD_NAME -- ip address + +2. Try to access internet from the UE by running: + kubectl --namespace {{ $.Release.Namespace }} exec -it $POD_NAME -- ping -I uesimtun0 www.google.com + kubectl --namespace {{ $.Release.Namespace }} exec -it $POD_NAME -- curl --interface uesimtun0 www.google.com + kubectl --namespace {{ $.Release.Namespace }} exec -it $POD_NAME -- traceroute -i uesimtun0 www.google.com + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/_helpers.tpl b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/_helpers.tpl new file mode 100644 index 00000000..073f25c6 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/_helpers.tpl @@ -0,0 +1,87 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{/* +Expand the name of the chart. +*/}} +{{- define "ueransim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ueransim.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "ueransim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ueransim.labels" -}} +helm.sh/chart: {{ include "ueransim.chart" . }} +{{ include "ueransim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ueransim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ueransim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +gNB Pod Annotations +*/}} +{{- define "ueransim.gnbAnnotations" -}} +{{- with .Values.gnb }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +UE Pod Annotations +*/}} +{{- define "ueransim.ueAnnotations" -}} +{{- with .Values.ue }} +{{- if .podAnnotations }} +{{- toYaml .podAnnotations }} +{{- end }} +{{- end }} +{{- end }} + + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-configmap.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-configmap.yaml new file mode 100644 index 00000000..2809dcd0 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-configmap.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.gnb }} +{{- if .enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.projectName }} + component: {{ .name }} +data: + gnb-config.yaml: | + + {{- .configuration | nindent 4 }} + + linkIp: 0.0.0.0 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) + # gNB's local IP address for N2 Interface (Usually same with local IP) +{{- if .amf.service.ngap.enabled }} + ngapIp: 0.0.0.0 +{{- else }} + ngapIp: {{ .n2if.ipAddress }} +{{- end }} + gtpIp: {{ .n3if.ipAddress }} # gNB's local IP address for N3 Interface (Usually same with local IP) + + # List of AMF address information + amfConfigs: + - address: {{ .amf.n2if.ipAddress }} + port: {{ .amf.n2if.port }} + +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-deployment.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-deployment.yaml new file mode 100644 index 00000000..d27fcaae --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-deployment.yaml @@ -0,0 +1,89 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.gnb }} +{{- if and .enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ueransim.fullname" $ }}-{{ .name }} + labels: + {{- include "ueransim.labels" $ | nindent 4 }} + app: {{ $.Values.projectName }} + component: {{ .name }} +spec: + selector: + matchLabels: + {{- include "ueransim.selectorLabels" $ | nindent 6 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + replicas: {{ .replicaCount }} + template: + metadata: + labels: + {{- include "ueransim.selectorLabels" $ | nindent 8 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + annotations: + {{- include "ueransim.gnbAnnotations" $ | nindent 8 }} + k8s.v1.cni.cncf.io/networks: '[ + {{- if not .amf.service.ngap.enabled }} + { "name": "{{ $.Values.global.n2network.name }}-{{ include "ueransim.fullname" $ }}", + "interface": "n2", + "ips": [ "{{ .n2if.ipAddress }}/{{ $.Values.global.n2network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n2network.gatewayIP }}" ] + }, + {{- end }} + { "name": "{{ $.Values.global.n3network.name }}-{{ include "ueransim.fullname" $ }}", + "interface": "n3", + "ips": [ "{{ .n3if.ipAddress }}/{{ $.Values.global.n3network.cidr }}" ], + "gateway": [ "{{ $.Values.global.n3network.gatewayIP }}" ] + } + ]' + + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + name: {{ .name }} + ports: + - name: gnb-ue + containerPort: {{ .service.port }} + protocol: {{ .service.protocol }} + securityContext: + capabilities: + add: ["NET_ADMIN"] + command: ["./nr-gnb"] + args: ["-c", "{{ .volume.mount }}/gnb-config.yaml"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + configMap: + name: {{ .configmap.name }} +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n2-nad.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n2-nad.yaml new file mode 100644 index 00000000..f5c21fe0 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n2-nad.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if not .Values.gnb.amf.service.ngap.enabled }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n2network.name }}-{{ include "ueransim.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n2network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n2network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n3-nad.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n3-nad.yaml new file mode 100644 index 00000000..bc607418 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-n3-nad.yaml @@ -0,0 +1,40 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ .Values.global.n3network.name }}-{{ include "ueransim.fullname" $ }} +spec: + config: '{ + "cniVersion": "0.3.1", + "plugins": [ + { + "type": "macvlan", + "capabilities": { "ips": true }, + "master": {{ .Values.global.n3network.masterIf | quote }}, + "mode": "bridge", + "ipam": { + "type": "static", + "routes": [ + { + "dst": "0.0.0.0/0", + "gw": "{{ .Values.global.n3network.gatewayIP }}" + } + ] + } + }, { + "capabilities": { "mac": true }, + "type": "tuning" + } + ] + }' diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-service.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-service.yaml new file mode 100644 index 00000000..36c76921 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/gnb/gnb-service.yaml @@ -0,0 +1,31 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if and .Values.gnb.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.gnb.service.name }} + labels: + app: {{ .Values.projectName }} + component: {{ .Values.gnb.name }} +spec: + type: {{ .Values.gnb.service.type }} + ports: + - name: gnb-ue + port: {{ .Values.gnb.service.port }} + protocol: {{ .Values.gnb.service.protocol }} + selector: + app: {{ .Values.projectName }} + component: {{ .Values.gnb.name }} +{{- end }} + diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/tests/connectivity-test.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/tests/connectivity-test.yaml new file mode 100644 index 00000000..385040cf --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/tests/connectivity-test.yaml @@ -0,0 +1,87 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI, Michal CHABIERA +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- if .Values.ue.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.ue.test.connectivity.configmap.name }} + annotations: + "halm.sh/hook": test +data: + script-connectivity-test.sh: | + #!/bin/bash + echo "Get ue pod name" + pod_name="$(kubectl -n free5gc get pods | grep -- -ue- | awk '{print $1}')" + echo "${pod_name}" + echo "***********************************************************************" + echo "" + + echo "Get ip address table for ${pod_name}" + ip_address="$(kubectl -n free5gc exec -i ${pod_name} -- bash -c 'ip address')" + echo "${ip_address}" + tun_interface="$(echo "$ip_address" | awk '$1 ~ /^[0-9].*/ && $2 ~/^uesimtun0/ {print}')" + if [ -z "$tun_interface" ] ; then + echo "" + echo "uesimtun0 interface not found" + exit 1 + fi + echo "***********************************************************************" + echo "" + + echo "Test connectivity" + ping_output="$(kubectl -n free5gc exec -i ${pod_name} -- bash -c 'ping -c 10 -I uesimtun0 google.com')" + echo "${ping_output}" + echo "***********************************************************************" + echo "" + ping_statistics="$(echo "$ping_output" |tail -n -2 |awk -F', ' 'NR==1 {print}')" + loss_rate="$(echo "$ping_statistics" |awk -F', ' '{for(i=1; i<=NF; i++){if(match($i, /packet loss$/))print $i}}')" + if [ "$loss_rate" != "100% packet loss" ] ; then + echo "Connection test passed - ${loss_rate}" + exit 0 + else + echo "Connection test failed - ${loss_rate}" + exit 1 + fi +# echo "$ping_output" |tail -n -2 |awk -F', ' 'NR==1 { print ($3 == "0% packet loss"? "Connection passed - " $3: "Connection failed - " $3)}' + + #ping -qc10 google.com |awk -F', ' 'END {print ($3 == "0% packet loss"? "Connection passed - " $3: "Connection failed - " $3)}' +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ .Values.ue.test.connectivity.name }} + annotations: + helm.sh/hook: test +spec: + template: + spec: + containers: + - name: {{ .Values.ue.test.connectivity.name }} + image: {{ .Values.ue.test.connectivity.image }} + imagePullPolicy: IfNotPresent + command: ["bin/sh"] + args: ["/scripts/script-connectivity-test.sh"] + volumeMounts: + - name: {{ .Values.ue.test.connectivity.volume.name }} + mountPath: {{ .Values.ue.test.connectivity.volume.mount }} + readOnly: true + volumes: + - name: {{ .Values.ue.test.connectivity.volume.name }} + configMap: + defaultMode: 0755 + name: {{ .Values.ue.test.connectivity.configmap.name }} + restartPolicy: Never + backoffLimit: 4 + ttlSecondsAfterFinished: {{ .Values.ue.test.connectivity.ttlseconds }} +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-configmap.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-configmap.yaml new file mode 100644 index 00000000..8b342a10 --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-configmap.yaml @@ -0,0 +1,42 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ue }} +{{- if .enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .configmap.name }} + labels: + app: {{ $.Values.projectName }} + component: {{ .name }} +data: + ue-config.yaml: | + + {{- .configuration | nindent 4 }} + + # List of gNB IP addresses for Radio Link Simulation + gnbSearchList: + - {{ $.Values.gnb.service.name }} + + wrapper.sh: | + #!/bin/bash + + mkdir /dev/net + mknod /dev/net/tun c 10 200 + + {{ .command }} + + {{ .script | nindent 4 }} + +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-deployment.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-deployment.yaml new file mode 100644 index 00000000..276dd81a --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/templates/ue/ue-deployment.yaml @@ -0,0 +1,74 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +{{- with .Values.ue }} +{{- if .enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ueransim.fullname" $ }}-{{ .name }} + labels: + {{- include "ueransim.labels" $ | nindent 4 }} + app: {{ $.Values.projectName }} + component: {{ .name }} +spec: + selector: + matchLabels: + {{- include "ueransim.selectorLabels" $ | nindent 6 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + replicas: {{ .replicaCount }} + template: + metadata: + annotations: + {{- include "ueransim.ueAnnotations" $ | nindent 8 }} + labels: + {{- include "ueransim.selectorLabels" $ | nindent 8 }} + app: {{ $.Values.projectName }} + component: {{ .name }} + spec: + imagePullSecrets: + {{- toYaml .imagePullSecrets | nindent 8 }} + securityContext: + {{- toYaml .podSecurityContext | nindent 8 }} + containers: + - image: {{ .image.name }}:{{ .image.tag | default $.Chart.AppVersion }} + name: {{ .name }} + securityContext: + {{- toYaml .securityContext | nindent 12 }} + command: ["{{ .volume.mount }}/wrapper.sh"] + volumeMounts: + - mountPath: {{ .volume.mount }} + name: {{ .volume.name }} + resources: + {{- toYaml .resources | nindent 12 }} + dnsPolicy: ClusterFirst + restartPolicy: Always + nodeSelector: + {{- toYaml .nodeSelector | nindent 8 }} + affinity: + {{- toYaml .affinity | nindent 8 }} + tolerations: + {{- toYaml .tolerations | nindent 8 }} + + volumes: + - name: {{ .volume.name }} + configMap: + name: {{ .configmap.name }} + items: + - key: ue-config.yaml + path: ue-config.yaml + - key: wrapper.sh + path: wrapper.sh + mode: 0755 +{{- end }} +{{- end }} diff --git a/tutorials/xNF_5G/ueransim/templates/helm/ueransim/values.yaml b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/values.yaml new file mode 100644 index 00000000..b99a92da --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/helm/ueransim/values.yaml @@ -0,0 +1,177 @@ +# +# Software Name : towards5gs-helm +# SPDX-FileCopyrightText: Copyright (c) 2021 Orange +# SPDX-License-Identifier: Apache-2.0 +# +# This software is distributed under the Apache License 2.0, +# the text of which is available at todo +# or see the "LICENSE" file for more details. +# +# Author: Abderaouf KHICHANE, Ilhem FAJJARI, Ayoub BOUSSELMI +# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes +# +# Default values for ueransim-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + multiCluster: false + #Global network parametes + n2network: + name: n2network + masterIf: eth0 + subnetIP: 10.100.50.248 + cidr: 29 + gatewayIP: 10.100.50.254 + excludeIP: 10.100.50.254 + n3network: + name: n3network + masterIf: eth0 + subnetIP: 10.100.50.232 + cidr: 29 + gatewayIP: 10.100.50.238 + excludeIP: 10.100.50.238 + + +projectName: ueransim + +gnb: + enabled: true + name: gnb + replicaCount: 1 + image: + name: towards5gs/ueransim-gnb + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: gnb-configmap + volume: + name: gnb-volume + mount: /ueransim/config + service: + name: gnb-service + type: ClusterIP + port: 4997 + protocol: UDP + + n2if: # NGAP + ipAddress: 10.100.50.250 + n3if: # GTP-U + ipAddress: 10.100.50.236 + + amf: + n2if: # NGAP + ipAddress: amf-n2 #10.152.183.60 #amf-n2 + port: 38412 + service: + ngap: + enabled: true # if true set gnb.amf.n2if.ipAddress to the name of AMF NGAP service or the IP of the cluster hosting the AMF + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + resources: + limits: + cpu: 250m + memory: 256Mi + requests: + cpu: 250m + memory: 256Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + nci: '0x000000010' # NR Cell Identity (36-bit) + idLength: 32 # NR gNB ID length in bits [22...32] + tac: 1 # Tracking Area Code + # List of supported S-NSSAIs by this gNB + slices: + - sst: 0x1 + sd: 0x010203 + # Indicates whether or not SCTP stream number errors should be ignored. + ignoreStreamIds: true +ue: + enabled: true + name: ue + replicaCount: 1 + image: + name: towards5gs/ueransim-ue + tag: "v3.1.3" + pullPolicy: IfNotPresent + configmap: + name: ue-configmap + volume: + name: ue-volume + mount: /ueransim/config + command: "./nr-ue -c ../config/ue-config.yaml" # This is the command that will be launched in the UE container + # A script that will be run after the UE creation. It may be used to periodically generate traffic + script: "" + # script: |- + # ping ..... + + podAnnotations: {} + # additional annotations + imagePullSecrets: [] + podSecurityContext: {} + securityContext: + capabilities: + add: ["NET_ADMIN"] + resources: + limits: + cpu: 120m + memory: 128Mi + requests: + cpu: 120m + memory: 128Mi + nodeSelector: {} + tolerations: [] + affinity: {} + + configuration: |- + supi: "imsi-208930000000003" # IMSI number + mcc: '208' # Mobile Country Code value + mnc: '93' # Mobile Network Code value (2 or 3 digits) + key: "8baf473f2f8fd09487cccbd7097c6862" # Operator code (OP or OPC) of the UE + op: "8e27b6af0e692e750f32667a3b14605d" # This value specifies the OP type and it can be either 'OP' or 'OPC' + opType: "OPC" # This value specifies the OP type and it can be either 'OP' or 'OPC' + amf: '8000' # Authentication Management Field (AMF) value + imei: '356938035643803' # IMEI number of the device + imeiSv: '4370816125816151' + sessions: + - type: "IPv4" + apn: "internet" + slice: + sst: 0x01 + sd: 0x010203 + # Configured NSSAI for this UE by HPLMN + configured-nssai: + - sst: 0x01 + sd: 0x010203 + # Default Configured NSSAI for this UE + default-nssai: + - sst: 1 + sd: 1 + # Supported encryption and integrity algorithms by this UE + integrity: + IA1: true + IA2: true + IA3: true + ciphering: + EA1: true + EA2: true + EA3: true + + test: + connectivity: + name: ue-connectivity-test + image: bitnami/kubectl:1.22.0 + configmap: + name: connectivity-test-configmap + volume: + name: connectivity-test-volume + mount: /scripts + ttlseconds: 100 diff --git a/tutorials/xNF_5G/ueransim/templates/tools/tail_all.sh b/tutorials/xNF_5G/ueransim/templates/tools/tail_all.sh new file mode 100644 index 00000000..d18674ea --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/tools/tail_all.sh @@ -0,0 +1,161 @@ +#!/bin/bash +# COPYRIGHT NOTICE STARTS HERE + +# Copyright 2020 . Samsung Electronics Co., Ltd. +# +# 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 NOTICE ENDS HERE + +set -e + +get_pod_name() { + kubectl -n ${NAMESPACE} get pod -l app="$1" -o jsonpath='{ .items[0].metadata.name }' +} + +exec_in_pod() { + local pod="$1" + local container="$2" + shift 2 + local cmd="$@" + kubectl --namespace ${NAMESPACE} exec ${pod} --container ${container} -- sh -c "${cmd}" +} + +pod_logs() { + local pod="$1" + local container="$2" + local options="$3" + shift 3 + kubectl --namespace ${NAMESPACE} logs ${pod} --container ${container} ${options:+"${options}"} +} + +k8s_tail() { + local operation="$1" + local file_to_tail="$2" + local pod_label="$3" + local container="$4" + if [ -z ${container} ]; then + container=${pod_label} + fi + mkdir -p ${CACHE_FILE_DIR} + local pod=$(get_pod_name ${pod_label}) + file_path_savable_form="$(sed 's#/#__#g' <<<"$file_to_tail")" + LINECOUNT_CACHE_FILE=${CACHE_FILE_DIR}/${pod}-${container}-${file_path_savable_form} + local line_count=0 + if [ "${operation}" == "start" ]; then + if [ "${file_to_tail}" == "POD_LOG" ]; then + line_count=$(pod_logs ${pod} ${container} "" | wc -l) + else + if ! line_count=$(exec_in_pod ${pod} ${container} "wc -l ${file_to_tail}"); then + echo "Failed to get file ${file_to_tail} line count, maybe it does not exist. Using linecount 0." >&2 + line_count=0 + else + # parse out linecount from wc -l output + line_count=$(echo -e "${line_count}" | tail -1 | cut -d' ' -f1) + fi + fi + echo "${line_count}" > ${LINECOUNT_CACHE_FILE} + echo "Saved file ${file_to_tail} of POD ${pod_label} linecount ${line_count} into file ${LINECOUNT_CACHE_FILE}" + fi + if [ "${operation}" == "collect" ]; then + if [ ! -f ${LINECOUNT_CACHE_FILE} ]; then + echo "Linecount cache file ${LINECOUNT_CACHE_FILE} not found. Either tailing was not started or POD has restarted. Colected from log beginning." >&2 + start_line=0 + else + start_line=$(cat ${LINECOUNT_CACHE_FILE}) + fi + echo "Tail pod's ${pod_label} container ${container} file ${file_to_tail} starting from line ${start_line} onwards" >&2 + if [ "${file_to_tail}" == "POD_LOG" ]; then + current_line_count=$(pod_logs ${pod} ${container} "" | wc -l) + lines_from_end=$(( ${current_line_count}-${start_line} )) + echo "Execute kubectl logs for ${pod} POD's ${container} container. Log ${lines_from_end} lines from end" + pod_logs ${pod} ${container} --tail=${lines_from_end} + else + echo "Execute cmd "tail -n +${start_line} ${file_to_tail}" inside ${pod} POD's ${container} container" + exec_in_pod ${pod} ${container} "tail -n +${start_line} ${file_to_tail}" + fi + fi +} + +tail_it() { + local operation=$1 + for tail in "${TAILS[@]}" + do + tailarray=(${tail}) + result=$(k8s_tail ${operation} ${tailarray[@]}) + if [ "${operation}" == "collect" ]; then + mkdir -p ${RESULT_DIR} + log_file=$(basename ${tailarray[0]}) + if [ "${log_file}" == "POD_LOG" ]; then + log_file=${log_file}.log + fi + pod=${tailarray[1]} + container="${pod:-tailarray[2]}" + out_file=${RESULT_DIR}/${pod}_${container}_${log_file} + echo -e "${result}" > ${out_file} + echo "Saved tail content to log file ${out_file}" + else + echo -e "${result}" + fi + done +} + + +##### MAIN ##### +if [ -f ./tail_config ]; then +. ./tail_config +fi +NAMESPACE=${NAMESPACE:-onap} +CACHE_FILE_DIR=${CACHE_FILE_DIR:-.k8s_tail} +RESULT_DIR=${RESULT_DIR:-./tail_results} +DEFAULT_TAILS=() +TAILS=("${TAILS[@]:-${DEFAULT_TAILS[@]}}") + +case "$1" in + -h|--help|help|?|"") + echo "Script usage:" + echo "$0 start - Start pods' log tailing" + echo "$0 collect - Collect all logs currently tailed or get all logs as whole" + echo "" + echo "If start is not called before collect is called, collect gathers all logs completely. " + echo "Otherwise logs are collected only from the linecount of the time of start call." + echo "" + echo "Log files collected is configured with 'tail_config' file in the same directory with the script." + echo "Config file needs to fontain bash array variable named TAILS=() and format of each entry in array is" + echo " []" + echo "where is actual file path inside the pod or special string 'POD_LOG' that means kubectl logs" + echo "where optional is to specify POD's container if many containers in the pod. By default same name as pod is used." + echo "" + echo 'Example: TAILS=(' + echo ' "/app/logs/apih/metrics.log so"' + echo ' "/app/logs/bpmn/debug.log so-bpmn-infra"' + echo ' "/app/logs/vnfm-adapter/debug.log so-vnfm-adapter"' + echo ' "/var/log/onap/sdnc/karaf.log sdnc"' + echo ' "/tmp/app.out network-name-gen"' + echo ' "POD_LOG cds-blueprints-processor"' + echo ' "POD_LOG multicloud multicloud"' + echo ' "POD_LOG multicloud-k8s multicloud-k8s"' + echo ' "POD_LOG multicloud-k8s framework-artifactbroker"' + echo ' "/app/logs/openstack/error.log so-openstack-adapter"' + echo ' "/app/logs/openstack/debug.log so-openstack-adapter"' + echo ' )' + echo "" + ;; + start|collect) + tail_it $1 + ;; + *) + echo "Wrong usage, check '$0 -h'" >&2 + exit 1 + ;; +esac diff --git a/tutorials/xNF_5G/ueransim/templates/tools/tail_config b/tutorials/xNF_5G/ueransim/templates/tools/tail_config new file mode 100644 index 00000000..ca49793c --- /dev/null +++ b/tutorials/xNF_5G/ueransim/templates/tools/tail_config @@ -0,0 +1,18 @@ +#!/bin/false + +NAMESPACE="onap" + +TAILS=( + "/app/logs/apih/debug.log so" + "/app/logs/apih/error.log so" + "/app/logs/bpmn/debug.log so-bpmn-infra" + "/app/logs/openstack/error.log so-openstack-adapter" + "/app/logs/openstack/debug.log so-openstack-adapter" + "/var/log/onap/sdnc/karaf.log sdnc" + "POD_LOG network-name-gen" + "POD_LOG cds-blueprints-processor" + "POD_LOG multicloud multicloud" + "POD_LOG multicloud-k8s multicloud-k8s" + "POD_LOG multicloud-k8s framework-artifactbroker" + "POD_LOG msb-iag msb-iag" +)