Can we spawn more containers from existing one in a pod?

5/28/2019

I am having Kubernetes pod on a machine and want to have empty pod where on run time pod should be able to add/remove the containers but seems like pod always starts with something called init_container, so can this init_container spawn more containers?

-- CodeQuestor
containers
docker
kubernetes

1 Answer

5/28/2019

This isn't possible. At an API level, the containers in a PodSpec cannot be updated once the pod has been created.

For this sort of setup the pattern I've found more useful is to set up a job queue like RabbitMQ, and then set up some number of workers that can read from that queue and do individual jobs. In Kubernetes land, the workers can be a simple Deployment and you can then control the number of workers with kubectl scale.

-- David Maze
Source: StackOverflow