本文介绍了如何使用复制控制器为Kubernetes中的有状态组件建模?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Kubernetes中为有状态组件/服务建模(例如CouchBase,Postgres等).在Kubernetes中,复制控制器对象需要一个用于Pod到Cookie剪切(复制)Pod的模板.如果pod是用于有状态组件,则将要求模板包含持久卷声明.如果我在复制控制器的模板中指定了持久声明,那么(可能没有尝试过,但从逻辑上来说)可能导致不同容器之间共享持久卷声明,并因此导致多个容器之间发生冲突.

I am trying to model stateful component/services (e.g. CouchBase, Postgres, etc) in Kubernetes. In Kubernetes, replication controller object requires a template for pod to cookie cut (replicate) pods. If the pod is for a stateful component, then the template will be required to include the persistent volume claim. If I specify a persistent claim in template of a replication controller, then that might (have not tried it, but logically) result in sharing of persistent volume claim between different pods and as a consequence resulting in conflict between multiple pods.

在使用复制控制器管理Pod时,如何为每个Pod分配不同的持久卷声明?如何使用复制控制器在Kubernetes中为有状态组件建模?

How to assign a different persistent volume claim to each pod when using replication controller for managing pods? How to model stateful components in Kubernetes using replication controller?

推荐答案

今天,您可能需要为应用程序中的每个副本或组件创建一个ReplicationController.因此,如果您有一个说Postgres的3节点副本,那么您将为此创建3个控制器.

Today you would probably need to create a ReplicationController for each replica or component in your app. So if you have a 3 node replica of say Postgres, you would create 3 controllers for that.

您也可以查看头盔( https://helm.sh/)以帮助解决问题,通过自动化一些步骤来为您解决其中的一些问题.

You could look at helm (https://helm.sh/) to help out here as well which has addresses some of this for you up front by automating some of the pieces.

还有一个正在实现的PetSet概念,它可以进一步解决此问题.您可以在此处阅读一些详细信息: https://github.com/kubernetes/kubernetes/Issues/260

There is also a notion of PetSet which is being implemented and addresses this issue more. You can read up on some of those details here: https://github.com/kubernetes/kubernetes/issues/260

这篇关于如何使用复制控制器为Kubernetes中的有状态组件建模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 12:04