serverless / serverless-kubeless

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

Is it possible to use serverless-kubeless with dotnetcore especially 3.1? #225

Open kingpeti opened 3 years ago

kingpeti commented 3 years ago

I tried lots of scenarios but every outcome was failed. Because native kubeless support dotnetcore3.1 it think the plugin should too. I tried manualy packaging and compileing files and also I tryed to send the source code to the pod. I zipped only the 2 nesesery files, test.cs and project.csproj.

service: test

provider:
  name: kubeless
  namespace: kubeless
  runtime: dotnetcore3.1

plugins:
  - serverless-kubeless

functions:
  hi:
    handler: module.handler

Error looks like the IOC is not loaded the code or project properly.

The log from pod after trying to deploy is the next:

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM3KSO807GKN", Request id "0HM3KSO807GKN:00000001": An unhandled exception was thrown by the application.
System.ArgumentNullException: Value cannot be null. (Parameter 'type')
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Kubeless.Core.Invokers.CompiledFunctionInvoker..ctor(IFunction function, Int32 functionTimeout) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 29
   at Kubeless.WebAPI.Startup.<>c__DisplayClass4_0.<ConfigureServices>b__0(IServiceProvider _) in /app/Kubeless.WebAPI/Startup.cs:line 30
   at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
   at lambda_method(Closure , IServiceProvider , Object[] )
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)  
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 8.2769ms 500

My function is correct because when I send it to kubeless with their command is works just fine

kubeless function update hi --from-file test.cs --handler module.handler --dependencies project.csproj --runtime dotnetcore3.1 -n kubeless

If my serverless.yaml is incorrect, what I need to add to work with this plugin?

I tried serverless-dotnet and serverless-dotnet-package but they just compiled and ziped.

If this plugin not suppors the dotnetcore runetime then please add this feature, because I also use this platform heavily with Typescript, and I would like to compare with dotnet in my project.