Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GraphScope support ResourceQuota limit in namespace #102

Merged
merged 8 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions coordinator/gscoordinator/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def __init__(
gie_graph_manager_image=None,
coordinator_name=None,
coordinator_service_name=None,
etcd_cpu=None,
etcd_mem=None,
zookeeper_cpu=None,
zookeeper_mem=None,
gie_graph_manager_cpu=None,
gie_graph_manager_mem=None,
engine_cpu=None,
engine_mem=None,
vineyard_cpu=None,
Expand Down Expand Up @@ -165,12 +171,18 @@ def __init__(

# etcd pod info
self._etcd_image = etcd_image
self._etcd_cpu = etcd_cpu
self._etcd_mem = etcd_mem

# zookeeper pod info
self._zookeeper_image = zookeeper_image
self._zookeeper_cpu = zookeeper_cpu
self._zookeeper_mem = zookeeper_mem

# interactive engine graph manager info
self._gie_graph_manager_image = gie_graph_manager_image
self._gie_graph_manager_cpu = gie_graph_manager_cpu
self._gie_graph_manager_mem = gie_graph_manager_mem

self._image_pull_policy = image_pull_policy

Expand Down Expand Up @@ -325,6 +337,8 @@ def _create_etcd(self):
name=self._etcd_container_name,
service_name=self._etcd_service_name,
image=self._etcd_image,
cpu=self._etcd_cpu,
mem=self._etcd_mem,
listen_peer_service_port=self._random_etcd_listen_peer_service_port,
listen_client_service_port=self._random_etcd_listen_client_service_port,
)
Expand Down Expand Up @@ -446,13 +460,17 @@ def _create_interactive_engine_service(self):
graph_manager_builder.add_manager_container(
name=self._gie_manager_container_name,
image=self._gie_graph_manager_image,
cpu=self._gie_graph_manager_cpu,
mem=self._gie_graph_manager_mem,
port=self._interactive_engine_manager_port,
)

# add zookeeper container
graph_manager_builder.add_zookeeper_container(
name=self._gie_zookeeper_container_name,
image=self._zookeeper_image,
cpu=self._zookeeper_cpu,
mem=self._zookeeper_mem,
port=self._zookeeper_port,
)

Expand Down
46 changes: 46 additions & 0 deletions coordinator/gscoordinator/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ def CreateInteractiveInstance(self, request, context):
request.object_id,
)
object_id = request.object_id
gremlin_server_cpu = request.gremlin_server_cpu
gremlin_server_mem = request.gremlin_server_mem
manager_host = MAXGRAPH_MANAGER_HOST % (
self._gie_graph_manager_service_name,
self._k8s_namespace,
Expand All @@ -428,6 +430,8 @@ def CreateInteractiveInstance(self, request, context):
"schemaJson": schema_json,
"podNameList": ",".join(self._pods_list),
"containerName": ENGINE_CONTAINER,
"gremlinServerCpu": str(gremlin_server_cpu),
"gremlinServerMem": gremlin_server_mem,
}
post_data = urllib.parse.urlencode(params).encode("utf-8")
create_res = urllib.request.urlopen(url=post_url, data=post_data)
Expand Down Expand Up @@ -774,6 +778,42 @@ def parse_sys_args():
default="256Mi",
help="Memory of engine container, suffix with ['Mi', 'Gi', 'Ti'].",
)
parser.add_argument(
"--k8s_etcd_cpu",
type=float,
default=1.0,
help="Cpu cores of etcd pod, default: 1.0",
)
parser.add_argument(
"--k8s_etcd_mem",
type=str,
default="256Mi",
help="Memory of etcd pod, suffix with ['Mi', 'Gi', 'Ti'].",
)
parser.add_argument(
"--k8s_zookeeper_cpu",
type=float,
default=1.0,
help="Cpu cores of zookeeper container, default: 1.0",
)
parser.add_argument(
"--k8s_zookeeper_mem",
type=str,
default="256Mi",
help="Memory of zookeeper container, suffix with ['Mi', 'Gi', 'Ti'].",
)
parser.add_argument(
"--k8s_gie_graph_manager_cpu",
type=float,
default=1.0,
help="Cpu cores of graph manager container, default: 1.0",
)
parser.add_argument(
"--k8s_gie_graph_manager_mem",
type=str,
default="256Mi",
help="Memory of graph manager container, suffix with ['Mi', 'Gi', 'Ti'].",
)
parser.add_argument(
"--k8s_volumes",
type=str,
Expand Down Expand Up @@ -819,6 +859,12 @@ def launch_graphscope():
gie_graph_manager_image=args.k8s_gie_graph_manager_image,
coordinator_name=args.k8s_coordinator_name,
coordinator_service_name=args.k8s_coordinator_service_name,
etcd_cpu=args.k8s_etcd_cpu,
etcd_mem=args.k8s_etcd_mem,
zookeeper_cpu=args.k8s_zookeeper_cpu,
zookeeper_mem=args.k8s_zookeeper_mem,
gie_graph_manager_cpu=args.k8s_gie_graph_manager_cpu,
gie_graph_manager_mem=args.k8s_gie_graph_manager_mem,
engine_cpu=args.k8s_engine_cpu,
engine_mem=args.k8s_engine_mem,
vineyard_cpu=args.k8s_vineyard_cpu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function _create_pod {
kubectl create configmap $config_name --from-file /home/maxgraph/config_$object_id
sed -e "s/unique_pod_name/$pod_name/g" -e "s/unique_config_name/$config_name/g" \
-e "s/gremlin_image/$gremlin_image/g" -e "s/unique_object_id/$object_id/g" \
-e "s/gremlin_server_cpu/$gremlin_server_cpu/g" -e "s/gremlin_server_mem/$gremlin_server_mem/g" \
-e "s/coordinator_image/$coordinator_image/g" \
/root/maxgraph/pod.yaml > /root/maxgraph/pod_${object_id}.yaml
kubectl apply -f /root/maxgraph/pod_${object_id}.yaml
Expand Down Expand Up @@ -98,6 +99,8 @@ export schema_path=$2
export engine_count=`echo $3 | awk -F"," '{print NF}'`
export pod_hosts=`echo $3 | awk -F"," '{for(i=1;i<=NF;++i) {print $i" "}}'`
export ENGINE_CONTAINER=$4
export engine_paras=$5
export gremlin_server_cpu=$5
export gremlin_server_mem=$6
export engine_paras=$7
export launch_engine_cmd="export object_id=${object_id} && /home/maxgraph/executor-entrypoint.sh"
_create_maxgraph_instance
14 changes: 14 additions & 0 deletions interactive_engine/deploy/docker/dockerfile/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ spec:
# - k8s_node_host
containers:
- image: gremlin_image
resources:
requests:
cpu: gremlin_server_cpu
memory: gremlin_server_mem
limits:
cpu: gremlin_server_cpu
memory: gremlin_server_mem
name: gremlin-container
imagePullPolicy: IfNotPresent
args: ["/home/maxgraph/frontend-entrypoint.sh"]
Expand All @@ -26,6 +33,13 @@ spec:
- mountPath: /home/maxgraph/config
name: config-volume
- image: coordinator_image
resources:
requests:
cpu: gremlin_server_cpu
memory: gremlin_server_mem
limits:
cpu: gremlin_server_cpu
memory: gremlin_server_mem
name: coordinator-container
imagePullPolicy: IfNotPresent
args: ["/home/maxgraph/coordinator-entrypoint.sh"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ private void checkContainerName(String containerName) {
public CreateInstanceEntity createInstance(@RequestParam("graphName") String graphName,
@RequestParam("schemaJson") String schemaJson,
@RequestParam("podNameList") String podNameList,
@RequestParam("containerName") String containerName) throws Exception {
@RequestParam("containerName") String containerName,
@RequestParam("gremlinServerCpu") String gremlinServerCpu,
@RequestParam("gremlinServerMem") String gremlinServerMem) throws Exception {
CreateInstanceEntity createInstanceEntity = new CreateInstanceEntity();
int errorCode;
String errorMessage;
Expand Down Expand Up @@ -123,6 +125,8 @@ public CreateInstanceEntity createInstance(@RequestParam("graphName") String gra
createCommandList.add(schemaPath);
createCommandList.add(podNameList);
createCommandList.add(containerName);
createCommandList.add(gremlinServerCpu);
createCommandList.add(gremlinServerMem);
String command = StringUtils.join(createCommandList, " ");
logger.info("start to create instance with command " + command);
Process process = Runtime.getRuntime().exec(command);
Expand Down
3 changes: 3 additions & 0 deletions proto/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ message CreateInteractiveRequest {
// object id of the graph in vineyard
int64 object_id = 1;
string schema_path = 2;
// resource
float gremlin_server_cpu = 3;
string gremlin_server_mem = 4;
}

message CreateInteractiveResponse {
Expand Down
9 changes: 7 additions & 2 deletions python/graphscope/client/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,14 @@ def send_heartbeat(self):
return self._stub.HeartBeat(request)

@catch_grpc_error
def create_interactive_engine(self, object_id, schema_path):
def create_interactive_engine(
self, object_id, schema_path, gremlin_server_cpu, gremlin_server_mem
):
request = message_pb2.CreateInteractiveRequest(
object_id=object_id, schema_path=schema_path
object_id=object_id,
schema_path=schema_path,
gremlin_server_cpu=gremlin_server_cpu,
gremlin_server_mem=gremlin_server_mem,
)
response = self._stub.CreateInteractiveInstance(request)
return check_grpc_response(response)
Expand Down
39 changes: 38 additions & 1 deletion python/graphscope/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ def __init__(
k8s_image_pull_secrets=gs_config.k8s_image_pull_secrets,
k8s_coordinator_cpu=gs_config.k8s_coordinator_cpu,
k8s_coordinator_mem=gs_config.k8s_coordinator_mem,
k8s_etcd_cpu=gs_config.k8s_etcd_cpu,
k8s_etcd_mem=gs_config.k8s_etcd_mem,
k8s_zookeeper_cpu=gs_config.k8s_zookeeper_cpu,
k8s_zookeeper_mem=gs_config.k8s_zookeeper_mem,
k8s_gie_graph_manager_cpu=gs_config.k8s_gie_graph_manager_cpu,
k8s_gie_graph_manager_mem=gs_config.k8s_gie_graph_manager_mem,
k8s_vineyard_cpu=gs_config.k8s_vineyard_cpu,
k8s_vineyard_mem=gs_config.k8s_vineyard_mem,
k8s_vineyard_shared_mem=gs_config.k8s_vineyard_shared_mem,
Expand Down Expand Up @@ -205,6 +211,22 @@ def __init__(

k8s_coordinator_mem (str, optional): Minimum number of memory request for coordinator pod. Defaults to '4Gi'.

k8s_etcd_cpu (float, optional): Minimum number of CPU cores request for etcd pod. Defaults to 0.5.

k8s_etcd_mem (str, optional): Minimum number of memory request for etcd pod. Defaults to '128Mi'.

k8s_zookeeper_cpu (float, optional):
Minimum number of CPU cores request for zookeeper container. Defaults to 0.5.

k8s_zookeeper_mem (str, optional):
Minimum number of memory request for zookeeper container. Defaults to '128Mi'.

k8s_gie_graph_manager_cpu (float, optional):
Minimum number of CPU cores request for graphmanager container. Defaults to 1.0.

k8s_gie_graph_manager_mem (str, optional):
Minimum number of memory request for graphmanager container. Defaults to '4Gi'.

k8s_volumes (dict, optional): A dict of k8s volume which represents a directory containing data, accessible to the
containers in a pod. Defaults to {}. Only 'hostPath' supported yet. For example, we can mount host path with:

Expand Down Expand Up @@ -283,6 +305,12 @@ def __init__(
"k8s_zookeeper_image",
"k8s_coordinator_cpu",
"k8s_coordinator_mem",
"k8s_etcd_cpu",
"k8s_etcd_mem",
"k8s_zookeeper_cpu",
"k8s_zookeeper_mem",
"k8s_gie_graph_manager_cpu",
"k8s_gie_graph_manager_mem",
"k8s_vineyard_cpu",
"k8s_vineyard_mem",
"k8s_vineyard_shared_mem",
Expand Down Expand Up @@ -643,6 +671,12 @@ def _connect(self):
vineyard_cpu=self._config_params["k8s_vineyard_cpu"],
vineyard_mem=self._config_params["k8s_vineyard_mem"],
vineyard_shared_mem=self._config_params["k8s_vineyard_shared_mem"],
etcd_cpu=self._config_params["k8s_etcd_cpu"],
etcd_mem=self._config_params["k8s_etcd_mem"],
zookeeper_cpu=self._config_params["k8s_zookeeper_cpu"],
zookeeper_mem=self._config_params["k8s_zookeeper_mem"],
gie_graph_manager_cpu=self._config_params["k8s_gie_graph_manager_cpu"],
gie_graph_manager_mem=self._config_params["k8s_gie_graph_manager_mem"],
engine_cpu=self._config_params["k8s_engine_cpu"],
engine_mem=self._config_params["k8s_engine_mem"],
coordinator_cpu=float(self._config_params["k8s_coordinator_cpu"]),
Expand Down Expand Up @@ -859,7 +893,10 @@ def gremlin(self, graph):
from graphscope.interactive.query import InteractiveQuery

response = self._grpc_client.create_interactive_engine(
graph.vineyard_id, graph.schema_path
object_id=graph.vineyard_id,
schema_path=graph.schema_path,
gremlin_server_cpu=gs_config.k8s_gie_gremlin_server_cpu,
gremlin_server_mem=gs_config.k8s_gie_gremlin_server_mem,
)
interactive_query = InteractiveQuery(
graphscope_session=self,
Expand Down
16 changes: 16 additions & 0 deletions python/graphscope/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ class GSConfig(object):
k8s_coordinator_cpu = 1.0
k8s_coordinator_mem = "4Gi"

# etcd resource configuration
k8s_etcd_cpu = 0.5
k8s_etcd_mem = "128Mi"

# zookeeper resource configuration
k8s_zookeeper_cpu = 0.5
k8s_zookeeper_mem = "128Mi"

# GIE graph manager resource configuration
k8s_gie_graph_manager_cpu = 1.0
k8s_gie_graph_manager_mem = "4Gi"

# GIE gremlin server resource configuration
k8s_gie_gremlin_server_cpu = 1.0
k8s_gie_gremlin_server_mem = "1Gi"

# vineyard resource configuration
k8s_vineyard_cpu = 0.5
k8s_vineyard_mem = "512Mi"
Expand Down
37 changes: 37 additions & 0 deletions python/graphscope/deploy/kubernetes/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ class KubernetesCluster(object):
image_pull_secrets: list of str, optional
A list of secret name used to pulling image. Defaults to None.

etcd_cpu: float
Minimum number of CPU cores request for etcd pod.

etcd_mem: str
Minimum number of memory request for etcd pod.

zookeeper_cpu: float
Minimum number of CPU cores request for zookeeper container.

zookeeper_mem: str:
Minimum number of memory request for zookeeper container.

gie_graph_manager_cpu: float
Minimum number of CPU cores request for graph manager container.

gie_graph_manager_mem: str
Minimum number of memory request for graph manager container.

vineyard_cpu: float
Minimum number of CPU cores request for vineyard container.

Expand Down Expand Up @@ -158,6 +176,12 @@ def __init__(
engine_mem=None,
coordinator_cpu=None,
coordinator_mem=None,
etcd_cpu=None,
etcd_mem=None,
zookeeper_cpu=None,
zookeeper_mem=None,
gie_graph_manager_cpu=None,
gie_graph_manager_mem=None,
volumes=None,
timeout_seconds=None,
waiting_for_delete=None,
Expand All @@ -184,6 +208,13 @@ def __init__(
elif not isinstance(self._image_pull_secrets, list):
self._image_pull_secrets = [self._image_pull_secrets]

self._etcd_cpu = etcd_cpu
self._etcd_mem = etcd_mem
self._zookeeper_cpu = zookeeper_cpu
self._zookeeper_mem = zookeeper_mem
self._gie_graph_manager_cpu = gie_graph_manager_cpu
self._gie_graph_manager_mem = gie_graph_manager_mem

self._vineyard_cpu = vineyard_cpu
self._vineyard_mem = vineyard_mem
self._vineyard_shared_mem = vineyard_shared_mem
Expand Down Expand Up @@ -422,6 +453,12 @@ def _create_coordinator(self):
coordinator_cpu=self._coordinator_cpu,
coordinator_mem=self._coordinator_mem,
coordinator_service_name=self._coordinator_service_name,
etcd_cpu=self._etcd_cpu,
etcd_mem=self._etcd_mem,
zookeeper_cpu=self._zookeeper_cpu,
zookeeper_mem=self._zookeeper_mem,
gie_graph_manager_cpu=self._gie_graph_manager_cpu,
gie_graph_manager_mem=self._gie_graph_manager_mem,
vineyard_cpu=self._vineyard_cpu,
vineyard_mem=self._vineyard_mem,
vineyard_shared_mem=self._vineyard_shared_mem,
Expand Down
Loading