serverless / serverless-kubeless

This plugin enables support for Kubeless within the Serverless Framework.
Apache License 2.0
303 stars 81 forks source link

Should having a Package > 1MB throw an error? #126

Open alexander-alvarez opened 6 years ago

alexander-alvarez commented 6 years ago

Right now we just log the warning, but I'm curious if the build pipeline should just stop at that point? https://github.com/serverless/serverless-kubeless/blob/cb1f2216484dd4d9e2ce71e1112a57b0f697b19b/deploy/kubelessDeploy.js#L74

andresmgot commented 6 years ago

The reason why that's a warning and not an error is because it's difficult to know the size in which the file will be too big. We now that the limitation of an etcd entry is 1MB but in our case the size should be calculated for the entire object not just the function file. That means that a huge dependencies file and a small zip will be an issue too. For that reason we let the user receive the error from the K8s API:

Serverless: WARNING! Function zip file is 10MB. The maximum size allowed is 1MB: please use package.exclude directives to include only the required files
Serverless: Deploying function hello...

  Error --------------------------------------------------

  Found errors while processing the given functions:
Error: Unable to deploy the function hello. Received:
  Code: 500
  Message: rpc error: code = ResourceExhausted desc = grpc: trying to send message larger than max (13814928 vs. 2097152)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
dwelch2344 commented 6 years ago

Running into this now with a fairly large serverless package. Is there any way to increase the limit to get around this?

andresmgot commented 6 years ago

hi @dwelch2344,

In theory, in the serverless package you should only include source code (so it's difficult to hit the limit of 1MB). If you are including some unnecessary files you can use the exclude: field to avoid adding those files.

ned-kelly commented 5 years ago

Running into this problem also ... I've got a pre-compiled "chromium" binary that's packaged up as part of my deployment - Works fine in AWS Lambda, however not Kubeless...

https://kubeless.io/docs/advanced-function-deployment/ - Documentation here explains that the "function" can actually be a link to a ZIP file that is downloaded upon initial execution of the function...

What would be the chances of implementing this?

andresmgot commented 5 years ago

Hi @ned-kelly,

It doesn't work right now with the serverless plugin but you can upload the zip file somewhere (accessible from within your cluster) and use the URL to deploy the function using kubeless CLI:

kubeless function deploy --from-file http://.../function.zip ...

That file doesn't have the restriction to be under 1MB. You can find more info here: https://kubeless.io/docs/advanced-function-deployment/#deploying-large-functions