diff --git a/sky/adaptors/kubernetes.py b/sky/adaptors/kubernetes.py index 093274044d4..4bf910cd1a1 100644 --- a/sky/adaptors/kubernetes.py +++ b/sky/adaptors/kubernetes.py @@ -11,6 +11,11 @@ kubernetes = None urllib3 = None + +LOCAL_PORT_FOR_PORT_FORWARD = 23100 +PORT_FORWARD_PROXY_CMD_TEMPLATE = 'kubernetes-port-forward-proxy-command.yaml.j2' +PORT_FORWARD_PROXY_CMD_PATH = '~/.sky/port-forward-proxy-cmd-{cluster_name}.sh' + _configured = False _core_api = None _auth_api = None diff --git a/sky/backends/backend_utils.py b/sky/backends/backend_utils.py index 42e8ee113a5..e96cfa4bee0 100644 --- a/sky/backends/backend_utils.py +++ b/sky/backends/backend_utils.py @@ -40,6 +40,7 @@ from sky import skypilot_config from sky import spot as spot_lib from sky import status_lib +from sky.adaptors import kubernetes from sky.backends import onprem_utils from sky.skylet import constants from sky.skylet import log_lib @@ -710,6 +711,12 @@ def remove_cluster( docker_user: If not None, use this user to ssh into the docker """ username = auth_config['ssh_user'] + port_forward_proxy_cmd_path = os.path.expanduser( + kubernetes.PORT_FORWARD_PROXY_CMD_PATH.format( + cluster_name=cluster_name)) + if os.path.exists(port_forward_proxy_cmd_path): + os.remove(port_forward_proxy_cmd_path) + config_path = os.path.expanduser(cls.ssh_conf_path) if not os.path.exists(config_path): return