From cd2eeb8a42b36f1c7e42d59c10d0ca0587f73ef5 Mon Sep 17 00:00:00 2001 From: DongZe Li <9546726@qq.com> Date: Fri, 17 Dec 2021 18:55:12 +0800 Subject: [PATCH] Support setting ports of coordinator pod from GSCOORDINATOR_PORTS env (#1188) --- python/graphscope/deploy/kubernetes/cluster.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python/graphscope/deploy/kubernetes/cluster.py b/python/graphscope/deploy/kubernetes/cluster.py index 4f2edf400b8a..e656c48c98a7 100644 --- a/python/graphscope/deploy/kubernetes/cluster.py +++ b/python/graphscope/deploy/kubernetes/cluster.py @@ -64,8 +64,6 @@ class KubernetesClusterLauncher(Launcher): _cluster_role_binding_name_prefix = "gs-cluster-reader-binding-" _random_coordinator_service_port = random.randint(59001, 60000) - # placeholder port sometime is needed, such as sshd service - _random_coordinator_placeholder_port = random.randint(60001, 61000) _url_pattern = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))" # noqa: E501 _endpoint_pattern = r"(?:http.*://)?(?P[^:/ ]+).?(?P[0-9]*).*" @@ -351,6 +349,13 @@ def _create_coordinator(self): coordinator_builder.add_simple_envs(envs) + if "GSCOORDINATOR_PORTS" in os.environ: + # a list of port, comma separated + # e.g. 50001,50002,50003,50004 + ports = [int(p) for p in os.environ["GSCOORDINATOR_PORTS"].split(",")] + else: + ports = [self._random_coordinator_service_port] + coordinator_builder.add_coordinator_container( cmd=["/bin/bash"], args=self._build_coordinator_cmd(), @@ -359,10 +364,7 @@ def _create_coordinator(self): cpu=self._saved_locals["k8s_coordinator_cpu"], mem=self._saved_locals["k8s_coordinator_mem"], preemptive=self._saved_locals["preemptive"], - ports=[ - self._random_coordinator_service_port, - self._random_coordinator_placeholder_port, - ], + ports=ports, module_name=self._coordinator_module_name, )