Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[k8s] Make ingress paths namespace aware #3373

Merged
merged 6 commits into from
May 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions sky/provision/kubernetes/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sky.utils import kubernetes_enums
from sky.utils.resources_utils import port_ranges_to_set

_PATH_PREFIX = '/skypilot/{cluster_name_on_cloud}/{port}'
_PATH_PREFIX = '/skypilot/{namespace}/{cluster_name_on_cloud}/{port}'
_LOADBALANCER_SERVICE_NAME = '{cluster_name_on_cloud}-skypilot-loadbalancer'


Expand Down Expand Up @@ -71,12 +71,14 @@ def _open_ports_using_ingress(
)

# Prepare service names, ports, for template rendering
service_details = [
(f'{cluster_name_on_cloud}-skypilot-service--{port}', port,
_PATH_PREFIX.format(cluster_name_on_cloud=cluster_name_on_cloud,
port=port).rstrip('/').lstrip('/'))
for port in ports
]
service_details = [(f'{cluster_name_on_cloud}-skypilot-service--{port}',
port,
_PATH_PREFIX.format(
cluster_name_on_cloud=cluster_name_on_cloud,
port=port,
namespace=kubernetes_utils.
get_current_kube_config_context_namespace()).rstrip(
'/').lstrip('/')) for port in ports]

# Generate ingress and services specs
# We batch ingress rule creation because each rule triggers a hot reload of
Expand Down Expand Up @@ -232,7 +234,10 @@ def _query_ports_for_ingress(
result: Dict[int, List[common.Endpoint]] = {}
for port in ports:
path_prefix = _PATH_PREFIX.format(
cluster_name_on_cloud=cluster_name_on_cloud, port=port)
cluster_name_on_cloud=cluster_name_on_cloud,
port=port,
namespace=kubernetes_utils.
get_current_kube_config_context_namespace())

http_port, https_port = external_ports \
if external_ports is not None else (None, None)
Expand Down
Loading