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

[Core][Docker] Support docker login on RunPod. #4287

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion sky/provision/runpod/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def run_instances(region: str, cluster_name_on_cloud: str,
disk_size=config.node_config['DiskSize'],
image_name=config.node_config['ImageId'],
ports=config.ports_to_open_on_launch,
public_key=config.node_config['PublicKey'])
public_key=config.node_config['PublicKey'],
docker_login_config=config.provider_config.get(
'docker_login_config'))
except Exception as e: # pylint: disable=broad-except
logger.warning(f'run_instances error: {e}')
raise
Expand Down
26 changes: 25 additions & 1 deletion sky/provision/runpod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from sky import sky_logging
from sky.adaptors import runpod
from sky.provision import docker_utils
from sky.skylet import constants
from sky.utils import common_utils

Expand Down Expand Up @@ -100,7 +101,8 @@ def list_instances() -> Dict[str, Dict[str, Any]]:


def launch(name: str, instance_type: str, region: str, disk_size: int,
image_name: str, ports: Optional[List[int]], public_key: str) -> str:
image_name: str, ports: Optional[List[int]], public_key: str,
docker_login_config: Optional[Dict[str, str]]) -> str:
"""Launches an instance with the given parameters.

Converts the instance_type to the RunPod GPU name, finds the specs for the
Expand Down Expand Up @@ -142,6 +144,27 @@ def launch(name: str, instance_type: str, region: str, disk_size: int,
if ports is not None:
custom_ports_str = ''.join([f'{p}/tcp,' for p in ports])

template_id = None
if docker_login_config is not None:
login_config = docker_utils.DockerLoginConfig(**docker_login_config)
# TODO(tian): The `name` argument seems only for display purpose but
# not specifying the registry server. Double check if that works for
# registries other than Docker Hub.
# TODO(tian): Delete the registry auth and template after the instance
# is terminated.
create_auth_resp = runpod.runpod.create_container_registry_auth(
name=f'{name}-registry-auth',
username=login_config.username,
password=login_config.password,
)
registry_auth_id = create_auth_resp['id']
create_template_resp = runpod.runpod.create_template(
name=f'{name}-template',
image_name=image_name,
registry_auth_id=registry_auth_id,
)
template_id = create_template_resp['id']

new_instance = runpod.runpod.create_pod(
name=name,
image_name=image_name,
Expand All @@ -157,6 +180,7 @@ def launch(name: str, instance_type: str, region: str, disk_size: int,
f'{constants.SKY_REMOTE_RAY_DASHBOARD_PORT}/http,'
f'{constants.SKY_REMOTE_RAY_PORT}/http'),
support_public_ip=True,
template_id=template_id,
docker_args=
f'bash -c \'echo {encoded} | base64 --decode > init.sh; bash init.sh\'')

Expand Down
4 changes: 3 additions & 1 deletion sky/setup_files/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def parse_readme(readme: str) -> str:
'oci': ['oci'] + local_ray,
'kubernetes': ['kubernetes>=20.0.0'],
'remote': remote,
'runpod': ['runpod>=1.5.1'],
# For the container registry auth api. Reference:
# https://github.com/runpod/runpod-python/releases/tag/1.6.1
'runpod': ['runpod>=1.6.1'],
'fluidstack': [], # No dependencies needed for fluidstack
'cudo': ['cudo-compute>=0.1.10'],
'paperspace': [], # No dependencies needed for paperspace
Expand Down
13 changes: 13 additions & 0 deletions sky/templates/runpod-ray.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ provider:
module: sky.provision.runpod
region: "{{region}}"
disable_launch_config_check: true
# For RunPod, we directly set the image id for the docker as runtime environment
# support, thus we need to avoid the DockerInitializer detects the docker field
# and performs the initialization. Therefore we put the docker login config in
# the provider config here.
{%- if docker_login_config is not none %}
docker_login_config:
username: |-
{{docker_login_config.username}}
password: |-
{{docker_login_config.password}}
server: |-
{{docker_login_config.server}}
{%- endif %}

auth:
ssh_user: root
Expand Down
Loading