Configuring Rancher Integration
The Rancher integration creates a seamless experience that enables self-service virtual cluster creation and management for teams already using Rancher to manage their Kubernetes fleet. Now you can provision and manage the entire lifecycle of virtual clusters in Rancher the same way you would any traditional Kubernetes cluster.
The Rancher integration enables organizations to:
- Unify management of virtual clusters and regular clusters within Rancher alongside each other.
- Enable virtual cluster self-service for Rancher users within guardrails defined by Rancher admins.
- Continue using Rancher for user management while syncing permissions between Rancher and vCluster Platform.
Prerequisites
Before you begin, make sure you have the following:
- A running vCluster Platform
- A running Rancher Server
- A Rancher API Bearer Token to allow the Platform to access and perform actions in Rancher
The Bearer Token to be used should have a long expiration or must be rotated using an external mechanism as it will be used for every call to the Rancher API
Setup
Install the Rancher extension
In the Rancher UI, click on the Extensions link in the left side menu, then click on the ellipsis menu on the top right and select Manage Repositories.
Click on on the right. Give the repository a name and enter
https://charts.loft.sh/
as the Index URL.Click on at the bottom.
Navigate back to the Extensions page and click on Available tab. Click on the extension named VCluster.Pro.
Now we'll add a label on the Rancher management cluster resource
management.cattle.io/v1 group
. In the left side nav menu, click on the Cluster Management link and then click the on the ellipsis button of the management cluster where Rancher is installed and then select the Edit Config option.Click on the Labels & Annotations row and click on . Finally, add
loft.sh/loft-hostname
for the label's key and your Platform hostname without the protocal prefix, e.g. my-vcluster-platform.dev
Configure the Platform
Now we'll add the Rancher object to the Platform configuration in order to set up a global Rancher integration. This enables the Platform to communicate with Rancher via its API and perform the necessary actions required for syncing. This also enables SSO, so you can login to the Platform via Rancher.
Log in to the Platform UI as an admin user and navigate to the Admin section using the menu on the left.
Edit the configuration by adding the Rancher object with the following properties:
- Inline Rancher Token
auth:
rancher:
host: your-rancher-instance
bearerToken: "your-rancher-token"
insecure: <true/false>Don't forget to change default valuesReplace
your-rancher-instance
with the address of your Rancher instance without protocol prefix, e.g. my-rancher.demo.devReplace
"your-rancher-token"
with the bearerToken to be used. Its usually of the format Access Key: Secret Key e.g."token-28kg6:gl5nqsq2hmxmdxr7fvcpfz2hh2krzvqff5w78kxr4tvc6r6x6s67t4"
For further configuration options, see the configuration reference and the Rancher configuration options.
- Save the changes to the configuration by clicking and wait for the platform to restart.
Connect Rancher Projects to Platform Projects
The Rancher integration can be enabled on a per-project basis. Subsequently, any virtual clusters within the project can be selectively imported into Rancher. Importing a virtual cluster means that it is available for use as a cluster within Rancher.
In the Platform UI, click on the Projects Navigator in the top left side menu and then switch to the Project for which you wish to enable the integration. Click on the Projects Navigator again and click on .
Click on Rancher and toggle the Enable Rancher Integration switch to enable synchronization for this project. Additional configuration options will appear.
Add the Rancher Project ID and Rancher Cluster ID of the Rancher project you want to connect. Note that those are different from the project name and cluster name. To retrieve those, you can either extract them from the URL in the Rancher dashboard (go to your project page, the cluster id has a
c-x-xxxx
format and the project id has ap-xxxx
format), or using the rancher CLI (select your cluster withrancher context switch
and thenrancher project list
will the output the project as<cluster-id>:<project-id>
).[Optional] Back in the Platform UI, toggle the Enable Member Synchronization switch if you wish to sync Rancher Project member roles into the Platform's Project member roles.
Click to save the Project settings.
To get the Rancher Cluster ID click on 'Cluster Management' in the left side menu in the Rancher UI, 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 'Cluster Management' screen, click on the desired cluster and then Projects/Clusters on the top left side of the screen. 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.
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 it in Rancher. Disabling the integration at the project level removes all virtual clusters from Rancher, so be careful when disabling at this level!
Configuration Options
The following configuration can be set on the projects.managementv1.loft.sh
resource.
enabled
required boolean false pro
Enabled indicates if the Rancher Project Integration is enabled for this project.
enabled
required boolean false 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 true pro
Enabled indicates whether to sync rancher project members to the loft project.
enabled
required boolean true 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 pro