logo

Kubernetes - Virtual Clusters

Virtual clusters (often called vclusters) are fully functional Kubernetes clusters that run inside another Kubernetes cluster.

Think of them like Virtual Machines for Kubernetes: just as a VM lets you run multiple isolated operating systems on one physical server, a virtual cluster lets you run multiple independent Kubernetes environments on a single physical "host" cluster.

How They Work

A virtual cluster consists of its own Control Plane (API server, controller manager, and data store) but typically shares the worker nodes and networking of the underlying host cluster.

  • Isolation: Each virtual cluster has its own API server, meaning users can have cluster-admin privileges, install their own CRDs (Custom Resource Definitions), and manage their own namespaces without affecting the host or other virtual clusters.
  • The Syncer: A key component (like the "hypervisor") syncs resources (like Pods) from the virtual cluster down to the host cluster so they can actually be scheduled and run on real nodes.

Key Benefits

  1. Hard Multi-Tenancy: Traditional Kubernetes namespaces are "soft" isolation. Virtual clusters provide "hard" isolation because each tenant has a completely separate API server and data store.
  2. Cost Efficiency: Instead of spinning up 10 separate EKS/GKE clusters (which is expensive due to control plane fees and idle nodes), you can run 10 virtual clusters on one physical cluster.
  3. Low Management Overhead: You only have to maintain, upgrade, and secure one "real" host cluster. The virtual clusters can be created and destroyed in seconds by developers.
  4. Configuration Flexibility: Different teams can run different Kubernetes versions, different versions of the same Operator, or conflicting CRDs on the same physical hardware.
  5. Developer Self-Service: Developers can be "Admins" of their own virtual sandbox. They can create namespaces and delete resources freely without the risk of breaking the production host cluster.

Popular Tools

1. vcluster (by Loft Labs)

The most popular open-source tool in this space. It is lightweight and easy to use.

  • How it works: It runs the k3s (or vanilla K8s) control plane as a Pod inside a namespace of your host cluster.
  • Best for: Development environments, CI/CD pipelines, and giving developers "private" clusters.

If the vcluster API server is just a pod, how does it actually start other pods? Vcluster uses a component called the Syncer.

  • When you tell the Virtual API Server to "Start a Pod," it doesn't actually have its own nodes to put it on.
  • Instead, the Syncer "copies" that pod request down to the Host Cluster.
  • The Host Cluster then schedules the pod on a real node.

2. Kamaji (by Clastix)

Kamaji takes a slightly different approach, acting as a "Control Plane Manager."

  • How it works: It turns a management cluster into a factory that churns out control planes for "tenant clusters." These tenant clusters can even use worker nodes located in different clouds or on-prem.
  • Best for: Managed Service Providers (MSPs) or large enterprises building their own "Kubernetes-as-a-Service."

3. Loft

This is the commercial platform built on top of the open-source vcluster.

  • Features: It adds a UI, enterprise security (SSO), and "sleep mode" (which automatically shuts down idle virtual clusters to save money).

4. Capsule (by Clastix)

While not exactly a "virtual cluster" tool, it is the leading alternative for Namespace-based multi-tenancy.

  • How it works: It aggregates multiple namespaces into a single "Tenant" entity and provides an API proxy to make the user feel like they are in a private space.
  • Best for: Teams that need isolation but don't want the extra overhead of a separate API server for every user.

Summary Comparison

Feature Kubernetes Namespaces Virtual Clusters (vcluster)
Isolation Soft (Shared API Server) Hard (Separate API Server)
Admin Rights Limited (Namespaced) Full (Cluster-Admin in vcluster)
Global Resources Shared (CRDs, Nodes) Isolated (Private CRDs)
Overhead Almost Zero Very Low (1-2 Pods)
Complexity Simple Moderate