Talin
Talin

Reputation: 1415

Call one container from another in kubernetes

Say I have a container image that contains a large command-line program that is executed from the shell. I have another container that contains a scheduler whose job it is to invoke the first container when it receives a certain signal. For various reasons I don't want to put them in the same container (mainly because the scheduler can invoke many different tools, and different versions of those tools, and I don't want to have to put all the tools and their versions in the same container image.)

I know how to put two containers in the same pod. However, the default behavior is to run both containers at startup. What I want to be able to do is to have the scheduler be able to decide when to invoke the other container, and to be able to specify the command-line arguments (and ideally, environment variables) for it. Also, I need to know the exit status. Extra credit for getting stdout/stderr, but I can hack around with volumes if I need to.

I also know how to do this if the second container was a server, but in this case it's a shell program.

Upvotes: 0

Views: 1017

Answers (1)

Norbert
Norbert

Reputation: 6084

A quick way to do this is:

  • Add a kubectl proxy in your container startup
  • Then call a kubernetes job from the first pod.

This would create a lightweight solution in which the desired job can be queried for success state, seemingly fulfilling your requirements

Upvotes: 1

Related Questions