commit
5633f2464d
|
@ -32,6 +32,8 @@ WEB_PORT=8888
|
||||||
USER_PORT=9100
|
USER_PORT=9100
|
||||||
#cluster net, default is 172.16.0.1/16
|
#cluster net, default is 172.16.0.1/16
|
||||||
CLUSTER_NET="172.16.0.1/16"
|
CLUSTER_NET="172.16.0.1/16"
|
||||||
|
# ip addresses range of containers for batch job, default is 10.0.3.0/24
|
||||||
|
BATCH_NET="10.0.3.0/24"
|
||||||
#configurable-http-proxy public port, default is 8000
|
#configurable-http-proxy public port, default is 8000
|
||||||
PROXY_PORT=8000
|
PROXY_PORT=8000
|
||||||
#configurable-http-proxy api port, default is 8001
|
#configurable-http-proxy api port, default is 8001
|
||||||
|
@ -103,6 +105,7 @@ pre_start_master () {
|
||||||
# iptables for NAT network for containers to access web
|
# iptables for NAT network for containers to access web
|
||||||
iptables -t nat -F
|
iptables -t nat -F
|
||||||
iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE
|
iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE
|
||||||
|
iptables -t nat -A POSTROUTING -s $BATCH_NET -j MASQUERADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ WEB_PORT=8888
|
||||||
USER_PORT=9100
|
USER_PORT=9100
|
||||||
#cluster net, default is 172.16.0.1/16
|
#cluster net, default is 172.16.0.1/16
|
||||||
CLUSTER_NET="172.16.0.1/16"
|
CLUSTER_NET="172.16.0.1/16"
|
||||||
|
# ip addresses range of containers for batch job, default is 10.0.3.0/24
|
||||||
|
BATCH_NET="10.0.3.0/24"
|
||||||
|
|
||||||
. $DOCKLET_CONF/docklet.conf
|
. $DOCKLET_CONF/docklet.conf
|
||||||
|
|
||||||
|
@ -103,6 +105,7 @@ pre_start_master () {
|
||||||
# iptables for NAT network for containers to access web
|
# iptables for NAT network for containers to access web
|
||||||
iptables -t nat -F
|
iptables -t nat -F
|
||||||
iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE
|
iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE
|
||||||
|
iptables -t nat -A POSTROUTING -s $BATCH_NET -j MASQUERADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ lxc.network.link = lxcbr0
|
||||||
lxc.network.flags = up
|
lxc.network.flags = up
|
||||||
lxc.network.ipv4 = %IP%
|
lxc.network.ipv4 = %IP%
|
||||||
lxc.network.ipv4.gateway = %GATEWAY%
|
lxc.network.ipv4.gateway = %GATEWAY%
|
||||||
|
lxc.network.mtu = 1420
|
||||||
|
|
||||||
lxc.cgroup.pids.max = 2048
|
lxc.cgroup.pids.max = 2048
|
||||||
lxc.cgroup.memory.limit_in_bytes = %CONTAINER_MEMORY%M
|
lxc.cgroup.memory.limit_in_bytes = %CONTAINER_MEMORY%M
|
||||||
|
|
|
@ -16,6 +16,7 @@ import grpc
|
||||||
#from utils import env
|
#from utils import env
|
||||||
import json,lxc,subprocess,threading,os,time,traceback
|
import json,lxc,subprocess,threading,os,time,traceback
|
||||||
from utils import imagemgr,etcdlib,gputools
|
from utils import imagemgr,etcdlib,gputools
|
||||||
|
from utils.lvmtool import sys_run
|
||||||
from worker import ossmounter
|
from worker import ossmounter
|
||||||
from protos import rpc_pb2, rpc_pb2_grpc
|
from protos import rpc_pb2, rpc_pb2_grpc
|
||||||
|
|
||||||
|
@ -200,8 +201,8 @@ class TaskController(rpc_pb2_grpc.WorkerServicer):
|
||||||
path = env.getenv('DOCKLET_LIB')
|
path = env.getenv('DOCKLET_LIB')
|
||||||
subprocess.call([path+"/master/userinit.sh", username])
|
subprocess.call([path+"/master/userinit.sh", username])
|
||||||
logger.info("user %s directory not found, create it" % username)
|
logger.info("user %s directory not found, create it" % username)
|
||||||
sys_run("mkdir -p /var/lib/lxc/%s" % lxcname)
|
sys_run("mkdir -p /var/lib/lxc/%s" % lxcname)
|
||||||
logger.info("generate config file for %s" % lxcname)
|
logger.info("generate config file for %s" % lxcname)
|
||||||
|
|
||||||
def config_prepare(content):
|
def config_prepare(content):
|
||||||
content = content.replace("%ROOTFS%",rootfs)
|
content = content.replace("%ROOTFS%",rootfs)
|
||||||
|
@ -272,8 +273,11 @@ class TaskController(rpc_pb2_grpc.WorkerServicer):
|
||||||
conffile.write("\n"+ mount_str % (self.fspath, username, mount.remotePath, rootfs, mount.remotePath))
|
conffile.write("\n"+ mount_str % (self.fspath, username, mount.remotePath, rootfs, mount.remotePath))
|
||||||
conffile.close()
|
conffile.close()
|
||||||
|
|
||||||
container = lxc.Container(lxcname)
|
|
||||||
if not container.start():
|
logger.info("Start container %s..." % lxcname)
|
||||||
|
#container = lxc.Container(lxcname)
|
||||||
|
ret = subprocess.run('lxc-start -n %s'%lxcname,stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
|
||||||
|
if ret.returncode != 0:
|
||||||
logger.error('start container %s failed' % lxcname)
|
logger.error('start container %s failed' % lxcname)
|
||||||
self.release_ip(ip)
|
self.release_ip(ip)
|
||||||
self.imgmgr.deleteFS(lxcname)
|
self.imgmgr.deleteFS(lxcname)
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
var host = window.location.host;
|
var host = window.location.host;
|
||||||
url = "//" + host + "/batch/job/output/" + "{{ masterip }}" + "/" + "{{ jobid }}" + "/" + "{{ taskid }}" + "/" + "{{ instid }}" + "/" + "{{ issue }}" + "/";
|
url = "//" + host + "/batch/job/output/" + "{{ masterip }}" + "/" + "{{ jobid }}" + "/" + "{{ taskid }}" + "/" + "{{ instid }}" + "/" + "{{ issue }}" + "/";
|
||||||
$.post(url,{},function(data){
|
$.post(url,{},function(data){
|
||||||
$("#output").html(data.data);
|
$("#output").text(String(data.data));
|
||||||
},"json");
|
},"json");
|
||||||
}
|
}
|
||||||
setInterval(updateOutput,2000);
|
setInterval(updateOutput,2000);
|
||||||
|
|
Loading…
Reference in New Issue