<p>I'm trying to deploy a very basic Sklearn model using Kfserving, here is the yaml file:</p>
<pre><code>apiVersion: &quot;serving.kubeflow.org/v1alpha2&quot;
kind: &quot;InferenceService&quot;
metadata:
  name: &quot;sklearn-iris&quot;
spec:
  default:
    predictor:
      sklearn:
        storageUri: file://./storage_dir
</code></pre>
<p>Note that since our corporate environment doesn't have access to Google Cloud Storage, for now I just use one of my local folders as the <code>storageUri</code>, and I have the <code>model.joblib</code> stored in the folder.</p>
<p>After I deploy it with <code>kubectl apply -f sklearn.yaml -n kfserving-test</code>, I got the following error when inspecting <code> kubectl describe  revision sklearn-iris-predictor-default-fj5qt -n kfserving-test</code>:</p>
<pre><code>Status:
  Conditions:
    Last Transition Time:  2020-12-16T22:51:38Z
    Message:               The target is not receiving traffic.
    Reason:                NoTraffic
    Severity:              Info
    Status:                False
    Type:                  Active
    Last Transition Time:  2020-12-16T22:51:37Z
    Message:               Container failed with: [I 201216 22:50:07 storage:35] Copying contents of /mnt/models to local
Traceback (most recent call last):
  File &quot;/usr/local/lib/python3.7/runpy.py&quot;, line 193, in _run_module_as_main
    &quot;__main__&quot;, mod_spec)
  File &quot;/usr/local/lib/python3.7/runpy.py&quot;, line 85, in _run_code
    exec(code, run_globals)
  File &quot;/sklearnserver/sklearnserver/__main__.py&quot;, line 33, in &lt;module&gt;
    model.load()
  File &quot;/sklearnserver/sklearnserver/model.py&quot;, line 36, in load
    model_file = next(path for path in paths if os.path.exists(path))
StopIteration

    Reason:                ExitCode1
    Status:                False
    Type:                  ContainerHealthy
    Last Transition Time:  2020-12-16T22:51:38Z
    Message:               Initial scale was never achieved
    Reason:                ProgressDeadlineExceeded
    Status:                False
    Type:                  Ready
    Last Transition Time:  2020-12-16T22:51:38Z
    Message:               Initial scale was never achieved
    Reason:                ProgressDeadlineExceeded
    Status:                False
    Type:                  ResourcesAvailable
  Container Statuses:
    Image Digest:       gcr.docker.prod.walmart.com/kfserving/sklearnserver@sha256:d2553d3f2a6ba7b50736028e6dbdfb35e90ca40ee7aa5cbe0e0b66fec1695f16
    Name:               kfserving-container
  Image Digest:         gcr.docker.prod.walmart.com/kfserving/sklearnserver@sha256:d2553d3f2a6ba7b50736028e6dbdfb35e90ca40ee7aa5cbe0e0b66fec1695f16
  Log URL:              http://localhost:8001/api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy/app/kibana#/discover?_a=(query:(match:(kubernetes.labels.knative-dev%2FrevisionUID:(query:'e6fee737-b9b8-4091-96a5-660dbf4082f8',type:phrase))))
  Observed Generation:  1
  Service Name:         sklearn-iris-predictor-default-fj5qt
Events:
  Type     Reason         Age    From                 Message
  ----     ------         ----   ----                 -------
  Warning  InternalError  2m16s  revision-controller  failed to update deployment &quot;sklearn-iris-predictor-default-fj5qt-deployment&quot;: Operation cannot be fulfilled on deployments.apps &quot;sklearn-iris-predictor-default-fj5qt-deployment&quot;: the object has been modified; please apply your changes to the latest version and try again
</code></pre>
<p>The exception looks like it failed to load/transfer the model files, and I'm wondering I did something wrong with the <code>storageUri</code> argument. It is supposed to be the relative path of the model file, right? (Reference: <a href="https://github.com/kubeflow/kfserving/blob/master/python/kfserving/docs/V1alpha2SKLearnSpec.md" rel="nofollow noreferrer">https://github.com/kubeflow/kfserving/blob/master/python/kfserving/docs/V1alpha2SKLearnSpec.md</a>)</p>

snowneji
<p>KFServing is injecting a second container in the pod of the predictor, SKLearn in your case, which is called <code>storage_initializer</code>. Its role is to download and copy of the model file from the <code>storageUri</code> to a location in the pod to offload the predictor from such a task.</p>
<p>Using the <code>file://</code> in the <code>storageUri</code> can be comfortable for tests when building KFServing, but it would require the pod to have the file already mounted locally.</p>
<p>If you don't have access to a cloud-based storage like <code>gs://</code> and <code>s3://</code>, you can use one of the alternative solutions like <code>uri://</code> or <code>pvc://</code>, serving the model file from your local kubernetes cluster. You can find <a href="https://github.com/kubeflow/kfserving/tree/master/docs/samples/storage" rel="nofollow noreferrer">examples here</a>.</p>
