Skip to content

Commit

Permalink
[K8s] Add user hash to the kind config for multi-user system permissi…
Browse files Browse the repository at this point in the history
…on issue (#4045)

* [K8s] Remove the kind config after `sky local down` for multi-user system permission issue

* upd

* fix

* resolve comments
  • Loading branch information
cblmemo authored Oct 10, 2024
1 parent ea881b4 commit 5491cf3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5097,7 +5097,8 @@ def _deploy_local_cluster(gpus: bool):

# Get directory of script and run it from there
cwd = os.path.dirname(os.path.abspath(up_script_path))
run_command = up_script_path + ' --gpus' if gpus else up_script_path
run_command = up_script_path + f' {common_utils.get_user_hash()}'
run_command = run_command + ' --gpus' if gpus else run_command
run_command = shlex.split(run_command)

# Setup logging paths
Expand Down
13 changes: 8 additions & 5 deletions sky/utils/kubernetes/create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ IMAGE_GPU="us-central1-docker.pkg.dev/skypilot-375900/skypilotk8s/skypilot-gpu:l
PORT_RANGE_START=30000
PORT_RANGE_END=30100

USER_HASH=$1

# Check for GPU flag
ENABLE_GPUS=false
if [[ "$1" == "--gpus" ]]; then
if [[ "$2" == "--gpus" ]]; then
ENABLE_GPUS=true
fi

Expand Down Expand Up @@ -88,16 +90,17 @@ if kind get clusters | grep -q skypilot; then
fi

# Generate cluster YAML
echo "Generating /tmp/skypilot-kind.yaml"
YAML_PATH="/tmp/skypilot-kind-$USER_HASH.yaml"
echo "Generating $YAML_PATH"

# Add GPUs flag to the generate_kind_config.py command if GPUs are enabled
if $ENABLE_GPUS; then
python -m sky.utils.kubernetes.generate_kind_config --path /tmp/skypilot-kind.yaml --port-start ${PORT_RANGE_START} --port-end ${PORT_RANGE_END} --gpus
python -m sky.utils.kubernetes.generate_kind_config --path $YAML_PATH --port-start ${PORT_RANGE_START} --port-end ${PORT_RANGE_END} --gpus
else
python -m sky.utils.kubernetes.generate_kind_config --path /tmp/skypilot-kind.yaml --port-start ${PORT_RANGE_START} --port-end ${PORT_RANGE_END}
python -m sky.utils.kubernetes.generate_kind_config --path $YAML_PATH --port-start ${PORT_RANGE_START} --port-end ${PORT_RANGE_END}
fi

kind create cluster --config /tmp/skypilot-kind.yaml --name skypilot
kind create cluster --config $YAML_PATH --name skypilot

echo "Kind cluster created."

Expand Down

0 comments on commit 5491cf3

Please sign in to comment.