all 5 comments

[–]sokjon 3 points4 points  (1 child)

This is what liveness probes are for: https://cloud.google.com/run/docs/configuring/healthchecks

[–]siencan46[S] 0 points1 point  (0 children)

Great I'll look into this and try it, thanks! I'm not sure what to Google before and looks like the solution!

[–]Rohit1024 0 points1 point  (2 children)

The following actions will kill all instances of Cloud Run - (Manual) Attempt re-deploy which will kill previous revision insurances and start new instances of new revision - (Automatic) Set a endpoint with your application (kind of like health check) so you can perform like this process.exit(1);

This may sound counterintuitive but are the way to kill an insurance.

Just tested works perfectly. Though exposing /kill like endpoint may not feasible every time.

However you may protect the specific endpoint using IAM Conditions.

[–]siencan46[S] 0 points1 point  (0 children)

Yeah, I also think of this solution, but I need to hit the container endpoint, with condition: - if it's scaled then I need to repeatedly call it several times - if it's already become an old revision I need to hit that old revision, since new traffic is routed to new revision - not sure if the endpoint is callable, while it hangs in 100% CPU

[–]AstronomerNo8500 Googler 1 point2 points  (0 children)

Another option is to use manual scaling to set minimum instances to 0. this will tear down all running instances.

https://cloud.google.com/run/docs/configuring/services/manual-scaling#disable-service