diff --git a/charts/gart/templates/configmap.yaml b/charts/gart/templates/configmap.yaml index 7fc30ca..4826604 100644 --- a/charts/gart/templates/configmap.yaml +++ b/charts/gart/templates/configmap.yaml @@ -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 }} diff --git a/charts/gart/templates/converter/svc.yaml b/charts/gart/templates/converter/svc.yaml index 284526e..88981b7 100644 --- a/charts/gart/templates/converter/svc.yaml +++ b/charts/gart/templates/converter/svc.yaml @@ -30,3 +30,4 @@ spec: - protocol: TCP port: {{ .Values.coordinator.port }} targetPort: {{ .Values.coordinator.containerPort }} + name: coordinator-port diff --git a/coordinator/flex/server/controllers/service_controller.py b/coordinator/flex/server/controllers/service_controller.py index 16e38e2..2900744 100644 --- a/coordinator/flex/server/controllers/service_controller.py +++ b/coordinator/flex/server/controllers/service_controller.py @@ -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) @@ -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: @@ -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) diff --git a/scripts/update_ip_tables.sh b/scripts/update_ip_tables.sh index 808df45..fc9a5ea 100755 --- a/scripts/update_ip_tables.sh +++ b/scripts/update_ip_tables.sh @@ -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 @@ -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)" @@ -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