# Virtual Clusters

VCluster (Virtual Cluster) enables you to run multiple isolated Kubernetes clusters (vclusters) within a single host cluster. This is ideal for multi-tenant, development, testing, and regional deployments on AKS, EKS, GKE, or on-prem clusters.

***

## Real-Life Use Cases

* **Multi-Tenant SaaS:** Isolate customer workloads in separate vclusters for security and compliance.
* **Dev/Test Environments:** Spin up ephemeral vclusters for feature branches, CI/CD, or integration testing without impacting production.
* **Regional Deployments:** Deploy vclusters per region to meet data residency or regulatory requirements.
* **Platform Engineering:** Empower teams to manage their own vclusters with full Kubernetes API access, while centralizing infrastructure management.

***

## Step-by-Step: Deploying a vcluster

1. **Install vcluster CLI:**

   ```sh
   curl -sSL https://vcluster.com/download | bash
   # or use Homebrew
   brew install vcluster
   ```
2. **Create a vcluster in a namespace:**

   ```sh
   kubectl create namespace dev-team
   vcluster create dev-vcluster -n dev-team
   ```
3. **Connect to the vcluster:**

   ```sh
   vcluster connect dev-vcluster -n dev-team
   # This updates your kubeconfig to point to the vcluster
   kubectl get nodes
   ```
4. **Deploy workloads in the vcluster:**

   ```sh
   kubectl apply -f my-app.yaml
   ```
5. **List and manage vclusters:**

   ```sh
   vcluster list
   vcluster delete dev-vcluster -n dev-team
   ```

***

## Best Practices

* Use separate namespaces for each vcluster to ensure isolation.
* Automate vcluster lifecycle (creation, deletion) in CI/CD pipelines for ephemeral environments.
* Monitor resource usage in the host cluster to avoid noisy neighbor issues.
* Use RBAC and network policies to restrict access between vclusters.
* Store vcluster configuration and manifests in Git for GitOps workflows.

***

## Common Pitfalls

* Overcommitting host cluster resources (CPU, memory) can impact all vclusters.
* Not cleaning up unused vclusters leads to resource waste.
* Assuming vcluster isolation is equivalent to physical cluster isolation (some host-level risks remain).
* Manual changes outside of Git in GitOps-managed environments.

***

## References

* [vcluster Official Docs](https://www.vcluster.com/docs/)
* [vcluster GitHub](https://github.com/loft-sh/vcluster)
* [Multi-Tenancy Patterns](https://kubernetes.io/docs/concepts/architecture/multitenancy/)
