简体   繁体   English

在 Kubernetes 的 pod 中从另一个容器启动一个容器

[英]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. 我希望它能帮助你。

\n
  • The pod need to run regularly , CronJob pod 需要run regularlyCronJob

  • The pod need to run on demand , Job pod 需要run on demandJob

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 相同。

您可以使用 Horizo​​ntal Pod Autoscaling ( https://kubernetes.io/docs/tasks/run-application/horizo​​ntal-pod-autoscale/ ) 根据队列中相关消息的数量来编排您的重容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌发布订阅。 从 AppEngine 到 Kubernetes pod 以及从一个 Kubernetes pod 到另一个 Kubernetes pod 的通信 - Google PubSub. Communication From AppEngine to Kubernetes pod and from one Kubernetes pod to another Kubernetes pod 在 kubernetes 中旋转另一个 docker 容器和 pod - Spin another docker container and pod in kubernetes 在一个Single Pod Kubernetes中运行多个容器 - Running multiple container in one Single Pod Kubernetes 从另一个 pod 重新启动 kubernetes pod - Restarting a kubernetes pod from another pod Kubernetes-一个容器中的每个容器一个请求 - Kubernetes - One request per container inside a pod 如何将来自一个容器的所有流量路由到同一个 Kubernetes pod 中的另一个容器? - How to route all traffic from a container through another container in the same Kubernetes pod? 从kubernetes容器中复制文件 - Copying files from a kubernetes pod container 在同一 kubernetes 集群中从一个 pod 调用一个 rest api 到另一个 pod - Call a rest api from one pod to another pod in same kubernetes cluster Kubernetes-如何在 kubernetes 中将数据从一个 Pod 发送到另一个 Pod - Kubernetes-How to send data from a pod to another pod in kubernetes 将容器中的文件夹公开为 Kubernetes Pod 中的卷 - Expose folder from a container as a volume in a Kubernetes Pod
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM