Is there any way in Qovery to set a rule to restart a pod if it reaches a certain CPU % threshold?
We have certain computationally intensive processes that run our app, and since that job may only run in a single pod (or perhaps two), it doesn’t trigger auto-scaling because overall CPU remains low (below the 60% threshold) across all our instances.
It would be very helpful if we could auto-refresh those high CPU pods after a certain period of time to make sure the application has sufficient resources. We will do other optimizations on our end, but this would be quite helpful short-term if something like this exists or there are similar options. thanks
Thank you for explaining why you would need to restart a pod if it reaches a certain CPU threshold.
Short answer is
yes
Long answer
Qovery does not support this out of the box, however you can do something which is:
Create a toolbox project with an environment.
Create a cronjob with a script that will poll the Qovery API every X minutes.
2.a We have an WebSocket API endpoint to poll the usage metrics from an app
2.b This is the API endpoint to restart an application.
Restart your service if you reach your defined threshold.
Thanks @rophilogene - setting something like this up in practice: is there documentation on the Websockets API to pull usage?
Reading REST API docs, are containers the same thing as pods? it seems like if there’s a way to get pods by application, I could then health and CPU check each one, but I don’t see a query that allows that. Currently can only GET container by ID correct so this won’t work? https://api.qovery.com/container/{containerId}
Also, to confirm, the docs say application/{applicationId}/restart is Deprecated - Please use the “Redeploy application” endpoint now. Is it still ok to use or should it call https://api.qovery.com/application/{applicationId}/deploy instead?
I can provide an example with Python today if needed?
Today, we make a clear distinction between applications deployed from a Git Repository (api.qovery.com/application) and a Container Registry (api.qovery.com/container). (Both endpoints will probably be merged this year).
So if your apps are deployed via Git, you need to look at the application resources from our API. Otherwise, it’s container resources.
Note: To list all your applications, you can use the Endpoint api.qovery.com/environment/:envId/application or api.qovery.com/environment/:envId/container
Actually, you should use the new restart endpoint if you want to restart (kill the process SIG 9). The deploy endpoint will not restart your app if it has not changed.
Thanks @rophilogene. Tried connecting to the websocket API using websocat client to see what the response looks like and I’m getting: 401 Unauthorized
I included our Qovery API key as an api_key={{ key }} param in the request.
A python example would be helpful. Also are the application and service params interchangeable? In this case as I understand it our service is an application