Skip to content

Commit

Permalink
support cypher query
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Wang <[email protected]>
  • Loading branch information
doudoubobo committed Oct 25, 2024
1 parent bd06c54 commit b8c27bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions charts/gart/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ data:
GART_CONTROLLER_SERVER: {{ $controller_service | quote }}
ETCD_SERVICE: {{ $etcd_service | quote }}
GIE_GREMLIN_PORT: {{ .Values.gie_frontend.gremlinPort | quote }}
GIE_CYPHER_PORT: {{ .Values.gie_frontend.cypherPort | quote }}
GIE_EXECUTOR_RPC_PORT: {{ .Values.gie_executor.GAIA_RPC_PORT | quote }}
GIE_EXECUTOR_ENGINE_PORT: {{ .Values.gie_executor.ENGINE_PORT | quote }}
NAME_SPACE: {{ .Release.Namespace | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/gart/templates/converter/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ spec:
- protocol: TCP
port: {{ .Values.coordinator.port }}
targetPort: {{ .Values.coordinator.containerPort }}
name: coordinator-port
8 changes: 6 additions & 2 deletions coordinator/flex/server/controllers/service_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ def get_service_status_by_id(graph_id): # noqa: E501
result_dict = {}
k8s_namespace = os.getenv('NAME_SPACE', 'default')
gremlin_service_name = os.getenv('GREMLIN_SERVICE_NAME', 'gremlin-service')
gremlin_service_port = os.getenv('GIE_GREMLIN_PORT', '8182')
gremlin_service_port = os.getenv('GIE_GREMLIN_PORT', '8182')
cypher_service_port = os.getenv('GIE_CYPHER_PORT', '7687')
gremlin_service_ip = get_external_ip_of_a_service(gremlin_service_name, k8s_namespace)
result_dict["graph_id"] = graph_id
result_dict["status"] = "Running"
result_dict["sdk_endpoints"] = {}
result_dict["sdk_endpoints"]["gremlin"] = f"ws://{gremlin_service_ip}:{gremlin_service_port}/gremlin"
result_dict["sdk_endpoints"]["cypher"] = f"neo4j://{gremlin_service_ip}:{cypher_service_port}"
return (ServiceStatus.from_dict(result_dict), 200)


Expand All @@ -66,7 +68,8 @@ def list_service_status(): # noqa: E501
result_dict = {}
k8s_namespace = os.getenv('NAME_SPACE', 'default')
gremlin_service_name = os.getenv('GREMLIN_SERVICE_NAME', 'gremlin-service')
gremlin_service_port = os.getenv('GIE_GREMLIN_PORT', '8182')
gremlin_service_port = os.getenv('GIE_GREMLIN_PORT', '8182')
cypher_service_port = os.getenv('GIE_CYPHER_PORT', '7687')
gremlin_service_ip = get_external_ip_of_a_service(gremlin_service_name, k8s_namespace)
try:
with open("/tmp/graph_id.txt", "r") as f:
Expand All @@ -77,6 +80,7 @@ def list_service_status(): # noqa: E501
result_dict["status"] = "Running"
result_dict["sdk_endpoints"] = {}
result_dict["sdk_endpoints"]["gremlin"] = f"ws://{gremlin_service_ip}:{gremlin_service_port}/gremlin"
result_dict["sdk_endpoints"]["cypher"] = f"neo4j://{gremlin_service_ip}:{cypher_service_port}"
return ([ServiceStatus.from_dict(result_dict)], 200)


Expand Down
12 changes: 7 additions & 5 deletions scripts/update_ip_tables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Function to get the node port for a service
get_node_port() {
kubectl get service "$1" -o=jsonpath='{.spec.ports[0].nodePort}' -n "$2"
kubectl get service "$1" -o=jsonpath="{.spec.ports[?(@.name==\"$2\")].nodePort}" -n "$3"
}

# Function to get the Kubernetes API server IP
Expand All @@ -23,16 +23,18 @@ update_iptables() {
SOURCE_PORT="$3"
NAME_SPACE="$4"
K8S_API_IP="$5"
SERVICE_PORT_NAME="$6"

echo "Updating iptables rules for $SERVICE_NAME (Source IP: $SOURCE_IP, Port: $SOURCE_PORT)"

NODE_PORT=$(get_node_port "$SERVICE_NAME" "$NAME_SPACE")
NODE_PORT=$(get_node_port "$SERVICE_NAME" "$SERVICE_PORT_NAME" "$NAME_SPACE")

if [ -z "$NODE_PORT" ]; then
echo "Error: Could not get node port for service $SERVICE_NAME"
return 1
fi

echo "socat TCP-LISTEN:${SOURCE_PORT},bind=${SOURCE_IP},fork TCP:${K8S_API_IP}:${NODE_PORT}"
sudo socat TCP-LISTEN:${SOURCE_PORT},bind=${SOURCE_IP},fork TCP:${K8S_API_IP}:${NODE_PORT} &

echo "Updated iptables rules for $SERVICE_NAME (Node Port: $NODE_PORT)"
Expand All @@ -51,15 +53,15 @@ echo "Kubernetes API server IP: $K8S_API_IP"
cleanup_iptables

# Update rules for each service
if ! update_iptables gart-release-coordinator-service 0.0.0.0 18080 gart "$K8S_API_IP"; then
if ! update_iptables gart-release-coordinator-service 0.0.0.0 18080 gart "$K8S_API_IP" coordinator-port; then
echo "Failed to update iptables for gart-release-coordinator-service"
fi

if ! update_iptables gart-release-gie-frontend-service 0.0.0.0 8182 gart "$K8S_API_IP"; then
if ! update_iptables gart-release-gie-frontend-service 0.0.0.0 8182 gart "$K8S_API_IP" gremlin-port; then
echo "Failed to update iptables for gart-release-gie-frontend-service gremlin"
fi

if ! update_iptables gart-release-gie-frontend-service 0.0.0.0 7687 gart "$K8S_API_IP"; then
if ! update_iptables gart-release-gie-frontend-service 0.0.0.0 7687 gart "$K8S_API_IP" cypher-port; then
echo "Failed to update iptables for gart-release-gie-frontend-service cypher"
fi

Expand Down

0 comments on commit b8c27bd

Please sign in to comment.