Skip to content

Commit

Permalink
Support setting ports of coordinator pod from GSCOORDINATOR_PORTS env (
Browse files Browse the repository at this point in the history
  • Loading branch information
lidongze0629 authored Dec 17, 2021
1 parent 53df412 commit cd2eeb8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/graphscope/deploy/kubernetes/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<host>[^:/ ]+).?(?P<port>[0-9]*).*"
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
)

Expand Down

0 comments on commit cd2eeb8

Please sign in to comment.