简体   繁体   English

Pod 或容器的自动扩展

[英]Automatic scaling of pods or containers

Can anyone tell me if it is possible to scale either the number of containers in a pod or the number of pods (containing only 1 container)?谁能告诉我是否可以扩展 pod 中的容器数量或 pod 的数量(仅包含 1 个容器)?

I want to have a setup where ideally 0 instances are running.我想要一个理想情况下运行 0 个实例的设置。 Then whenever a user arrive at a page it should add another pod/container-instance, so that each user has their own environment.然后每当用户到达一个页面时,它应该添加另一个 pod/container-instance,以便每个用户都有自己的环境。 When the user leaves the specific environment should be terminated.当用户离开特定环境时应终止。 Is this possible to set for any n-users.这是否可以为任何 n 用户设置。 Eg to have a limit of 5 users per pod/container.例如,每个 pod/容器限制为 5 个用户。 First person that joins means creating a new pod/container.第一个加入的人意味着创建一个新的 pod/容器。 The second just arrives at the same p/c and so on to the fifth.第二个只是到达相同的 p/c,依此类推到第五个。 If a sixth user joins I want it to create a new pod/container for this user.如果第六个用户加入,我希望它为此用户创建一个新的 pod/容器。 A pod/container should be terminated if it has 0 connections.如果 Pod/容器有 0 个连接,则应终止它。

I have read that if a container within a pod gets terminated - then all the containers of the same kind also gets terminated, which I want to avoid in case other users are connected to one of these containers.我已经读过,如果 pod 中的容器被终止 - 那么所有同类容器也会被终止,我想避免这种情况,以防其他用户连接到这些容器之一。

Being fairly new within this docker / kubernetes stuff (using minikube as a test right now), I hope you can point me in the right direction.在这个 docker / kubernetes 的东西中相当新(现在使用 minikube 作为测试),我希望你能指出我正确的方向。 Thanks!谢谢!

As I mentioned in comments you should check Horizontal Pod Autoscaler and Cluster Autoscaler .正如我在评论中提到的,您应该检查Horizontal Pod AutoscalerCluster Autoscaler

Horizontal Pod Autoscaler can upscale or downscale number of your pods depends on metrics. Horizo​​ntal Pod Autoscaler可以根据指标放大或缩小Pod 的数量。 If you want use CPU or Memory metrics, they are built-in in Kubernetes.如果您想使用CPUMemory指标,它们是内置在 Kubernetes 中的。 Information how to use is well described in Horizontal Pod Autoscaler Walkthrough . Horizo​​ntal Pod Autoscaler Walkthrough 中详细描述了如何使用的信息。

When you will use HPA example from docs, please keep in mind, HPA need a few minutes to gather metrics and then display it.当您将使用文档中的HPA示例时,请记住, HPA需要几分钟来收集指标然后显示它。

If you would use other metrics (those like you mentioned in question) you should use custom metrics or external metrics , depends on your needs.如果您要使用其他指标(如您在问题中提到的那些),您应该使用custom metricsexternal metrics ,这取决于您的需要。 To get those metrics you will need to deploy metrics agents who will gather this data.要获得这些指标,您需要部署将收集这些数据的指标代理。 One of the most popular is Prometheus adapter .最流行的一种是Prometheus 适配器 I've already mentioned about this when use kubeadm or minikube here .我已经在此处使用kubeadmminikube时提到了这一点

If you want to autoscale nodes, you should read about Cluster Autoscaler .如果你想自动缩放节点,你应该阅读Cluster Autoscaler As CA need to add/remove node at any time it's recommended to use Cloud environment.由于CA需要随时添加/删除节点,因此建议使用 Cloud 环境。

For AWS you can check this article and if you would use GKE you should check this article .对于 AWS,您可以查看这篇文章,如果您要使用 GKE,则应该查看这篇文章

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

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