[英]How to scale a CRD Controller in Kubernetes
I'm reading a lot of documentation about CRD Controller 我正在阅读很多关于CRD控制器的文档
I've implemented one with my business logic, and sometimes I got this race condition: 我用我的业务逻辑实现了一个,有时候我遇到了这种竞争条件:
Foo
with name bar
bar
称它为Foo
Deployment
with a generated name, and I save the name (as reference) it in the Foo
object Deployment
,并将其保存在Foo
对象中的名称(作为参考) error syncing 'default/bar': Operation cannot be fulfilled on Foo.k8s.io "bar":
the object has been modified; please apply your changes to the latest version
and try again, requeuing
The thing is because my Deployment
has a generated name and maybe the save (Foo) has failed, I got two Deployment
with two names. 问题是因为我的
Deployment
有一个生成的名称,也许save(Foo)失败了,我有两个Deployment
有两个名字。
I did not found a way to fix it for now, but it raises a question. 我暂时没有找到解决问题的方法,但它提出了一个问题。
How if I've multiple controllers running ? 如果我有多个控制器在运行?
I've started two controllers, and I got the same race condition by just creating a new object. 我已经启动了两个控制器,并且通过创建一个新对象获得了相同的竞争条件。
So, what is the best design to scale a CRD controller and avoid this kind of race conditions? 那么,扩展CRD控制器并避免这种竞争条件的最佳设计是什么?
Generally you only run one copy of a controller, or at least only one is active at any given time. 通常,您只运行一个控制器副本,或者在任何给定时间至少只有一个处于活动状态。 As long as you were careful to write your code convergently then it shouldn't technically matter, but there really isn't much reason to run multiple.
只要你小心地编写你的代码,那么它在技术上并不重要,但实际上没有多少理由可以运行多个代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.