如何自动缩放 helm chart rabbitmq statefulset

How to auto scale helm chart rabbitmq statefulset

我已经通过 helm 从 bitnami

安装了 rabbitmq

它的文档讨论了手动水平缩放,据我所知我想知道自动缩放,这可能真的很方便。我想知道在没有数据丢失的情况下是否会 possible/safe 获得自动缩放设置

建议使用带有源版本控制值 yaml 的声明式 helm 升级命令来扩展或缩小 rabbitmq 集群,而不是命令式 kubectl scale 命令,因为它是源版本控制的,如果您需要重新运行 更改一些其他值后的 helm upgrade 命令,它将使用正确的副本计数。

我没有看到水平 pod 自动缩放器 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ template in https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq/templates 所以我认为它没有内置自动缩放功能。 Horizo​​ntal Pod Autoscaler v2beta2 API 具有许多稳定缩减的功能。

https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq#horizontal-scaling中所述,当您缩小集群时,helm/kubernetes只会删除 pod,而不会使用 rabbitmqctl forget_cluster_node 命令从集群中删除 rabbitmq 节点.它也不会删除与 pod 关联的 pvc。因为 pvc 没有被删除,如果你再次扩展集群,它会使用相同的 pvc,因为它使用了 statefulset。您将必须手动 运行 rabbitmqctl forget_cluster_node 命令并删除文档中提到的 pvc。

请注意,根据 https://www.rabbitmq.com/clustering.html#cluster-membership, if you dont use queue type that supports replication and some problem happens with the pv bound for some pvc associated with a pod replica or if one of the pods is evicted or crashes or killed by OOM Killer or the Node on which is it running fails, then that will lead to message data loss. Also, if you scale down your cluster, then in this case also, it could lead to message data loss. So best way to avoid message data loss is to use queue type that supports replication and also using Volume Snapshots https://kubernetes.io/docs/concepts/storage/volume-snapshots/

我建议您也阅读下文以了解有状态集副本。 https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/ https://kubernetes.io/docs/tasks/run-application/scale-stateful-set/