Virtual Cluster Templates
Virtual Cluster Templates can be used to create different virtual cluster profiles or set default options for virtual clusters in connected clusters.
Workflows
Create a Virtual Cluster Template
- UI
- kubectl
Navigate to Virtual Clusters > Virtual Cluster Templates. Click on the 'Add Virtual Cluster Template' button.
In the view you can modify the following sections:
- Configuration: the default virtual cluster metadata, version and values that should be used to create a new virtual cluster. In addition, you can define apps here that should get deployed into the virtual cluster on creation. You can also specify in which namespaces those apps should get deployed.
- Space Template: if a new space is created for the virtual cluster, this is the space template that is used to create the space.
- Access To Virtual Cluster Template: additional users and teams that should be able to access this virtual cluster template in addition to all existing RBAC rules
Create a virtual-cluster-template.yaml
in the following form:
apiVersion: storage.loft.sh/v1
kind: VirtualClusterTemplate
metadata:
name: my-virtual-cluster-template
spec:
template:
helmRelease:
chart:
version: 0.4.0
values: |-
# Additional helm values for the virtual cluster
# Loft will automatically add the correct service CIDR
# and k3s version to the helm values upon deployment
storage:
size: 5Gi
# syncer:
# If you don't want to sync ingresses from the virtual cluster to
# the host cluster uncomment the next lines
# extraArgs: ["--disable-sync-resources=ingresses"]
apps:
- name: my-app
namespace: default
spaceTemplateRef:
name: my-space-template
access: []
Then apply the virtual cluster template to the cluster where Loft was installed with:
kubectl apply -f virtual-cluster-template.yaml
Use a Virtual Cluster Template
You can create a virtual cluster from a template either through the Loft UI or the CLI.
- UI
- CLI
Navigate to virtual clusters and click on the 'Create Virtual Cluster' button. In the drawer you can select a virtual cluster template or based on the cluster default a template will be preselected automatically.
Afterwards you can still change the desired virtual cluster configuration and press 'Create' to create the virtual cluster.
You can use the flag --template
to select a virtual cluster template to apply. For example, if you want to create a new virtual cluster with the template my-virtual-cluster-template
the command would look like this:
loft create vcluster my-vcluster --template my-virtual-cluster-template
Based on the target cluster configuration it might be possible that a template will be applied even though no --template
is supplied.
Set Default Virtual Cluster Template
Navigate to the Clusters view and click on 'Edit'. Select a virtual cluster template that should be used as default template for creating new virtual clusters in that specific connected cluster. Then press update to apply the changes.
Delete Virtual Cluster Templates
You can either delete a virtual cluster template through the Loft UI or use kubectl. Deleting a virtual cluster template will not delete any virtual clusters that were created by this template.
- UI
- kubectl
Navigate to Virtual Clusters > Virtual Cluster Templates. Then click on the 'Delete' button.
Delete the virtual cluster template my-virtual-cluster
by running the following command in the cluster where Loft is installed in:
kubectl delete virtualclustertemplates my-virtual-cluster