Skip to content

Commit 2d90bbc

Browse files
committed
Rename properties in Kubernetes backend config:
* networking -> proxy_jump * ssh_host -> hostname * ssh_port -> port In addition, `dstack-` prefix has been added to jump pod and service names for consistency with jobs pods and services. Closes: #3136
1 parent daa3d03 commit 2d90bbc

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

docs/docs/reference/server/config.yml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ to configure [backends](../../concepts/backends.md) and other [server-level sett
295295

296296
###### `projects[n].backends[type=kubernetes].networking` { #kubernetes-networking data-toc-label="networking" }
297297

298-
#SCHEMA# dstack._internal.core.backends.kubernetes.models.KubernetesNetworkingConfig
298+
#SCHEMA# dstack._internal.core.backends.kubernetes.models.KubernetesProxyJumpConfig
299299
overrides:
300300
show_root_heading: false
301301

src/dstack/_internal/core/backends/kubernetes/compute.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from dstack._internal.core.backends.base.offers import filter_offers_by_requirements
2121
from dstack._internal.core.backends.kubernetes.models import (
2222
KubernetesConfig,
23-
KubernetesNetworkingConfig,
23+
KubernetesProxyJumpConfig,
2424
)
2525
from dstack._internal.core.backends.kubernetes.utils import (
2626
call_api_method,
@@ -69,10 +69,10 @@ class KubernetesCompute(
6969
def __init__(self, config: KubernetesConfig):
7070
super().__init__()
7171
self.config = config.copy()
72-
networking_config = self.config.networking
73-
if networking_config is None:
74-
networking_config = KubernetesNetworkingConfig()
75-
self.networking_config = networking_config
72+
proxy_jump = self.config.proxy_jump
73+
if proxy_jump is None:
74+
proxy_jump = KubernetesProxyJumpConfig()
75+
self.proxy_jump = proxy_jump
7676
self.api = get_api_from_config_data(config.kubeconfig.data)
7777

7878
def get_offers_by_requirements(
@@ -143,7 +143,7 @@ def run_job(
143143
# as an ssh proxy jump to connect to all other services in Kubernetes.
144144
# Setup jump pod in a separate thread to avoid long-running run_job.
145145
# In case the thread fails, the job will be failed and resubmitted.
146-
jump_pod_hostname = self.networking_config.ssh_host
146+
jump_pod_hostname = self.proxy_jump.hostname
147147
if jump_pod_hostname is None:
148148
jump_pod_hostname = get_cluster_public_ip(self.api)
149149
if jump_pod_hostname is None:
@@ -156,7 +156,7 @@ def run_job(
156156
namespace=self.config.namespace,
157157
project_name=run.project_name,
158158
ssh_public_keys=[project_ssh_public_key.strip(), run.run_spec.ssh_key_pub.strip()],
159-
jump_pod_port=self.networking_config.ssh_port,
159+
jump_pod_port=self.proxy_jump.port,
160160
)
161161
if not created:
162162
threading.Thread(
@@ -820,11 +820,11 @@ def _run_ssh_command(hostname: str, port: int, ssh_private_key: str, command: st
820820

821821

822822
def _get_jump_pod_name(project_name: str) -> str:
823-
return f"{project_name}-ssh-jump-pod"
823+
return f"dstack-{project_name}-ssh-jump-pod"
824824

825825

826826
def _get_jump_pod_service_name(project_name: str) -> str:
827-
return f"{project_name}-ssh-jump-pod-service"
827+
return f"dstack-{project_name}-ssh-jump-pod-service"
828828

829829

830830
def _get_pod_service_name(pod_name: str) -> str:

src/dstack/_internal/core/backends/kubernetes/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
DEFAULT_NAMESPACE = "default"
99

1010

11-
class KubernetesNetworkingConfig(CoreModel):
12-
ssh_host: Annotated[
13-
Optional[str], Field(description="The external IP address of any node")
11+
class KubernetesProxyJumpConfig(CoreModel):
12+
hostname: Annotated[
13+
Optional[str], Field(description="The external IP address or hostname of any node")
1414
] = None
15-
ssh_port: Annotated[
15+
port: Annotated[
1616
Optional[int], Field(description="Any port accessible outside of the cluster")
1717
] = None
1818

@@ -24,8 +24,8 @@ class KubeconfigConfig(CoreModel):
2424

2525
class KubernetesBackendConfig(CoreModel):
2626
type: Annotated[Literal["kubernetes"], Field(description="The type of backend")] = "kubernetes"
27-
networking: Annotated[
28-
Optional[KubernetesNetworkingConfig], Field(description="The networking configuration")
27+
proxy_jump: Annotated[
28+
Optional[KubernetesProxyJumpConfig], Field(description="The SSH proxy jump configuration")
2929
] = None
3030
namespace: Annotated[
3131
str, Field(description="The namespace for resources managed by `dstack`")

src/tests/_internal/core/backends/kubernetes/test_configurator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from dstack._internal.core.backends.kubernetes.models import (
99
KubeconfigConfig,
1010
KubernetesBackendConfigWithCreds,
11-
KubernetesNetworkingConfig,
11+
KubernetesProxyJumpConfig,
1212
)
1313
from dstack._internal.core.errors import BackendInvalidCredentialsError
1414

@@ -17,7 +17,7 @@ class TestKubernetesConfigurator:
1717
def test_validate_config_valid(self):
1818
config = KubernetesBackendConfigWithCreds(
1919
kubeconfig=KubeconfigConfig(data="valid", filename="-"),
20-
networking=KubernetesNetworkingConfig(ssh_host=None, ssh_port=None),
20+
proxy_jump=KubernetesProxyJumpConfig(hostname=None, port=None),
2121
)
2222
with patch(
2323
"dstack._internal.core.backends.kubernetes.utils.get_api_from_config_data"
@@ -30,7 +30,7 @@ def test_validate_config_valid(self):
3030
def test_validate_config_invalid_config(self):
3131
config = KubernetesBackendConfigWithCreds(
3232
kubeconfig=KubeconfigConfig(data="invalid", filename="-"),
33-
networking=KubernetesNetworkingConfig(ssh_host=None, ssh_port=None),
33+
proxy_jump=KubernetesProxyJumpConfig(hostname=None, port=None),
3434
)
3535
with (
3636
patch(

0 commit comments

Comments
 (0)