简体   繁体   中英

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)?

I want to have a setup where ideally 0 instances are running. Then whenever a user arrive at a page it should add another pod/container-instance, so that each user has their own environment. When the user leaves the specific environment should be terminated. Is this possible to set for any n-users. Eg to have a limit of 5 users per pod/container. First person that joins means creating a new pod/container. The second just arrives at the same p/c and so on to the fifth. If a sixth user joins I want it to create a new pod/container for this user. A pod/container should be terminated if it has 0 connections.

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.

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. Thanks!

As I mentioned in comments you should check Horizontal Pod Autoscaler and Cluster Autoscaler .

Horizontal Pod Autoscaler can upscale or downscale number of your pods depends on metrics. If you want use CPU or Memory metrics, they are built-in in Kubernetes. Information how to use is well described in Horizontal 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.

If you would use other metrics (those like you mentioned in question) you should use custom metrics or external metrics , depends on your needs. To get those metrics you will need to deploy metrics agents who will gather this data. One of the most popular is Prometheus adapter . I've already mentioned about this when use kubeadm or minikube here .

If you want to autoscale nodes, you should read about Cluster Autoscaler . As CA need to add/remove node at any time it's recommended to use Cloud environment.

For AWS you can check this article and if you would use GKE you should check this article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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