Skip to content

Commit

Permalink
Deprecate dev image & use image from arg instead.
Browse files Browse the repository at this point in the history
Fix #9
  • Loading branch information
Cyril Diagne committed Oct 12, 2019
1 parent 8bd7cf1 commit bd31f17
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 42 deletions.
11 changes: 6 additions & 5 deletions cmd/dev-start.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ import (

// startCmd represents the `dev start` command
var startCmd = &cobra.Command{
Use: "start",
Use: "start [docker-image]",
Short: "Start a dev session.",
Long: "Start a dev session.",
Long: "Start a dev session using the provider docker image.",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if err := start(); err != nil {
if err := start(args[0]); err != nil {
fmt.Println("ERROR:", err)
}
},
Expand All @@ -43,12 +44,12 @@ func init() {
devCmd.AddCommand(startCmd)
}

func start() error {
func start(devImage string) error {
fmt.Println("→ Starting a remote session...")
// Image to run.
image := viper.GetString("image")
// Command to run.
command := []string{"kuda_dev_start"}
command := []string{"kuda_dev_start", devImage}

// Add the CWD to the volumes mounted in Docker.
dir, err := os.Getwd()
Expand Down
9 changes: 8 additions & 1 deletion docs/kuda/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,24 @@ Deletes the remote cluster.
### → Start

```bash
kuda dev start
kuda dev start [base-image]
```

Starts a remote dev session with the current working directory.

**Example:** `kuda dev start nvidia/cuda:10.1-base`

This command:

- Provisions a node with GPU on the cluster & install the nvidia driver
- Starts a development pod based on the Deep Learning VM
- Synchronise the directory provided as parameter with the remote node

List of recommended `base-image`:

- all images from [nvidia/cuda](https://hub.docker.com/r/nvidia/cuda/)
- gcloud's [Deep Learning containers](https://cloud.google.com/ai-platform/deep-learning-containers/docs/choosing-container)

### → Stop

```bash
Expand Down
4 changes: 3 additions & 1 deletion docs/kuda/remote_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Developping on remote sessions offers many other advantages such as:
Start a remote dev session that will be provisioned on your cluster.

```bash
kuda dev start
kuda dev start nvidia/cuda:10.1-base
```

`nvidia/cuda:10.1-base` Is the docker image to use as base. It allows you to specify which version of CUDA and CuDNN you need. You can find a list of suggested images in the kuda dev [reference page](https://docs.kuda.dev/kuda/cli#dev).

This command will start the remote session and synchronize the CWD \(current working directory\) with the remote instance.

Upon started, it will also print the cluster's IP address / port to use later on. Make not of that as we'll refer to it later as `<your-dev-session-external-ip:port>`
Expand Down
3 changes: 0 additions & 3 deletions images/dev/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions images/dev/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions images/providers/gcp/.config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export KUDA_DEFAULT_GPU="${KUDA_DEFAULT_GPU:-k80}"
export KUDA_DEFAULT_USE_PREEMPTIBLE="${KUDA_DEFAULT_USE_PREEMPTIBLE:-false}"

export KUDA_DEV_APP_NAME="${KUDA_DEV_APP_NAME:-kuda-dev}"
export KUDA_DEV_APP_IMAGE_NAME="${KUDA_DEV_APP_IMAGE_NAME:-kuda-dev-base}"
export KUDA_DEV_APP_IMAGE="${KUDA_DEV_APP_IMAGE:-gcr.io/kuda-project/dev:1.0.0}"
export KUDA_DEV_SYNC_PATH="${KUDA_DEV_SYNC_PATH:-/app_home}"

# Disable prompts.
Expand Down
44 changes: 22 additions & 22 deletions images/providers/gcp/dev_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ gcloud container clusters get-credentials $KUDA_GCP_CLUSTER_NAME
# --num-nodes 1 \
# --quiet

# TODO: Support multiple sessions.
# tmp_uuid=$(od -x /dev/urandom | head -1 | awk '{print $2$3}')
# KUDA_DEV_APP_NAME=kuda-dev-$tmp_uuid

# exit 1
uid=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 7)
dev_app_name=$KUDA_DEV_APP_NAME-$uid
dev_image=$1

# Launch.
# TODO: materialize as external yaml file and customize
Expand All @@ -26,39 +24,41 @@ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: $KUDA_DEV_APP_NAME
name: $dev_app_name
labels:
app: $KUDA_DEV_APP_NAME
app: $dev_app_name
spec:
ports:
- name: http
port: 8000
targetPort: 80
selector:
app: $KUDA_DEV_APP_NAME
app: $dev_app_name
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: $KUDA_DEV_APP_NAME
name: $dev_app_name
spec:
replicas: 1
selector:
matchLabels:
app: $KUDA_DEV_APP_NAME
app: $dev_app_name
template:
metadata:
labels:
app: $KUDA_DEV_APP_NAME
app: $dev_app_name
spec:
containers:
- name: $KUDA_DEV_APP_IMAGE_NAME
image: $KUDA_DEV_APP_IMAGE
- name: kuda-dev-image
image: $dev_image
imagePullPolicy: Always
resources:
limits:
nvidia.com/gpu: 1
ports:
- containerPort: 80
command: ["/bin/bash"]
env:
- name: POD_NAME
valueFrom:
Expand All @@ -85,7 +85,7 @@ cat <<EOF | kubectl apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: $KUDA_DEV_APP_NAME-gateway
name: $dev_app_name-gateway
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
Expand All @@ -95,17 +95,17 @@ spec:
name: http
protocol: HTTP
hosts:
- "$KUDA_DEV_APP_NAME.example.com"
- "$dev_app_name.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: $KUDA_DEV_APP_NAME
name: $dev_app_name
spec:
hosts:
- "$KUDA_DEV_APP_NAME.example.com"
- "$dev_app_name.example.com"
gateways:
- $KUDA_DEV_APP_NAME-gateway
- $dev_app_name-gateway
http:
- match:
- uri:
Expand All @@ -114,7 +114,7 @@ spec:
- destination:
port:
number: 8000
host: $KUDA_DEV_APP_NAME
host: $dev_app_name
EOF

# Initialize ksync.
Expand Down Expand Up @@ -149,7 +149,7 @@ sp="⣷⣯⣟⡿⢿⣻⣽⣾"
while true; do
printf "\b${sp:i++%${#sp}:1}"
min=1
status=$(kubectl get deployment $KUDA_DEV_APP_NAME -o jsonpath={.status.availableReplicas})
status=$(kubectl get deployment $dev_app_name -o jsonpath={.status.availableReplicas})
if [ ! -z "$status" ]; then
if [ "$status" -ge 1 ]; then
break
Expand All @@ -164,7 +164,7 @@ ksync watch --daemon=true

# Watch file changes.
ksync create \
--selector=app=$KUDA_DEV_APP_NAME \
--selector=app=$dev_app_name \
--reload=false \
$KUDA_DEV_SYNC_PATH \
$KUDA_DEV_SYNC_PATH
Expand All @@ -180,5 +180,5 @@ echo "$ingress_host:$ingress_port"
echo

# Launch remote shell.
pod_name=$(kubectl get pods -o name | grep -m1 $KUDA_DEV_APP_NAME | cut -d'/' -f 2)
pod_name=$(kubectl get pods -o name | grep -m1 $dev_app_name | cut -d'/' -f 2)
kubectl exec -it $pod_name -- /bin/bash

0 comments on commit bd31f17

Please sign in to comment.