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

Extend gremlin pod expose to load-balancer #45

Merged
merged 1 commit into from
Dec 25, 2020
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
1 change: 1 addition & 0 deletions coordinator/gscoordinator/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ def _create_interactive_engine_service(self):
"GREMLIN_IMAGE": self._gie_graph_manager_image,
"ENGINE_NAMESPACE": self._namespace,
"COORDINATOR_IMAGE": self._gie_graph_manager_image,
"GREMLIN_EXPOSE": self._service_type,
}
graph_manager_builder.add_simple_envs(envs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,31 @@ function _setup_config {
sh -c "$update_cmd"
parallel_run "$update_cmd" "$pod_hosts" $ENGINE_CONTAINER
}
function _random_generator {
min=$1
range=$2
_port=$(( ((RANDOM<<15)|RANDOM) % $range + $min ))
echo ${_port}
}
function _expose_gremlin_server {
port=$1
gremlin_pod=`kubectl get pods -l "graph=pod-${object_id}" | grep -v NAME | awk '{print $1}'`
kubectl expose pod ${gremlin_pod} --name=gremlin-${object_id} --port=${port} \
--target-port=${port} --type=NodePort 1>/dev/null 2>&1
[ $? -eq 0 ] || exit 1
node_port=`kubectl describe services gremlin-${object_id} | grep "NodePort" | grep "TCP" | tr -cd "[0-9]"`
[ $? -eq 0 ] || exit 1
# EXTERNAL_IP=`kubectl describe pods -l "app=manager" | grep "Node:" | head -1 | awk -F '[ /]+' '{print $3}'`
EXTERNAL_IP=`kubectl describe pods pod-${object_id} | grep "Node:" | head -1 | awk -F '[ /]+' '{print $3}'`
echo "FRONTEND_PORT:$EXTERNAL_IP:$node_port"
if [ "$GREMLIN_EXPOSE" = "LoadBalancer" ]; then
# range [50001, 53000)
external_port=$( _random_generator 50001 3000 )
kubectl expose pod ${gremlin_pod} --name=gremlin-${object_id} --port=${external_port} \
--target-port=${port} --type=LoadBalancer 1>/dev/null 2>&1
[ $? -eq 0 ] || exit 1
EXTERNAL_IP=`kubectl describe service gremlin-${object_id} | grep "LoadBalancer Ingress" | awk -F'[ :]+' '{print $3}'`
else
kubectl expose pod ${gremlin_pod} --name=gremlin-${object_id} --port=${port} \
--target-port=${port} --type=NodePort 1>/dev/null 2>&1
[ $? -eq 0 ] || exit 1
external_port=`kubectl describe services gremlin-${object_id} | grep "NodePort" | grep "TCP" | tr -cd "[0-9]"`
[ $? -eq 0 ] || exit 1
EXTERNAL_IP=`kubectl describe pods pod-${object_id} | grep "Node:" | head -1 | awk -F '[ /]+' '{print $3}'`
fi
echo "FRONTEND_PORT:$EXTERNAL_IP:$external_port"
}
export object_id=$1
export schema_path=$2
Expand Down