One time task with Kubernetes

10/2/2019

We are implementing a utility that will apply the DDLs to the database. The utility is built using spring boot java and it has a main program that will run just once on startup. Can some one share what kind of K8s recipe file. Here are my considerations, the pod is expected to be short lived and after the program executes I want the POD to get killed.

-- vinSan
deployment
kubernetes
spring

1 Answer

10/2/2019

Kubernetes Jobs are what you want for that.

Here is a great example.

Once you start running jobs you'll also want to think of an automated way of cleaning up the old jobs. There are custom controllers written to clean up jobs, so you could look at those, but there is first-class support being built-in for job clean-up that I believe is still in alpha state, but you can already use this of course.

It works by simply adding a TTL to your job manifests. Here is more info on the job clean-up mechanism with TTL.

-- Shogan
Source: StackOverflow