Skip to main content
Version: 2.3

Virtual Clusters

A virtual cluster is a fully functional Kubernetes cluster that runs inside the namespace of another Kubernetes cluster (host cluster). Virtual clusters are very useful if you are hitting the limits of namespaces and do not want to make special exceptions to the multi-tenancy configuration of the underlying cluster, e.g. a user needs their own CRD or user needs pods from 2 namespaces to communicate with each other but your standard NetworkPolicy does not allow this, then a virtual cluster may be perfect for this user.

Working with Virtual Clusters

Unlike "real" clusters, virtual clusters are much more lightweight and much faster to spin up and tear down again.

Create Virtual Clusters

To create a virtual cluster using Loft CLI, run:

loft create vcluster [vcluster-name]
Kube-Context

Running loft create vcluster will automatically add a kube-context to your kube-config file, so you can immediately run kubectl commands right after creating a virtual cluster.

Delete Virtual Clusters
loft delete vcluster [vcluster-name]
Kube-Context

Deleting virtual clusters with Loft CLI has the advantage that Loft CLI will also delete the kube-context for this virtual cluster from your local kube-config file to keep everything cleaned up.

List Virtual Clusters

Run this command using Loft CLI to get a list of all virtual clusters you have access to across all clusters:

loft list vclusters
Kube-Context

If you want to retrieve a kube-context for any of your virtual clusters, run:

loft use vcluster [vcluster-name]
Control Access To Virtual Cluster

To give someone access to a virtual cluster using Loft CLI, run:

loft share vcluster [optional:name]

Configuration

Virtual Cluster Template

JSONPath in VirtualCluster CRD:
 metadata.annotations["loft.sh/virtual-cluster-template"] (type: string)

Metadata

Name

JSONPath in VirtualCluster CRD:
 metadata.name (type: string)

Namespace

JSONPath in VirtualCluster CRD:
 metadata.namespace (type: string)

Labels

JSONPath in VirtualCluster CRD:
 metadata.labels (type: map[string]string)

Annotations

JSONPath in VirtualCluster CRD:
 metadata.annotations (type: map[string]string)

Advanced Options

Version

JSONPath in VirtualCluster CRD:
 spec.helmRelease.chart.version (type: string)

Helm Values

JSONPath in VirtualCluster CRD:
 spec.helmRelease.values (type: {})

Apps

Namespaces For Apps

Access To Virtual Cluster

JSONPath in VirtualCluster CRD:
 spec.access (type: Access[])

CRDs

VirtualCluster

apiVersion
string

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

kind
string

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

object (io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta)

ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.

object (com.github.loft-sh.agentapi.pkg.apis.loft.cluster.v1.VirtualClusterSpec)
object (com.github.loft-sh.agentapi.pkg.apis.loft.cluster.v1.VirtualClusterStatus)
{
  • "apiVersion": "string",
  • "kind": "string",
  • "metadata": {
    },
  • "spec": {
    },
  • "status": {
    }
}