-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-workers.sh
154 lines (144 loc) · 5.41 KB
/
start-workers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Modify this script by copying it to your home directory
# *** be sure to remove the "exec" line below from your copy! ***
USERSCRIPT=$HOME/start-workers.sh
if [ -x "$USERSCRIPT" ]; then
exec "$USERSCRIPT" "$@"
fi
NUM_WORKERS=2
WORKER_CPU_REQUEST=8
WORKER_CPU_LIMIT=8
WORKER_MEM_REQUEST=16384M
WORKER_MEM_LIMIT=16384M
WORKER_GPU_COUNT=0
IMAGE=${JUPYTER_IMAGE_SPEC:-${DOCKER_IMAGE}}
echo "STARTING WORKERS WITH WORKER_CPU_REQUEST=${WORKER_CPU_REQUEST}"
if kubectl get deployment deployment-ray-worker 2>/dev/null > /dev/null; then
kubectl delete deployment deployment-ray-worker
fi
read -d '' DEPLOYMENT <<EOM
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"labels": {
"app": "ray-cluster-worker"
},
"name": "deployment-ray-worker"
},
"spec": {
"progressDeadlineSeconds": 600,
"replicas": ${NUM_WORKERS},
"selector": {
"matchLabels": {
"app": "ray-cluster-worker",
"component": "ray-worker",
"type": "ray"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "ray-cluster-worker",
"component": "ray-worker",
"type": "ray"
}
},
"spec": {
"containers": [
{
"args": [
"ray start --num-cpus=${WORKER_CPU_REQUEST} --address=service-ray-cluster:6380 --object-manager-port=8076 --node-manager-port=8077 --dashboard-agent-grpc-port=8078 --dashboard-agent-listen-port=52365 --block --object-store-memory=7516192768 --memory=17179869184"
],
"command": [
"/bin/bash",
"-c",
"--"
],
"env": [
{
"name": "MY_CPU_REQUEST",
"valueFrom": {
"resourceFieldRef": {
"divisor": "0",
"resource": "requests.cpu"
}
}
}
],
"image": "${IMAGE}",
"imagePullPolicy": "Always",
"name": "ray-worker",
"resources": {
"limits": {
"cpu": "${WORKER_CPU_LIMIT}",
"memory": "${WORKER_MEM_LIMIT}"
},
"requests": {
"cpu": "${WORKER_CPU_REQUEST}",
"memory": "${WORKER_MEM_REQUEST}"
}
},
"securityContext": {
"allowPrivilegeEscalation": false,
"runAsUser": ${UID}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"volumeMounts": [
{
"mountPath": "/dev/shm",
"name": "dshm"
},
{
"mountPath": "/datasets",
"name": "datasets"
},
{
"mountPath": "/home/${USER}/private",
"name": "home"
},
{
"mountPath": "/home/${USER}",
"name": "course-workspace",
"subPath": "home/${USER}"
},
{
"mountPath": "/home/${USER}/public",
"name": "course-workspace",
"subPath": "public"
}
]
}
],
"terminationGracePeriodSeconds": 30,
"volumes": [
{
"emptyDir": {
"medium": "Memory"
},
"name": "dshm"
},
{
"persistentVolumeClaim": {
"claimName": "dsmlp-datasets"
},
"name": "datasets"
},
{
"persistentVolumeClaim": {
"claimName": "home"
},
"name": "home"
}
]
}
}
}
}
EOM
VOL=$( kubectl get pod ${HOSTNAME} -o json | jq '.spec.volumes[] | select(.name=="course-workspace")' )
DEPLOYMENT=$( echo "$DEPLOYMENT" | jq --argjson v "$VOL" '.spec.template.spec.volumes += [ $v ]')
# echo "$DEPLOYMENT"
echo "$DEPLOYMENT" | kubectl create -f -