Call jobs on demand

5/17/2021

We have a docker container which is a CLI application, it runs, does it s things and exits.

I got the assignment to put this into kubernetes but that containers can not be deployed as it exits and then is considered a crashloop.

So the next question is if it can be put in a job. The job runs and gets restarted every time a request comes in over the proxy. Is that possible? Can job be restarted externally with different parameters in kubernetes?

-- Serve Laurijssen
docker
kubernetes

1 Answer

5/17/2021

So the next question is if it can be put in a job.

If it is supposed to just run once, a Kubernetes Job is a good fit.

The job runs and gets restarted every time a request comes in over the proxy. Is that possible?

This can not easyli be done without external add-ons. Consider using Knative for this.

Can job be restarted externally with different parameters in kubernetes?

Not easyli, you need to interact with the Kubernetes API, to create a new Job for this, if I understand you correctly. One way to do this, is to have a Job with kubectl-image and proper RBAC-permissions on the ServiceAccount to create new jobs - but this will involve some latency since it is two jobs.

-- Jonas
Source: StackOverflow