<p>I am working on <a href="https://medium.com/analytics-vidhya/deploy-your-first-deep-learning-model-on-kubernetes-with-python-keras-flask-and-docker-575dc07d9e76" rel="nofollow noreferrer">this</a> tutorial and trying to deploy a deep learning model on the Google Cloud Engine.
I am able to containerize successfully the model which is wrapped with the flask framework. However, when I want to connect the container with Kubernetes, I am getting an error.</p>
<pre><code>$ kubectl run keras-app --image=stamatelou/keras-app --port 5000
pod/keras-app created

$ kubectl get pods
NAME        READY   STATUS              RESTARTS   AGE
keras-app   0/1     ContainerCreating   0          20s

$ kubectl get pods
NAME        READY   STATUS    RESTARTS   AGE
keras-app   1/1     Running   0          98s
</code></pre>
<p>Here it seems that the app is created and running as expected but then when i run the following command, I am receiving an error.</p>
<pre><code>$ kubectl expose deployment keras-app --type=LoadBalancer --port 80 --target-port 5000
Error from server (NotFound): deployments.extensions &quot;keras-app&quot; not found
</code></pre>
<p>Here are the logs of the container &quot;keras-app&quot;</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>$ kubectl logs keras-app
2020-07-03 06:56:10.730502: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file:N
o such file or directory
2020-07-03 06:56:10.730899: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: UNKNOWN ERROR (303)
2020-07-03 06:56:10.731013: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (keras-app): /proc/driver/nvidia/version does note
xist
2020-07-03 06:56:10.731416: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-07-03 06:56:10.740235: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2300000000 Hz
2020-07-03 06:56:10.740653: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fb760000b20 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-03 06:56:10.740769: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
* Loading Keras model and Flask starting server...please wait until server has fully started
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet50_weights_tf_dim_ordering_tf_kernels.h5
102973440/102967424 [==============================] - 1s 0us/step
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)</code></pre>
</div>
</div>
</p>

Elena Stamatelou
<p>To deploy follow the below command</p>
<pre><code># kubectl create deployment keras-app --image=stamatelou/keras-app
deployment.apps/keras-app created

# kubectl get deploy
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
keras-app   1/1     1            1           25s

To access the pod 
kubectl expose deployment keras-app --port=80 --target-port=5000 --type=NodePort

OR

kubectl expose deployment keras-app --port=80 --target-port=5000 --type=LoadBalancer
</code></pre>
