[英]Start a container from another one in a pod in Kubernetes
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.
这个容器占用大量内存和 CPU 资源,我希望它仅按需启动。
As an example, with docker-compose, out of Kubernetes, I use it this way:例如,在 Kubernetes 之外的 docker-compose 中,我是这样使用它的:
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).在 Kubernetes 中,我希望这个容器执行它提供的操作,但是响应一些消息(AMQP 消息,由其他容器创建)。 I have a container that listens for messages.
我有一个监听消息的容器。 My first thought was a pod with two containers: listener and performer.
我的第一个想法是一个带有两个容器的 pod:listener 和 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. Init 或 sidecar 容器似乎不是解决方案。 And I prefer to avoid creating a custom image to inject the listener into the performer.
而且我更喜欢避免创建自定义图像来将听众注入表演者。
Is there any way to achieve this?有没有办法实现这一目标?
I hope it help you.
我希望它能帮助你。
The pod need to run regularly
, CronJob pod 需要
run regularly
, CronJob
The pod need to run on demand
, Job pod 需要
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.我明白你现在想要什么,我认为它可以在同一个 pod 中运行多个容器。 Patterns for Application Augmentation on OpenShift is helpful for you.
OpenShift 上的应用程序增强模式对您有所帮助。
PS.附注。 OpenShift is Enterprise Kubernetes, so you can think OpenShift is same with Kubernetes.
OpenShift 是 Enterprise Kubernetes,因此您可以认为 OpenShift 与 Kubernetes 相同。
您可以使用 Horizontal Pod Autoscaling ( https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ ) 根据队列中相关消息的数量来编排您的重容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.