Skip to content

Support model download via INIT containers #4307

Closed

Description

@rakelkar

In what area(s)?

/area API

/area autoscale
/area build
/area monitoring
/area networking
/area test-and-release

Describe the feature

KFServing would like to enable data scientists to refer to ML models in a consistent way across ML Inference Hosts (like TFServing and TensorRT) without requiring the build of a derived container.

See discussion and proposed design doc at: kserve/kserve#148

This requires KNative support for:

  1. An INIT container to download the model before the inference container starts
  2. The ability to mount a volume from the INIT container to the inference container

We believe that (2) above is a clean extension and does not violate the immutability principle laid out in issues like #2025

Activity

  1. added
    kind/feature
    on Jun 9, 2019
  2. rakelkar commented on Jun 9, 2019

    @rakelkar
    Author

    Not sure if area label is correct

  3. rakelkar commented on Jun 9, 2019

    @rakelkar
    Author
  4. added this to the Ice Box milestone on Jun 25, 2019
  5. knative-housekeeping-robot commented on Dec 23, 2019

    @knative-housekeeping-robot

    Issues go stale after 90 days of inactivity.
    Mark the issue as fresh by adding the comment /remove-lifecycle stale.
    Stale issues rot after an additional 30 days of inactivity and eventually close.
    If this issue is safe to close now please do so by adding the comment /close.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /lifecycle stale

  6. added
    lifecycle/stale
    on Dec 23, 2019
  7. mattmoor commented on Dec 23, 2019

    @mattmoor
    Contributor

    /remove-lifecycle stale

    This also needs a place to put the model, so some volume work would be needed.

    cc @savitaashture @markusthoemmes who are looking at multi-container, as I've mentioned these things as related work a few times.

  8. removed
    lifecycle/stale
    on Dec 23, 2019
  9. knative-housekeeping-robot commented on Mar 23, 2020

    @knative-housekeeping-robot

    Issues go stale after 90 days of inactivity.
    Mark the issue as fresh by adding the comment /remove-lifecycle stale.
    Stale issues rot after an additional 30 days of inactivity and eventually close.
    If this issue is safe to close now please do so by adding the comment /close.

    Send feedback to Knative Productivity Slack channel or file an issue in knative/test-infra.

    /lifecycle stale

  10. added
    lifecycle/stale
    on Mar 23, 2020
  11. mattmoor commented on Mar 23, 2020

    @mattmoor
    Contributor

    /remove-lifecycle stale

  12. removed
    lifecycle/stale
    on Mar 23, 2020
  13. VonRehberg commented on Apr 2, 2020

    @VonRehberg

    Would be good to have PVCs or any similar possibility to access models/files. Building derived containers seems very cumbersome.
    Any feedback if you're working on it?

  14. mattmoor commented on Apr 2, 2020

    @mattmoor
    Contributor

    The most related thing in-flight is support for multiple spec.template.spec.containers, but I see spec.template.spec.initContainers, and expanded volume support as related (e.g. as a medium for passing data between containers). (cc @savitaashture @markusthoemmes )

    I think at this point it is mostly a question of bandwidth. I know @JRBANCEL mentioned this on our call Weds, so maybe he is interested in tackling volumes next?

    cc @dprotaso

  15. JRBANCEL commented on Apr 2, 2020

    @JRBANCEL
    Contributor

    I know @JRBANCEL mentioned this on our call Weds, so maybe he is interested in tackling volumes next?

    Definitely, as this has been asked quite a bit already. Let's finish the Downward API work first though🚀 .

  16. 18 remaining items

  17. added
    lifecycle/frozen
    on Feb 11, 2021
  18. evankanderson commented on Mar 22, 2021

    @evankanderson
    Member

    /area API

    @dprotaso -- It looks like multi-container did not enable init containers:

    out.InitContainers = nil

    Thought on priority for this request?

    /triage needs-user-input

  19. added
    area/API
    triage/needs-user-input
    on Mar 22, 2021
  20. RafalSkolasinski commented on May 12, 2021

    @RafalSkolasinski

    We’d like to chip in here - this is one of the features that we'd love to see in knative at some point.

    In the context of ML inference servers having support for init containers would make a lot of sense. Following comment of @evankanderson from stackoverflow.com

    Knative deliberately excludes init containers right now because they can induce large (unbounded) amounts of additional latency during cold-start.

    If we assume that the workaround is to do the init container’s job on the main container startup (download the model) rather than in the init containers this does not change anything - it is the same download that needs to occur before microservice can serve inference requests.

    If kservices would support init containers, however, then after kservice scaled to zero and back to positive number of replicas no download would be required as the same PVC with already downloaded model would be mounted saving us from unnecessary download.

    Another argument is that separating this logic out of the main container allows to easier use of specialised microservices.

  21. markusthoemmes commented on May 12, 2021

    @markusthoemmes
    Contributor

    I agree with the above. init containers don't violate the "statelessness" of a service and I guess the tradeoff with cold start latency is quite obvious. +1 on supporting it.

  22. lisamburns commented on Jun 3, 2021

    @lisamburns

    Another use case we could see here is to enable debugging via dev orchestrators like Skaffold. Skaffold automatically configures debugging for you by transforming a k8s manifest to add an initContainer with debug dependencies, volume mounts the debug dependencies onto the main container, and also modifies the start command and adds a debug port. Since knative does not support volume mounts or initContainers, this doesn't work, but if this feature were enabled, it would be another use case in addition to the one mentioned above.

    This is also another use case for supporting multiple ports (see other issue): #8471
    Here's a related issue that folks opened on the skaffold repo which suggests other folks may be interested in skaffold debug + knative: GoogleContainerTools/skaffold#4702

  23. dprotaso commented on Jun 14, 2021

    @dprotaso
    Member

    1. For the model downloading use case - re-posting my comments from: #4417 (comment)

    I'm not really convinced downloading models (via an initContainer) into an emptyDir really makes a lot of sense. It seems really inefficient and you're not benefiting from any caching. Any additional pods that are scaled up (even on the same node) will always download the model? Maybe the better pattern is to bundle them in an OCI image and access them as a sidecar. Then subsequent starts would be much faster since these model images will be cached by Kubernetes

    1.1 Downloading models into a PVC

    @RafalSkolasinski Is it possible to setup a PVC prior to creating the Knative Service? Then you'd declare the PVC read-only. If not why?

    2. For sourcing/injecting secrets on startup

    This seems like a practical use case of initContainers - your workloads need a secret/identity on demand. There's external tooling to help fetch said secret.

    3. Debugging Containers

    @lisamburns curious if skaffold can support debugging via sidecars - since we do support multiple containers. I'd imagine this would then enable debugging in the future using k8s ephemeral containers

  24. emaildanwilson commented on Jun 22, 2021

    @emaildanwilson
    Contributor

    I also have a use case for this which is binding config/secrets at runtime that could ideally be handled with an init container and a shared emptyDir volume. I can add the feature flags for these if this is agreed upon. I've done a few times for other settings.

  25. lisamburns commented on Jun 29, 2021

    @lisamburns

    @dprotaso I'm a skaffold user, not a contributor, but that's a good question. I'm not sure if the below discussion is off-topic for this github issue. Tldr I think there is still a valid use case for volume mounts/initContainers for the debug use case.

    I think what you're suggesting is a different approach but let me attempt to clarify.

    1. Skaffold approach (requires volume mounts and initContainers)
      They are rewriting the start command to be "dlv exec /app", and the web container gets delv because an initContainer mounts it into a shared dir (i.e emptyDir).

    2. Your suggestion? - ephemeral containers and sidecars instead of skaffold
      You could debug a knative service with an ephemeral container sidecar, without the need for knative to support initContainers or volume mounts. The sidecar could run "dlv attach pid-of-server", assuming sidecar has delv installed and process namespace sharing. Out of curiosity I tried this but it errors unless I add capabilities (sys_ptrace). The same does not seem to be true of launching the app with dlv to begin with ..."dlv exec /app", but I don't how that would work with the sidecar approach. Ephemeral containers don't have their own securityContext, either. Let me know if I am reading your suggestion correctly or not though.

  26. skonto commented on Sep 10, 2021

    @skonto
    Contributor

    Feature track doc here, please feel free to review.

  27. dprotaso commented on Oct 6, 2021

    @dprotaso
    Member

    Hey folks so @skonto added some init container support behind a feature flag.

    From the review one topic one topic that I felt required further discussion is the use of ports on the init containers. With the feature gate as its there isn't much restriction.

    @skonto's comments were

    My pov is that init containers are not part of normal app operation. So I thought users should be more flexible (be closer to K8s initi container's allowed spec) and so to use more stuff than normal Service operation allows. For example port names should be arbitrary at this point and communication protocol can be any because people may want to setup their app in some arbitrary way.

    I'm posting here to source some feedback on whether folks require the use of ports in their use cases

  28. added
    lifecycle/stale
    and removed
    lifecycle/frozen
    on Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/APIkind/featurelifecycle/staletriage/needs-user-input

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions