I have an API as a Kubernetes service, and I need to run an endpoint in the API every hour. (heavy statistic calculation, takes around 3-5 minutes)
Currently I am using curl to call the end point directly:
containers:
- name: callout
image: 'buildpack-deps:curl'
args:
- /bin/sh
- '-ec'
- 'curl http://api-service/v1/Stats/CalculateStats'
The problem is the task is sent to service, and it ends up on one of the pods. Running the calculation keeps the pod busy, and the other requests coming from regular users via front-end slow down.
How can I create a dedicated pod from the same API image with a higher CPU request (so it can run faster) and run the calculation on it, then remove the pod and repeat the process on the next schedule?
Thanks