[英]How to organize containers “horizontally” inside Kubernetes pods?
So I'm trying to wrap my head around what exactly a typical Kubernetes pod looks like. 所以我试图围绕一个典型的Kubernetes pod看起来像什么。 According to their docs , a pod :
根据他们的文档 ,一个pod :
" A pod (as in a pod of whales or pea pod) corresponds to a colocated group of applications running with a shared context. "
“ 一个pod(如在一群鲸鱼或豌豆荚中)对应于一个以共享上下文运行的共同应用程序组。 ”
Later in that same article: 后来在同一篇文章中:
" Pods can be used to host vertically integrated application stacks, but their primary motivation is to support co-located... "
“ Pod可用于托管垂直集成的应用程序堆栈,但它们的主要动机是支持共存...... ”
OK, so you can organize a single pod as your entire vertical stack (from DB to web app). 好的,您可以将单个窗格组织为整个垂直堆栈(从数据库到Web应用程序)。 But apparently that's not typically how it's organized, so I assume that typically a " horizontal " organization is preferred ( why?? ).
但显然这通常不是它的组织方式,所以我认为通常一个“ 横向 ”组织是首选( 为什么?? )。
But to me, horizontal layering/stratification implies that you'll only have one container in a pod, because typically in each tier of service (web, app, cache, db, etc.) you'll have one type of component. 但对我来说,水平分层/分层意味着你在一个pod中只有一个容器,因为通常在每个服务层(web,app,cache,db等)中你都有一种类型的组件。
Let's take a concrete example. 我们举一个具体的例子。 Say we have the following vertical stack of tiers:
假设我们有以下垂直堆栈:
These are fairly typical components in an app stack. 这些是应用程序堆栈中相当典型的组件。 If we went against Kubernetes' own advice, and created "vertically-aligned" pods, each pod would consist of 1 type of container for each tier (the web/app server, each microservice, each DB, etc.).
如果我们反对Kubernetes自己的建议,并创建“垂直对齐”的pod,每个pod将由每层的一种类型的容器(web / app服务器,每个微服务,每个DB等)组成。
But how would a horizontally-aligned pod be organized? 但是如何组织水平对齐的吊舱呢? What containers would go in which pods?
什么容器会进入哪个容器?
A Pod is the basic scheduling unit in Kubernetes. Pod是Kubernetes的基本调度单元。 It is the common case that a pod will only have a single container running in it, as most containers can be scheduled independently (ie they do not need to be co-located on the same machine).
通常情况下,pod只有一个容器在其中运行,因为大多数容器可以独立调度(即它们不需要共同位于同一台机器上)。
With regards to your example, you could put most containers in individual pods, and use a Replication Controller to horizontally scale the number of replicas of each Pod (and therefore container) as needed. 关于您的示例,您可以将大多数容器放在单个pod中,并使用Replication Controller根据需要水平扩展每个Pod(以及容器)的副本数。 Along with your replication controller, you'll also want a Service to load balance between the replicas.
与复制控制器一起,您还需要服务在副本之间进行负载平衡。 Vertical tiers could be organized using labels on the pods/replication controllers/services, such as
tier=message_broker
. 可以使用pod /复制控制器/服务上的标签来组织垂直层,例如
tier=message_broker
。
Edit: 编辑:
The reason it's not a good idea to put your entire stack in a single pod is it limits your flexibility: 将整个堆栈放在一个pod中并不是一个好主意的原因是它限制了你的灵活性:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.