Service type ClusterIP - Controller port forward through CLI (#431)
setting serviceType to ClusterIP as default for fission controller and corresponding changes in fission cli to be able to port-forward the controller pod.
This commit is contained in:
committed by
smruthi2187
parent
1428c64b4f
commit
b9a559af2f
@@ -17,6 +17,7 @@ FLUENTD_IMAGE=gcr.io/fission-ci/fluentd
|
||||
BUILDER_IMAGE=$REPO/builder
|
||||
TAG=test
|
||||
PRUNE_INTERVAL=1 # this variable controls the interval to run archivePruner. The unit is in minutes.
|
||||
ROUTER_SERVICE_TYPE=ClusterIP
|
||||
|
||||
dump_system_info
|
||||
|
||||
@@ -36,4 +37,4 @@ build_and_push_fluentd $FLUENTD_IMAGE:$TAG
|
||||
|
||||
build_fission_cli
|
||||
|
||||
install_and_test $IMAGE $TAG $FETCHER_IMAGE $TAG $FLUENTD_IMAGE $TAG $PRUNE_INTERVAL
|
||||
install_and_test $IMAGE $TAG $FETCHER_IMAGE $TAG $FLUENTD_IMAGE $TAG $PRUNE_INTERVAL $ROUTER_SERVICE_TYPE
|
||||
|
||||
+18
-54
@@ -163,11 +163,12 @@ helm_install_fission() {
|
||||
fluentdImage=$8
|
||||
fluentdImageTag=$9
|
||||
pruneInterval="${10}"
|
||||
routerServiceType=${11}
|
||||
|
||||
ns=f-$id
|
||||
fns=f-func-$id
|
||||
|
||||
helmVars=image=$image,imageTag=$imageTag,fetcherImage=$fetcherImage,fetcherImageTag=$fetcherImageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=Always,analytics=false,logger.fluentdImage=$fluentdImage,logger.fluentdImageTag=$fluentdImageTag,pruneInterval=$pruneInterval
|
||||
helmVars=image=$image,imageTag=$imageTag,fetcherImage=$fetcherImage,fetcherImageTag=$fetcherImageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=Always,analytics=false,logger.fluentdImage=$fluentdImage,logger.fluentdImageTag=$fluentdImageTag,pruneInterval=$pruneInterval,routerServiceType=$routerServiceType
|
||||
|
||||
timeout 30 bash -c "helm_setup"
|
||||
|
||||
@@ -175,7 +176,7 @@ helm_install_fission() {
|
||||
helm list -q|xargs -I@ bash -c "helm_uninstall_fission @"
|
||||
|
||||
# deleting ns does take a while after command is issued
|
||||
while `kubectl get ns| grep fission-builder`
|
||||
while `kubectl get ns| grep "fission-builder"`
|
||||
do
|
||||
sleep 5
|
||||
done
|
||||
@@ -192,45 +193,6 @@ helm_install_fission() {
|
||||
helm list
|
||||
}
|
||||
|
||||
wait_for_service() {
|
||||
id=$1
|
||||
svc=$2
|
||||
health_endpoint=$3
|
||||
|
||||
ns=f-$id
|
||||
retry=0
|
||||
max_retries=5
|
||||
while true
|
||||
do
|
||||
retry=$((retry+1))
|
||||
if ((retry == max_retries)); then
|
||||
echo "Waiting for $svc to be routable exceeded max retries. Quitting.."
|
||||
exit 1
|
||||
fi
|
||||
ip=$(kubectl -n $ns get svc $svc -o jsonpath='{...ip}')
|
||||
if [ -z $ip ]; then
|
||||
continue
|
||||
fi
|
||||
http_status=`curl -sw "%{http_code}" "http://$ip/$health_endpoint"`
|
||||
echo "http_status for svc $svc : $http_status"
|
||||
if [ "$http_status" -ne "200" ]; then
|
||||
echo "Service $svc returned response other than 200. waiting for 200 after backing off for 1 second"
|
||||
sleep 1
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
wait_for_services() {
|
||||
id=$1
|
||||
|
||||
echo "\n--- wait for controller and router services to be routable ---"
|
||||
wait_for_service $id controller "healthz"
|
||||
wait_for_service $id router "router-healthz"
|
||||
echo "\n--- end wait for controller and router services to be routable ---"
|
||||
}
|
||||
|
||||
dump_kubernetes_events() {
|
||||
id=$1
|
||||
ns=f-$id
|
||||
@@ -269,14 +231,17 @@ helm_uninstall_fission() {(set +e
|
||||
)}
|
||||
export -f helm_uninstall_fission
|
||||
|
||||
set_environment() {
|
||||
port_forward_services() {
|
||||
id=$1
|
||||
ns=f-$id
|
||||
port=8888
|
||||
|
||||
export FISSION_URL=http://$(kubectl -n $ns get svc controller -o jsonpath='{...ip}')
|
||||
export FISSION_ROUTER=$(kubectl -n $ns get svc router -o jsonpath='{...ip}')
|
||||
kubectl get pods -l svc="router" -o name --namespace $ns | \
|
||||
sed 's/^.*\///' | \
|
||||
xargs -I{} kubectl port-forward {} $port:$port -n $ns &
|
||||
|
||||
# set path to include cli
|
||||
export FISSION_ROUTER="127.0.0.1:"
|
||||
FISSION_ROUTER+="$port"
|
||||
export PATH=$ROOT/fission:$PATH
|
||||
}
|
||||
|
||||
@@ -296,7 +261,6 @@ dump_builder_pod_logs() {
|
||||
done
|
||||
echo "--- end builder pod logs $p ---"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
dump_function_pod_logs() {
|
||||
@@ -457,6 +421,7 @@ install_and_test() {
|
||||
fluentdImage=$5
|
||||
fluentdImageTag=$6
|
||||
pruneInterval=$7
|
||||
routerServiceType=$8
|
||||
|
||||
controllerPort=31234
|
||||
routerPort=31235
|
||||
@@ -465,17 +430,16 @@ install_and_test() {
|
||||
|
||||
id=$(generate_test_id)
|
||||
trap "helm_uninstall_fission $id" EXIT
|
||||
if ! helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort $fluentdImage $fluentdImageTag $pruneInterval
|
||||
then
|
||||
helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort $fluentdImage $fluentdImageTag $pruneInterval $routerServiceType
|
||||
helm status $id | grep STATUS | grep -i deployed
|
||||
if [ $? -ne 0 ]; then
|
||||
describe_all_pods $id
|
||||
dump_kubernetes_events $id
|
||||
dump_tiller_logs
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wait_for_services $id
|
||||
set_environment $id
|
||||
|
||||
port_forward_services $id $routerPort
|
||||
run_all_tests $id
|
||||
|
||||
dump_logs $id
|
||||
@@ -486,7 +450,7 @@ install_and_test() {
|
||||
then
|
||||
# describe each pod in fission ns and function namespace
|
||||
describe_all_pods $id
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -496,4 +460,4 @@ install_and_test() {
|
||||
# echo "Usage: test.sh [image] [imageTag]"
|
||||
# exit 1
|
||||
# fi
|
||||
# install_and_test $1 $2
|
||||
# install_and_test $1 $2
|
||||
@@ -6,6 +6,7 @@ pkg=""
|
||||
http_status=""
|
||||
url=""
|
||||
|
||||
|
||||
cleanup() {
|
||||
if [ -e "test-deploy-pkg.zip" ]; then
|
||||
rm -rf test-deploy-pkg.zip test_dir
|
||||
@@ -13,6 +14,7 @@ cleanup() {
|
||||
if [ -e "/tmp/file" ]; then
|
||||
rm -rf /tmp/file
|
||||
fi
|
||||
ps aux | grep -i "kubectl port-forward controller" | awk {'print $2'} | xargs kill -9 || true
|
||||
}
|
||||
|
||||
create_archive() {
|
||||
@@ -38,8 +40,21 @@ get_archive_url_from_package() {
|
||||
url=`kubectl get package $1 -ojsonpath='{.spec.deployment.url}'`
|
||||
}
|
||||
|
||||
port_forward_controller_pod() {
|
||||
log "Trying to port forward controller pod"
|
||||
controller_pod=`kubectl get pods -n $FISSION_NAMESPACE| grep controller| tr -s " "| cut -d" " -f1`
|
||||
controller_port=`kubectl get svc controller -n $FISSION_NAMESPACE -ojsonpath='{.spec.ports[0].targetPort}'`
|
||||
log "controller pod: $controller_pod, controller port : $controller_port"
|
||||
kubectl port-forward $controller_pod 9999:8888 -n $FISSION_NAMESPACE &
|
||||
sleep 4
|
||||
}
|
||||
|
||||
get_archive_from_storage() {
|
||||
http_status=`curl -sw "%{http_code}" $1 -o /tmp/file`
|
||||
storage_service_url=$1
|
||||
controller_proxy_url=`echo $storage_service_url | sed -e "s/storagesvc.$FISSION_NAMESPACE/127.0.0.1:9999\/proxy\/storage/"`
|
||||
log "controller_proxy_url=$controller_proxy_url"
|
||||
http_status=`curl -sw "%{http_code}" $controller_proxy_url -o /tmp/file`
|
||||
echo "http_status: $http_status"
|
||||
}
|
||||
|
||||
#1. declare trap to cleanup for EXIT
|
||||
@@ -75,6 +90,9 @@ main() {
|
||||
delete_package $pkg_2
|
||||
log "deleted packages : $pkg_1 $pkg_2"
|
||||
|
||||
# port forward controller pod
|
||||
port_forward_controller_pod
|
||||
|
||||
# curl on the archive url
|
||||
get_archive_from_storage $url_1
|
||||
log "http_status for $url_1 : $http_status"
|
||||
@@ -111,6 +129,7 @@ main() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
log "Test archive pruner PASSED"
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,5 @@ set -euo pipefail
|
||||
# have the right environment, that's all.
|
||||
|
||||
log "Test test, please ignore."
|
||||
|
||||
log $FISSION_URL
|
||||
log $FISSION_ROUTER
|
||||
which fission
|
||||
|
||||
Reference in New Issue
Block a user