Build your self-service Kubernetes Platform with Virtual Clusters 🚀- DevOps Tool of the Month (2)
Tags: kubernetes, devops, cloud, productivity
Published: 2021-02-18 14:52:08

[DevOps tool of the month](https://www.youtube.com/playlist?list=PLy7NrYWoggjztwSskGu59O38gL5v0LjUT) is a new series, where each month I will introduce one new useful DevOps tool in 2021 🙌🏼

The second one in the series is: [**Loft**](https://loft.sh/) 🎉 - With loft, any Kubernetes cluster becomes a self-service platform for developers to create virtual clusters on-demand!

---
{% youtube tt7hope6zU0 %}
---

##What problem Loft solves?  👀
Let's say in your company there are 10 project teams all using Kubernetes and each team would need 3 clusters for dev, staging and production environment. 

As you might think, each team creating and managing their own K8s cluster is very inefficient. Especially because administration of a K8s cluster is a lot of effort and you don't want to do it 30 times in a company because you have 10 projects. In addition, it's also expensive, because you need more servers and so more resources. 🤯

So a common approach of companies is to create a **company-wide K8s cluster** that a dedicated team is managing. So now your company would only need to administer this one shared cluster. And they can now give developers access to this shared cluster using isolation with namespaces, so each team can deploy their applications. 👍

**However, this comes with the following challenges**:

- **Give Access** - How do you give different teams and individual developers access to this shared cluster?
- **Restrict Access** - Also, how do you make sure each team only gets access to their project resources?  You need to restrict access to each project to keep the cluster secure. Or even within the team, you may want to restrict who has access to what based on their role and tasks.
- **Restrict Resources** - How do you restrict how much cluster resources each team can use? You don't want one team using up most of the cluster resources or one developer misconfiguring something in his namespace and messing up all other cluster services.
- **Isolate Running Resources** - How do you isolate the resources and applications of each project from each other? Because obviously, you don't want the project resources to be accidentally mixed up, right?

![Challenges](https://dev-to-uploads.s3.amazonaws.com/i/xxtaj1kd58j7q5gevqzj.png)

---

##How Loft solves it? 🤔
And Loft helps solve exactly those challenges using a concept of virtual clusters.

So what is a virtual cluster?

###Virtual Clusters###
It's simply a cluster inside a cluster.

![Kubernetes virtual clusters](https://dev-to-uploads.s3.amazonaws.com/i/ldkwm5wac5b6guyas59m.png)

The way Loft implements virtual clusters is, when user creates a vCluster, Loft will create a new namespace and create a lightweight K8s cluster inside that namespace (K3s with Api server and controller). And this way vClusters will be **completely isolated from each other**, even though they are part of the same host cluster. 😎

### Self-Service ###
Now one developer can create a vCluster to test a new feature for example. And even if he blows up and messes up his vCluster, nothing else gets affected. ✅

Or if a product manager wants to demo new features to the potential app users, they can now very easily spin up a vCluster to deploy the application and remove their vCluster when the demo is over! ✅

![Developers creating vClusters](https://dev-to-uploads.s3.amazonaws.com/i/4ob29omysjkb28bj92u7.png)

### Sleep Mode to save cloud infrastructure cost ###
A very important feature of Loft is the Sleep Mode, which lets you save significantly on your infrastructure costs.

In Sleep Mode, the virtual cluster will scale down all the resources, however, data and all Kubernetes components will be persisted.

You can trigger the sleep mode either manually or **configure virtual clusters to go to sleep mode automatically** after some period of time. With the first interaction with that virtual cluster, the cluster will become active again automatically. 👍 

--- 

## Get started with Loft 👩🏻‍💻
###*To build your own self-service Kubernetes platform*

Usually you already have existing Kubernetes clusters in your company (created using EKS, OpenShift, Rancher etc) and you already have cluster-wide resources, like Ingress Controller or Monitoring configured.

**1. Download Loft CLI**
**2. Install Loft in one of the clusters**
**3. Connect clusters to it**

Now Loft comes into the picture. Usually DevOps engineers will install Loft in one of the clusters and start connecting all other clusters to it, creating 1 big self-service cluster from many.

**4. Cluster admins create users with permissions**

Now using loft UI, loft CLI or even kubectl, cluster admins can create users for the teams or individual developers and give them permissions to create and use virtual clusters.

![Isolated Kubernetes clusters](https://dev-to-uploads.s3.amazonaws.com/i/i88s4l5u9cplcpfnzi0w.png)

**5. Developers can create vClusters when needed**

Now teams can start creating vClusters themselves when needed very easily:
![Loft UI - Create vCluster](https://dev-to-uploads.s3.amazonaws.com/i/8je3ux8gndhwyeal5kxg.png)

---

As you see loft solves quite a lot of challenges for managing and using Kubernetes clusters within your company. And at the same time, loft's sleep mode and cluster sharing help you to save cloud computing cost.

So check it out and let me know what you think about it! 🤓 🧐

More awesome tools coming up next on this series, so stay tuned for it! 🎬 😊

---

**Like, share and follow me** 😍 for more content:
- [Private FB group](https://www.facebook.com/groups/techworldwithnana)
- [Twitter](https://twitter.com/Njuchi_)
- [YouTube](https://www.youtube.com/channel/UCdngmbVKX1Tgre699-XLlUA?sub_confirmation=1)
- [Instagram](https://www.instagram.com/techworld_with_nana/)
- [LinkedIn](linkedin.com/in/nana-janashia)