如何在Kubernetes Pod之间共享存储? [英] How to share storage between Kubernetes pods?

查看:1271
本文介绍了如何在Kubernetes Pod之间共享存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估Kubernetes作为我们新应用程序的平台.现在,一切看起来都非常令人兴奋!但是,我遇到了一个问题:我将群集托管在GCE上,并且需要某种机制来在两个Pod(连续集成服务器和应用服务器)之间共享存储.用kubernetes做到这一点的最佳方法是什么?这些卷类型似乎都不符合我的需求,因为如果一个Pod需要写入GCE磁盘,则无法共享该磁盘. NFS会很完美,但是似乎需要为kubernetes集群提供特殊的构建选项?

I am evaluating Kubernetes as a platform for our new application. For now, it looks all very exciting! However, I’m running into a problem: I’m hosting my cluster on GCE and I need some mechanism to share storage between two pods - the continous integration server and my application server. What’s the best way for doing this with kubernetes? None of the volume types seems to fit my needs, since GCE disks can’t be shared if one pod needs to write to the disk. NFS would be perfect, but seems to require special build options for the kubernetes cluster?

共享存储似乎是我现在使用Kubernetes多次遇到的问题.在多个用例中,我只想拥有一个卷并将其连接到多个Pod(具有写访问权限).我只能假设这是一个常见的用例,不是吗?

Sharing storage seems to be a problem that I have encountered multiple times now using Kubernetes. There are multiple use cases where I'd just like to have one volume and hook it up to multiple pods (with write access). I can only assume that this would be a common use case, no?

例如,此页面描述了如何设置Elasticsearch集群,但是将它与持久性存储连接起来是不可能的(如此处所述),这使它变得毫无意义. :(

For example, this page describes how to set up an Elasticsearch cluster, but wiring it up with persistent storage is impossible (as described here), which kind of renders it pointless :(

推荐答案

回答这个问题有点晚了,但是根据到目前为止我对Kubernetes/MSA的经验,这里的问题更多是在您的设计模式中. MSA中经常出现的一种基本设计模式是对服务的正确封装,其中还包括其数据.

A bit late to answer this question but from my experience thus far of Kubernetes / MSA, the issue here is more in your design pattern. One of the fundamental design patterns that continues to come up quite often in MSA is the proper encapsulation of your services, which also includes its data.

您的服务应照顾与其关注领域相关的数据,并且与OOP一样,应允许通过接口(API,PUBSUB消息等)将该数据访问到其他服务.对数据的多服务访问类似于OOP中的全局变量.

Your service should look after the data that is related to its area of concern and, much like OOP, should allow access to this data to other services via an interface (an API, PUBSUB message etc). Multi-service access to data is an anti-pattern akin to global variables in OOP.

我认为Google也有同样的看法,这就是为什么Kubernetes是以这种方式设置的.

I assume that Google have the same opinion as well and this is why Kubernetes is set up in this fashion.

作为一个例子,如果您要写日志,则应该有一个日志服务,每个服务都可以调用它需要记录的相关数据.直接写入共享磁盘意味着,如果您更改日志目录结构等,或者决定添加其他功能(如出现错误的电子邮件),则需要更新每个容器.

As an example, if you where looking to write logs, you should have a log service which each service can call with the relevant data it needs to log. Writing directly to a shared disk means that you'd need to update every container if you change your log directory structure etc or decided to add extra functionality like emails on errors.

这篇关于如何在Kubernetes Pod之间共享存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆