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
Solution 1:
You could use nginx as revrese proxy server. It is a suggested strategy for .NET Core hosting. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-3.1
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.