############### 14 f I. test KFServing ###################### 
# sanity check the KFServing deployment
# get the cluster credential
gcloud container clusters get-credentials $GKE_CLUSTER_NAME 

# Git clone the repo (on local env)
# we will use the repo when we will santiy check the KFServing deployment
mkdir $HOME/Downloads/kfs
cd $HOME/Downloads/kfs
git clone https://github.com/kubeflow/kfserving.git .

echo $KFSERVING_NAMESPACE
echo $KFSERVING_SAMPLE
echo $ISTIO_SERVICE
echo $ISTIO_NAMESPACE

export SERVICE_HOSTNAME=$(kubectl get inferenceservice $KFSERVING_SAMPLE \
  -n $KFSERVING_NAMESPACE -o jsonpath='{.status.default.predictor.host}')
echo $SERVICE_HOSTNAME 
export INGRESS_HOST=$(kubectl get svc -l istio=$ISTIO_SERVICE \
  -n $ISTIO_NAMESPACE -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}')
echo $INGRESS_HOST
 
# check if the flowers-sample (a TensorFlow model) model is ready to accept request
curl -H "Host: ${SERVICE_HOSTNAME}" "http://$INGRESS_HOST/v1/models/$KFSERVING_SAMPLE"
 
# post data to the endpoint - use the sample file from the KFServing git repo 
# from the kfserving git repo for flowers-sample (a TensorFlow model)
curl -H "Host: ${SERVICE_HOSTNAME}" "http://$INGRESS_HOST/v1/models/$KFSERVING_SAMPLE:predict" -d @$HOME/Downloads/kfs/docs/samples/tensorflow/input.json
# end of sanity check of the KFServing