Start a container from another one in a pod in Kubernetes

8/15/2018

I have a container that performs some actions over some data. This container is heavy in memory and CPU resources, and I want it to start only an on-demand basis.

As an example, with docker-compose, out of Kubernetes, I use it this way:

docker-compose run heavycontainer perform.sh some-action

The container performs the action and ends.

In Kubernetes I want this container to perform the actions it provides, but in response to some messages (AMQP messages, created by other containers). I have a container that listens for messages. My first thought was a pod with two containers: listener and performer. But I don't know whether is possible or not start a container from another.

Init or sidecar containers doesn't seem a solution. And I prefer to avoid creating a custom image to inject the listener into the performer.

Is there any way to achieve this?

-- Manel R. Doménech
docker
kubernetes

2 Answers

9/29/2019

You can use Horizontal Pod Autoscaling (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) for orchestrating your heavycontainer, based on number of relevant messages in the queue.

-- Vitaly
Source: StackOverflow

8/15/2018

I hope it help you.

  • The pod need to run regularly, CronJob

    • The pod need to run on demand, Job

Firstly, I apologize you about my wrong answer.

I understand what you want now, and I think it can be available to run multiple containers in same pod. Patterns for Application Augmentation on OpenShift is helpful for you.

PS. OpenShift is Enterprise Kubernetes, so you can think OpenShift is same with Kubernetes.

-- Daein Park
Source: StackOverflow