0

Community, I want to gentle stop Kestrel and a running .Net Core app to make it completes existing queries, prevent it from handle new queries and when all existing queries are done - stop the app and Kestrel.

I need it to setup CI/CD in Kubernetes, where I have balancer routes to Kestrel without nginx, to achieve zero downtime while deployment new app version.

Perfectly would be nice to have something similar to `nginx -s quit

Can anyone suggest the solution or share knowledge how to organize zero downtime with dotnetcore in Kubernetes?

I tried to Google the solutions - didn't worked out for me. Killing the process are not the option.

Thank you

Lorenzo Isidori
  • 1,809
  • 2
  • 20
  • 31

1 Answers1

0

Solution 1:

You could use nginx as revrese proxy server. It is a suggested strategy for .NET Core hosting. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1

nginx as reverse proxy

Solution 2:

Isn't correct. Leaving it here for others to not go this route. Read @David's comment below.

You'll have to try this yourself. and it's very risky. You might lock yourself out.

.UseKestrel(options => { options.Limits.MaxConcurrentConnections = 0; })

If you can configure KestrelServerLimits MaxConcurrentConnections to 0 you should be able to stop all the traffic. I don't know how you can configure these limits at runtime. But it'll be fun to see an implementation of this.

Ziaullah Khan
  • 2,020
  • 17
  • 20
  • 1
    That second option isn't right. Kestrel already handles graceful shutdown based on the signals sent to it (sigterm e.g.) – davidfowl May 05 '20 at 07:39
  • Thanks for pointing out @davidfowl. I'll highlight it in the answer. It was a solution from quick read and I used very skeptical language, showing my limited understanding. Thanks for pointing out. – Ziaullah Khan May 06 '20 at 11:46