Bring up worker as a pod -- worker
(index,num_replicas,scheduler_host,num_servers,num_workers,algorithm,data_dir,output_dir)
| 290 | os.system(cmd) |
| 291 | |
| 292 | def upServer(index,num_replicas,scheduler_host,num_servers,num_workers,algorithm,data_dir,output_dir): |
| 293 | ''' |
| 294 | Bring up worker as a pod -- worker |
| 295 | ''' |
| 296 | server=dict() |
| 297 | server['id']='server'+str(index) |
| 298 | server['kind']='ReplicationController' |
| 299 | server['apiVersion']='v1beta1' |
| 300 | |
| 301 | ###set container### |
| 302 | container=dict() |
| 303 | container['name']='server'+str(index) |
| 304 | #image |
| 305 | container['image']='qicongc/pserver' |
| 306 | port=dict() |
| 307 | #port mapping |
| 308 | port['containerPort']=8002 |
| 309 | hostPort=11101+index |
| 310 | port['hostPort']=hostPort |
| 311 | container['ports']=[port] |
| 312 | #environment variables |
| 313 | env=dict() |
| 314 | env['name']='LD_LIBRARY_PATH' |
| 315 | env['value']='/home/parameter_server/third_party/lib/' |
| 316 | container['env']=[env] |
| 317 | #working directory when container starts running |
| 318 | container['workingDir']='/home/parameter_server/script' |
| 319 | #command |
| 320 | 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 8002 ' |
| 321 | cmd+="-scheduler \"role:SCHEDULER,hostname:\'"+scheduler_host+"\',port:11000,id:\'H\'\" " |
| 322 | cmd+="-my_node \"role:SERVER,hostname:\'`cat /tmp/docker/host/host`\',port:"+str(hostPort)+",id:\'S_$(hostname)\'\"" |
| 323 | command=['sh','-c'] |
| 324 | command.append(cmd) |
| 325 | container['command']=command |
| 326 | #volume mapping -- container side |
| 327 | #path for container to identify current minion |
| 328 | volumeMount=dict() |
| 329 | volumeMount['name']='host' |
| 330 | volumeMount['mountPath']='/tmp/docker/host' |
| 331 | container['volumeMounts']=[volumeMount] |
| 332 | #path to van print |
| 333 | volumeMount=dict() |
| 334 | volumeMount['name']='log' |
| 335 | volumeMount['mountPath']='/home/parameter_server/script' |
| 336 | container['volumeMounts'].append(volumeMount) |
| 337 | #path to config file |
| 338 | volumeMount=dict() |
| 339 | volumeMount['name']='config' |
| 340 | volumeMount['mountPath']='/home/parameter_server/config' |
| 341 | container['volumeMounts'].append(volumeMount) |
| 342 | #path to data |
| 343 | volumeMount=dict() |
| 344 | volumeMount['name']='data' |
| 345 | volumeMount['mountPath']='/home/parameter_server/data' |
| 346 | container['volumeMounts'].append(volumeMount) |
| 347 | #path to output |
| 348 | volumeMount=dict() |
| 349 | volumeMount['name']='output' |