简体   繁体   English

Kubernetes 自定义部署

[英]Kubernetes custom deployment

Our horizontal scaling is currently suffering because of Liquibase.由于 Liquibase,我们目前的水平扩展受到了影响。

We would want our deployments to always deploy one pod which runs Liquibase ( -Dspring.liquibase.enabled=true ), and then all subsequent pods to not run it ( -Dspring.liquibase.enabled=false ).我们希望我们的部署始终部署一个运行 Liquibase ( -Dspring.liquibase.enabled=true ) 的 pod,然后所有后续 pod 不运行它 ( -Dspring.liquibase.enabled=false )。

Is there anything that Kubernetes offers which could do this out of the box? Kubernetes 提供的东西有什么开箱即用的吗?

I'm unfamiliar with Liquibase and I'm unclear how non-first Pods leverage Liquibase but, you may be able to use a lock to control access.我不熟悉 Liquibase,我不清楚非第一个 Pod 如何利用 Liquibase,但是,您可以使用锁来控制访问。 A Pod that acquires the lock sets the property to true and, if it is unable to acquire the lock, the property is false .获取锁的 Pod 将该属性设置为true ,如果无法获取锁,则该属性为false

One challenge will be in ensuring that the lock is released if the first Pod terminates.一个挑战是确保在第一个 Pod 终止时释放锁。 And, to understand the consequence on the other Pods.并且,要了解对其他 Pod 的影响。 Is an existing Pod promoted?是否提升了现有 Pod?

Even though Kubernetes leverages etcd for its own distributed locking purposes, users are encouraged to run separate etcd instances if they need locks.尽管 Kubernetes 将 etcd 用于其自己的分布式锁定目的,但如果用户需要锁定,我们还是鼓励他们运行单独的 etcd 实例。 Since you have to choose, you may as well choose what you prefer eg Redis, Zookeeper.既然你必须选择,你也可以选择你喜欢的,例如Redis,Zookeeper。

You could use an init Container or sidecar for the locking mechanism and a shared volume to record its state.您可以使用 init Container 或 sidecar 作为锁定机制和共享卷来记录其 state。

It feels as though Liquibase should be a distinct Deployment exposed as a Service that all Pods access.感觉好像 Liquibase 应该是一个独特的部署,作为所有 Pod 访问的服务公开。

Have you contacted Liquibase to see what it recommends for Kubernetes deployments?您是否联系过 Liquibase 以了解它对 Kubernetes 部署的建议?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM