本文介绍了将多个容器放在一个容器中的好处是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在吊舱中拥有多个容器与拥有独立容器相比有什么好处?

What's the benefit of having multiple containers in a pod versus having standalone containers?

推荐答案

如果同一吊舱中有多个容器,则它们可以像localhost那样相互交谈,并且可以共享安装的卷.

If you have multiple containers in the same pod, they can speak to each other as localhost and can share mounted volumes.

如果每个容器有多个容器,则可以重新启动一个容器而无需重新启动另一个容器.假设它们受部署控制,则可以添加其中一个的其他副本,而不必扩展其他副本.如果其中一个的版本或其他特征发生更改,则不会强制您重新启动另一个.您需要设置一种服务,以便彼此通信,并且它们无法通过文件系统进行通信.

If you have multiple pods of one container each, you can restart one without restarting the other. Assuming they're controlled by deployments, you can add additional replicas of one without necessarily scaling the other. If the version or some other characteristic of one of them changes, you're not forced to restart the other. You'd need to set up a service to talk from one to the other, and they can't communicate via a filesystem.

我经常看到的一般方法是,在部署中,每个吊舱中始终有一个容器,除非您有特殊的理由需要一个额外的容器.通常,这是某种专用的"sidecar",它与凭证服务进行对话,管理日志记录,运行网络代理,或者是pod所做的主要工作之外的其他事情(并且不是pod中的单独服务)本身的权利).

The general approach I've always seen is to always have one container per pod within a deployment, unless you have a specific reason to need an additional container. Usually this is some kind of special-purpose "sidecar" that talks to a credentials service, or manages logging, or runs a network proxy, or something else that's secondary to the main thing the pod does (and isn't a separate service in its own right).

这篇关于将多个容器放在一个容器中的好处是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:03
查看更多