Question

Is multisite a valid use case for Kubernetes?

Posted April 27, 2020 655 views
Kubernetes

I’m very new to Kubernetes. I’m pretty familiar with Docker though, which is why I’m interested in giving this a shot. I love the ease of deploying apps with Docker. I don’t know how many hours of manual labor it has saved me at this point. Now I have a situation where I want to deploy a bunch of apps to a server. I’m curious as to what the best approach would be. Here’s what I want to achieve in a nutshell:

I want to start off with one server that will host multiple Django sites for clients. These Django sites will basically be backoffice applications that will get only be visited by my clients themselves to store information. This information will be read out through an API, and will be turned into pure HTML, CSS, and JS, that I will host somewhere else as a static site. So these backoffice apps will basically serve as static site generators with a fancy Django-powered backend. The amount of traffic each of these backoffices will get will be very small. To use my resources efficiently, I want to fit as many of these ‘backoffice’ apps as I can in as little server space as I can. Unfortunately, creating one application that will serve all users is not an option. So for now they’re going to have to be different Django apps.

I know I can deploy multiple Django sites on one droplet, but I’d really like to use containers for this. It makes the process that much easier to manage. My question is, would managing these tiny 'backoffice’ sites be a valid use case for Kubernetes? Would it help me avoid the hassle of having to set up a bunch of sites on a droplet manually, and would it help me use my resources efficiently? Or should I perhaps use regular Docker containers without Kubernetes? Or is my idea of achieving this using containers just ridiculous in the first place?

For the types of clients I have in mind for this service, I imagine I could fit a hundred clients onto one small droplet without them getting in each other’s way, as only one or two will be active at any given time.

I’m curious if it’s worth checking out out Kubernetes (or Docker) to manage these microsites, or if I’m better off just biting the bullet and setting up some flow to deploy these sites to the droplet individually.

Any advice is more than welcome!

1 comment
  • Hi, you’ll have to use different Docker images for each of the these backoffice services whether you choose to use Kubernetes or not. I would recommend using Kubernetes if you require the following functional benefits in production:

    • need to scale service workloads individually
    • need service failover functionality
    • need to be able to do rolling updates for a given service
    • need to be able to do rollbacks for a given service
    • need 3 or more nodes for a Kubernetes cluster

    If you’re not requiring some or all the above functionality, you may want to consider an alternative approach here for your production deployment. For example, one can simply use docker-compose and get all these services up and operational by doing a docker-compose up -d. Otherwise, I would consider it to be overkill to use Kubernetes for the task at hand for your proposed deployment strategy. Gotta run, I wish that this helps, and all the best.

    Think different and code well,

    -Conrad

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi, first note: remember that Kubernetes is not more than one orchestrator and is container made !

The answer for your question:

  • Is multisite a valid use case for Kubernetes?
  • YES

For your question I recommend you give a first k8s try in local environment, may be using k3s, minikube, kind, or bare metal options with kubeadm, rke, etc. This will show you the real k8s power and his beauty. By the other way, yes, k8s is your correct option.

Then you can deploy your k8s manifest in DOK with Managed Kubernetes o droplet based, any way, take the correct decision and use k8s !!

Normally you declare the desired state for you cluster using declarative manifest like deployments, services, secrets, ConfigMaps, volumes, ingresses and Load Balancers. The best option for expose your services will be one Ingress Controller like Traefik using a single Load Balancer.

For your requirements can also think about the Digital Ocean CDN or the Digital Ocean Space…

Best regards,

HR ;)

  • Thanks for your reply! I got two in favor and one against. The benefits Conrad mentions in favor of Kubernetes don’t really apply to me at this point. But then again I’m sufficiently excited to just give it a shot and see what happens along the way. The first part of setting it up will be trial and error. And if I have the docker containers at the ready I can always switch to a more conventional approach if I find there may be easier ways.

    As for DO Spaces and its CDN, I’m definitely interested in those! The cost is much lower than S3, while the API is S3 compatible. Since DO Spaces doesn’t support static website hosting, however, I’ll have to use a different service to host the individual site.

I really enjoy using and learning about Kubernetes. If it’s at all helpful, here’s how I set up my cluster:

I currently run about 10 (very low traffic) sites on a 3-node cluster. It’s probably overkill, but it’s also great learning experience and practice for me, so it’s totally worth it in my mind.

About half of the sites serve static content.

I have other apps written in different languages (.NET/PHP/NodeJS) that have some state, but I keep that in Azure Storage (you could use Amazon or DigitalOcean equivalents of course)

I deploy all my applications as replica sets with 2 instances. The idea being that if one node went down the apps would continue to function.

I use nginx with cert-manager to manage the SSL certs for all the domains. I found it a little tricky to get working, but there was a really good tutorial for getting that set up correctly, I forget which one though :-)

I store my private docker images in AWS ECR. Pretty easy to use, but one trick to getting it working smoothly with digital ocean k8s : https://nabeel.dev/2020/03/22/k8s-ecr-login-renew/

My advice especially if you’re new to k8s: DO NOT deploy any type of database. Lots of ways to mess that up. Better to use a managed data service for that part and keep your Kubernetes deployments stateless.

  • Thanks for your answer! Yeah, I’m sure I’ll also enjoy all the learning that comes with this! If it’s a bit of an overkill at first that’s alright. I’ve been wanting to get my hands dirty with K8s for a while now, so I’m also looking for any business case that can get me going!

    I’m quite familiar with AWS S3 (though I prefer DO spaces), ECR, and the lot. I’ll definitely keep my database outside of the cluster!

Submit an Answer