Using the Rancher Integration
Once Rancher is configured on vCluster Platform, virtual clusters can be imported into Rancher and started using as a cluster in Rancher. In order to enable this integration on each virtual cluster, the vCluster Platform project must be enabled with the Rancher integration first.
Enable Rancher Integration on a vCluster Platform project
Limitations
Only one Rancher project can be connected to one vCluster Platform project. You should not configure the Rancher project to multiple vCluster Platform projects as the integration will not work if you do so.
Using the UI
Before being able to enable virtual clusters with the Rancher integration, it must be enabled on the project. When vCluster Platform projects are enabled with Rancher integration, a label loft.sh/loft-project-name: <VCLUSTER_PLATFORM_PROJECT_NAME>
is added to the Rancher project resource.
In the settings of a project, click on Rancher and toggle the Enable Rancher Integration switch to enable synchronization for this project. Additional configuration options will appear.
Input the Rancher Project ID and Rancher Cluster ID of the Rancher project you want to connect. Note that these are the IDs and are different from the project name and cluster name. The cluster ID has a
c-x-xxxx
format and the project ID has ap-xxxx
format.[Optional] Toggle the Enable Member Synchronization switch if you wish to sync the Rancher project member roles into vCluster Platform's project member roles.
Click to save the vCluster Platform project settings.
To find the Rancher Cluster ID, in the Rancher UI, click on 'Cluster Management' in the left side menu, and then select the desired cluster, click on the ellipsis button on the right side and select View YAML. The metadata.name
is the Cluster ID.
To get the Rancher Project ID, in the Rancher UI, click on 'Cluster Management' in the left side menu, click on the cluster that has the project you want to connect to. In the cluster explorer, click on Projects/Namespaces in the cluster navigation. Click the ellipsis button on the right side of the desired project name and select the View YAML option. The metadata.name
is the Rancher Project ID.
On the Project Resource
If you are creating a project resource into vCluster Platform directly, you can configure the Rancher integration directly on the projects.managementv1.loft.sh
resource.
enabled
required boolean pro
Enabled indicates if the Rancher Project Integration is enabled for this project.
enabled
required boolean proprojectRef
required object pro
ProjectRef defines references to rancher project, required for syncMembers and syncVirtualClusters.syncMembers
projectRef
required object proimportVirtualClusters
required object pro
ImportVirtualClusters defines settings to import virtual clusters to Rancher on creation
importVirtualClusters
required object proroleMapping
required object pro
RoleMapping indicates an optional role mapping from a rancher project role to a rancher cluster role. Map to an empty role to exclude users and groups with that role from
being synced.
roleMapping
required object prosyncMembers
required object pro
SyncMembers defines settings to sync Rancher project members to the loft project
syncMembers
required object proenabled
required boolean pro
Enabled indicates whether to sync rancher project members to the loft project.
enabled
required boolean proroleMapping
required object pro
RoleMapping indicates an optional role mapping from a rancher role to a loft role. Map to an empty role to exclude users and groups with that role from
being synced.
roleMapping
required object proManaging Virtual Clusters in Rancher UI
Creating a virtual cluster in the Rancher UI
In the Rancher home page, click on the button.
Enter a name for the virtual cluster and select the Rancher project in which you wish to create the virtual cluster. Only those projects which have the Rancher Integration enabled are displayed in the list.
Click the button which will take you to the Create VirtualClusterInstance page in the vCluster Platform to get ready to create a virtual cluster.
Click the Rancher configuration tab.
Slide the Add to Rancher toggle to enable.
Click on the button once you have configured the rest of the virtual cluster as per your preference.
Navigate back to the Rancher UI and the virtual cluster should be available and in Active state.
Deleting a virtual cluster in the Rancher UI
In the Rancher home page, click on the Delete icon for the virtual cluster you want to delete.
You will be re-directed to the VirtualClusterInstance Page in the vCluster Platform UI for confirmation.
Click on the to confirm in the vCluster Platform UI. The virtual cluster will be deleted from Rancher.
Importing Virtual Clusters into Rancher through vCluster Platform UI
Once a vCluster Platform project has the Rancher integration enabled, virtual clusters within that project are eligible to be synced into Rancher as an imported cluster in Rancher UI. In the vCluster Platform UI, you can enable virtual cluster import into Rancher during the virtual cluster creation step, or by enabling this feature on existing virtual clusters.
If the project does not have Rancher integration enabled, you will not see the "Add to Rancher" options in the virtual cluster configuration.
- During Virtual Cluster Creation
- On Existing Virtual Cluster
In the vCluster Platform UI, select a project that has Rancher integration enabled.
Click on Virtual Clusters and the button.
In the popup, optionally select the virtual cluster template, then click the button.
Click the Rancher configuration tab.
Slide the Add to Rancher slider to enabled.
Finish configuring anything else you'd like on your virtual cluster, then click the button. The virtual cluster is created in vCluster Platform and imported into Rancher.
In the vCluster Platform UI, select a project that has Rancher integration enabled.
Find your desired virtual cluster in the virtual cluster list. Slide the Add to Rancher slider to import the virtual cluster into Rancher.
Hiding Nodes in Rancher
Since virtual clusters are not using physical nodes, you can hide the nodes from Rancher in order for the virtual nodes to not be counted in your Rancher node count. In order to hide the nodes of your virtual cluster, you need to enable our Rancher nodeless plugin on the virtual cluster.
Add the plugin to your vcluster.yaml
configuration.
plugins:
rancher:
image: ghcr.io/loft-sh/rancher-nodeless-plugin:0.0.3
You can enforce that all virtual clusters enable the plugin by enforcing template usage in the project.
Disabling Rancher Integration
You may disable the Rancher integration at a per virtual cluster or per project level by toggling the same sliders used to enable it. Disabling the integration at the virtual cluster level simply removes the virtual cluster from the Rancher UI, but the virtual cluster is still running.
Disabling the integration at the project level removes all virtual clusters from Rancher, so be careful when disabling at this level.