Bring up worker as a pod -- worker
(index,num_replicas,scheduler_host,num_servers,num_workers,algorithm,data_dir,output_dir)
| 157 | return line[2].strip('/') |
| 158 | |
| 159 | def upWorker(index,num_replicas,scheduler_host,num_servers,num_workers,algorithm,data_dir,output_dir): |
| 160 | ''' |
| 161 | Bring up worker as a pod -- worker |
| 162 | ''' |
| 163 | worker=dict() |
| 164 | worker['id']='worker'+str(index) |
| 165 | worker['kind']='ReplicationController' |
| 166 | worker['apiVersion']='v1beta1' |
| 167 | |
| 168 | ###set container### |
| 169 | container=dict() |
| 170 | container['name']='worker'+str(index) |
| 171 | #image |
| 172 | container['image']='qicongc/pserver' |
| 173 | port=dict() |
| 174 | #port mapping |
| 175 | port['containerPort']=8001 |
| 176 | hostPort=11401+index |
| 177 | port['hostPort']=hostPort |
| 178 | container['ports']=[port] |
| 179 | #environment variables |
| 180 | env=dict() |
| 181 | env['name']='LD_LIBRARY_PATH' |
| 182 | env['value']='/home/parameter_server/third_party/lib/' |
| 183 | container['env']=[env] |
| 184 | #working directory when container starts running |
| 185 | container['workingDir']='/home/parameter_server/script' |
| 186 | #command |
| 187 | cmd='../build/ps -num_servers '+str(num_servers)+' -num_workers '+str(num_workers)+' -num_threads '+str(num_servers+num_workers)+' -app_file ../config/'+algorithm+'_l1lr.conf -print_van -bind_to 8001 ' |
| 188 | cmd+="-scheduler \"role:SCHEDULER,hostname:\'"+scheduler_host+"\',port:11000,id:\'H\'\" " |
| 189 | cmd+="-my_node \"role:WORKER,hostname:\'`cat /tmp/docker/host/host`\',port:"+str(hostPort)+",id:\'W_$(hostname)\'\"" |
| 190 | command=['sh','-c'] |
| 191 | command.append(cmd) |
| 192 | container['command']=command |
| 193 | #volume mapping -- container side |
| 194 | #path for container to identify current minion |
| 195 | volumeMount=dict() |
| 196 | volumeMount['name']='host' |
| 197 | volumeMount['mountPath']='/tmp/docker/host' |
| 198 | container['volumeMounts']=[volumeMount] |
| 199 | #path to van print |
| 200 | volumeMount=dict() |
| 201 | volumeMount['name']='log' |
| 202 | volumeMount['mountPath']='/home/parameter_server/script' |
| 203 | container['volumeMounts'].append(volumeMount) |
| 204 | #path to config file |
| 205 | volumeMount=dict() |
| 206 | volumeMount['name']='config' |
| 207 | volumeMount['mountPath']='/home/parameter_server/config' |
| 208 | container['volumeMounts'].append(volumeMount) |
| 209 | #path to data |
| 210 | volumeMount=dict() |
| 211 | volumeMount['name']='data' |
| 212 | volumeMount['mountPath']='/home/parameter_server/data' |
| 213 | container['volumeMounts'].append(volumeMount) |
| 214 | #path to output |
| 215 | volumeMount=dict() |
| 216 | volumeMount['name']='output' |