Kubernetes has several s to check if your app is able to handle connections and in return if Kubernetes wants to kill you app (scale down, or end of life for your preemptible/spot-instance node,…) it will signal your app to wrap up and shutdown. mechanism If your server does not handle shutdowns gracefully or it is not adjustable in ways you need to make it work in k8s (shutdown delay, …) , notice you can always wrap it with bash. Assume a deployment like apiVersion: extensions/v1beta1 kind: Deployment ... containers: - args: - /bin/bash - -c - tensorflow_serving image: tensorflow/serving:1 name: tfserving readinessProbe: httpGet: path: /ready port: 8080 ... You can use your bash-wrapper and run the server there. Your bash script can handle the termination signal and do what you want. In this case you just need to instruct Kubernetes to use a file for readinessProbe or livenessProbe. apiVersion: extensions/v1beta1 kind: Deployment ... containers: - args: - /bin/bash - -c - /init.sh tensorflow_serving image: tensorflow/serving:1 name: tfserving readinessProbe: exec: command: - cat - /tmp/ready ... And a sample of an can look like: init.sh -e COMMAND= INIT_NAME= HEALTH_PORT= HEALTH_PATH= HEALTH_PERIOD_SECONDS= HEALTHY_INDICATOR= APP_STOP_DELAY= SIGNAL_RECIEVED_INDICATOR=$(mktemp --dry-run /tmp/ -teminating.XXXXXX) () { touch rm -f } () { ls /tmp _terminating sleep -9 } () { [ ! -f ] ! curl --fail --silent http://localhost: / > /dev/null rm -f touch rm -f sleep } _term SIGTERM & child=$! _health_check & _terminating #!/bin/bash set " " $@ ${INIT_NAME:-myapp} ${HEALTH_PORT:-8080} ${HEALTH_PATH:-ping} ${HEALTH_PERIOD_SECONDS:-1} ${HEALTHY_INDICATOR:-/tmp/ready} ${APP_STOP_DELAY:-5} $INIT_NAME _terminating ${SIGNAL_RECIEVED_INDICATOR} ${HEALTHY_INDICATOR} _term echo "Caught SIGTERM signal!" ${APP_STOP_DELAY} echo "stopping the child " ${child} kill ${child} _health_check while ${SIGNAL_RECIEVED_INDICATOR} do # either you check the port (nc version) or you are checking the http call (curl version) # if ! nc -vz locahost ${HEALTH_PORT} >/dev/null 2>&1 if ${HEALTH_PORT} ${HEALTH_PATH} then ${HEALTHY_INDICATOR} else ${HEALTHY_INDICATOR} fi ${HEALTH_PERIOD_SECONDS} done trap ${COMMAND} wait " " ${child} This is modifiable for your needs.