简体   繁体   中英

Kubernetes scaling pods using custom algorithm

Our cloud application consists of 3 tightly coupled Docker containers, Nginx, Web and Mongo. Currently we run these containers on a single machine. However as our users are increasing we are looking for a solution to scale. Using Kubernetes we would form a multi container pod. If we are to replicate we need to replicate all 3 containers as a unit. Our cloud application is consumed by mobile app users. Our app can only handle approx 30000 users per Worker node and we intend to place a single pod on a single worker node. Once a mobile device is connected to worker node it must continue to only use that machine ( unique IP address )

We plan on using Kubernetes to manage the containers. Load balancing doesn't work for our use case as a mobile device needs to be tied to a single machine once assigned and each Pod works independently with its own persistent volume. However we need a way of spinning up new Pods on worker nodes if the number of users goes over 30000 and so on.

The idea is we have some sort of custom scheduler which assigns a mobile device a Worker Node ( domain/ IPaddress) depending on the number of users on that node.

Is Kubernetes a good fit for this design and how could we implement a custom pod scale algorithm.

Thanks

Piggy-Backing on the answer of Jonah Benton:

While this is technically possible - your problem is not with Kubernetes it's with your Application! Let me point you the problem:

Our cloud application consists of 3 tightly coupled Docker containers, Nginx, Web, and Mongo.

Here is your first problem: Is you can only deploy these three containers together and not independently - you cannot scale one or the other! While MongoDB can be scaled to insane loads - if it's bundled with your web server and web application it won't be able to...

So the first step for you is to break up these three components so they can be managed independently of each other. Next:

Currently we run these containers on a single machine.

While not strictly a problem - I have serious doubt's what it would mean to scale your application and what the challenges that come with scalability!

Once a mobile device is connected to worker node it must continue to only use that machine ( unique IP address )

Now, this IS a problem. You're looking to run an application on Kubernetes but I do not think you understand the consequences of doing that: Kubernetes orchestrates your resources. This means it will move pods (by killing and recreating) between nodes (and if necessary to the same node). It does this fully autonomous (which is awesome and gives you a good night sleep) If you're relying on clients sticking to a single nodes IP, you're going to get up in the middle of the night because Kubernetes tried to correct for a node failure and moved your pod which is now gone and your users can't connect anymore. You need to leverage the load-balancing features (services) in Kubernetes. Only they are able to handle the dynamic changes that happen in Kubernetes clusters.

Using Kubernetes we would form a multi container pod.

And we have another winner - No! You're trying to treat Kubernetes as if it were your on-premise infrastructure! If you keep doing so you're going to fail and curse Kubernetes in the process!

Now that I told you some of the things you're thinking wrong - what a person would I be if I did not offer some advice on how to make this work:

In Kubernetes your three applications should not run in one pod! They should run in separate pods:

Feel free to ask if you have any more questions!

Building a custom scheduler and running multiple schedulers at the same time is supported:

https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/

That said, to the question of whether kubernetes is a good fit for this design- my answer is: not really.

K8s can be difficult to operate, with the payoff being the level of automation and resiliency that it provides out of the box for whole classes of workloads.

This workload is not one of those. In order to gain any benefit you would have to write a scheduler to handle the edge failure and error cases this application has (what happens when you lose a node for a short period of time...) in a way that makes sense for k8s. And you would have to come up to speed with normal k8s operations.

With the information provided, hard pressed to see why one would use k8s for this workload over just running docker on some VMs and scripting some of the automation.

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