From 13d1c5d6e5253998b56f2658d560835a79fe5252 Mon Sep 17 00:00:00 2001 From: Marco Donadoni Date: Tue, 26 Mar 2024 16:44:14 +0100 Subject: [PATCH] feat(k8s): set custom ingressClassName for interactive sessions (#581) Closes reanahub/reana#742 --- reana_workflow_controller/config.py | 3 +++ reana_workflow_controller/k8s.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/reana_workflow_controller/config.py b/reana_workflow_controller/config.py index 122606fb..5d42a862 100644 --- a/reana_workflow_controller/config.py +++ b/reana_workflow_controller/config.py @@ -197,6 +197,9 @@ def _env_vars_dict_to_k8s_list(env_vars): REANA_INGRESS_ANNOTATIONS = json.loads(os.getenv("REANA_INGRESS_ANNOTATIONS", "{}")) """REANA Ingress annotations defined by the administrator.""" +REANA_INGRESS_CLASS_NAME = os.getenv("REANA_INGRESS_CLASS_NAME") +"""REANA Ingress class name defined by the administrator to be used for interactive sessions.""" + IMAGE_PULL_SECRETS = os.getenv("IMAGE_PULL_SECRETS", "").split(",") """Docker image pull secrets which allow the usage of private images.""" diff --git a/reana_workflow_controller/k8s.py b/reana_workflow_controller/k8s.py index 8ff873f5..56287d99 100644 --- a/reana_workflow_controller/k8s.py +++ b/reana_workflow_controller/k8s.py @@ -1,5 +1,5 @@ # This file is part of REANA. -# Copyright (C) 2019, 2020, 2021, 2022 CERN. +# Copyright (C) 2019, 2020, 2021, 2022, 2024 CERN. # # REANA is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -26,6 +26,7 @@ JUPYTER_INTERACTIVE_SESSION_DEFAULT_IMAGE, JUPYTER_INTERACTIVE_SESSION_DEFAULT_PORT, REANA_INGRESS_ANNOTATIONS, + REANA_INGRESS_CLASS_NAME, ) @@ -105,6 +106,8 @@ def _build_ingress(self): spec = client.V1IngressSpec( rules=[client.V1IngressRule(http=ingress_rule_value)] ) + if REANA_INGRESS_CLASS_NAME: + spec.ingress_class_name = REANA_INGRESS_CLASS_NAME ingress = client.V1Ingress( api_version="networking.k8s.io/v1", kind="Ingress",