Kubernetes部署与StatefulSets [英] Kubernetes Deployments vs StatefulSets
问题描述
我已经在Kubernetes上进行了很多挖掘工作,并且我很喜欢我看到的东西!我一直无法弄清楚的一件事是Deployment资源和StatefulSet资源之间的确切区别是什么,以及您将在哪种方案中使用每种方案(或者通常比另一种方案更受欢迎).
I've been doing a lot of digging on Kubernetes, and I'm liking what I see a lot! One thing I've been unable to get a clear idea about is what the exact distinctions are between the Deployment and StatefulSet resources and in which scenarios would you use each (or is one generally preferred over the other).
人们可以分享的任何经历都将非常棒!!
Any experiences people can share would be awesome!!
推荐答案
部署和ReplicationController用于无状态使用,并且非常轻巧. 状态集在状态为坚持下去.因此,后者对持久性卷使用volumeClaimTemplates
/声明,以确保它们可以在组件重新启动时保持状态.
Deployments and ReplicationControllers are meant for stateless usage and are rather lightweight. StatefulSets are used when state has to be persisted. Therefore the latter use volumeClaimTemplates
/ claims on persistent volumes to ensure they can keep the state across component restarts.
因此,如果您的应用程序是有状态的,或者要在Kubernetes上部署有状态的存储,请使用StatefulSet.
So if your application is stateful or if you want to deploy stateful storage on top of Kubernetes use a StatefulSet.
如果您的应用程序是无状态的,或者在启动过程中可以从后端系统建立状态,请使用Deployments.
If your application is stateless or if state can be built up from backend-systems during the start then use Deployments.
Further details about running stateful application can be found in 2016 kubernetes' blog entry about stateful applications
这篇关于Kubernetes部署与StatefulSets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!