Is it Possible to Dynamically Launch a Container from another Container in Kubernetes

4/9/2020

Here's my scenario,

I want to launch a Job in Kubernetes, the first container that runs will look through a list of custom resources, and launch each of the containers defined in that resource to completion. I don't know whats in the list ahead of time, I only know when the job is kicked off.

Is this possible? Can someone point me to something that shows how to do it?

-- Zeus82
kubernetes

2 Answers

4/9/2020

It is possible to manage jobs programmatically using the kubernetes client-go project.

Here are some examples.

To create a job to completion, refer:

Custom resources definitions can be managed using the kubernetes apiextensions-apiserver project.

To manage custom resources definitions, refer:

To create custom resources, refer:

-- Vikram Hosakote
Source: StackOverflow

4/9/2020

You can use the Kubernetes Client Libraries to create any Kubernetes resource from inside your code (given that it has the correct service account of course if RBAC is configured in your cluster).

If you want to run a container to completion, a Kubernetes Job would be the best fit.

-- Blokje5
Source: StackOverflow