Starting container on demand

12/26/2018

Is there any way using k8s or swarm or any other option to automate the spawn of containers according to requests.

Part of my project is to send an event to an eventbus (rabbitMQ) which has a listener to the events once an event arrives then start a new container for each message.

The only option I found was to mount the host engine to the event listener container that and I don't really like this solution.

I would like an orchestrator to "listen" to the eventbus or to any other request queue container spawn requests and start them.

Thank you

-- IB.
containers
docker
docker-swarm
google-kubernetes-engine
kubernetes

1 Answer

12/26/2018

This is a broad question, there are many ways on you can accomplish this.

For example:

  1. Write a simple bash script on an infinite loop that gets a message from RabbitMQ using another program (perhaps written python with Pika). As soon as it gets a message, issue a docker run ...

  2. Write your own program with Pika that waits for a message and then creates a pod in Kubernetes using the python K8s client.

  3. You can also use any other language that has a client API for RabbitMQ, Docker, and/or Kubernetes.

-- Rico
Source: StackOverflow