Rancher Integration Guide
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 vCluster.Pro 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.Pro
Prerequisites
Before you begin, make sure you have the following:
- A running vCluster.Pro Platform
- A running Rancher Server
- A Rancher API Bearer Token to allow the vCluster.Pro 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 vCluster.Pro 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 vCluster.Pro platform hostname without the protocal prefix, e.g. my-vcluster-platform.dev
Configure vCluster.Pro Platform
Now we'll add the Rancher object to the vCluster.Pro Platform configuration in order to set up a global Rancher integration. This enables the vCluster.Pro 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 vCluster.Pro platform via Rancher.
- Log in to the vCluster.Pro 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 vCluster.Pro 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 vCluster.Pro 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 vCluster.Pro platform, 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.
- [Optional] Back in the vCluster.Pro platform UI, toggle the Enable Member Synchronization switch if you wish to sync Rancher Project member roles into the vCluster.Pro 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.
Using The Integration
After configuring the Rancher integration, you can now create and delete virtual clusters from the Rancher UI. Additionally, you can also access the vCluster.Pro Platform directly from the Rancher UI.
Creating a virtual cluster
- In the Rancher UI, click on .
- Enter a name for the virtual cluster and select the vCluster.Pro Project in which you wish to create the virtual cluster. Only projects which have the Rancher Integration enabled would be displayed in the list.
- Click which will redirect you to the vCluster.Pro Platform to complete the creation process. At this point, you can optionally select a template and click and then click on the Rancher configuration tab and slide the Add to Rancher toggle to enabled. Click to finish creating the virtual cluster.
- Navigate back to the Rancher UI and you should see the newly created virtual cluster available and in Activestate.
Deleting a virtual cluster
- In the Rancher UI, click on the Delete icon for the virtual cluster you want to delete.
- You will be redirected to the platform's VirtualClusterInstance Page for confirmation.
- Click on the to confirm. The virtual cluster will be deleted from Rancher.
Importing virtual clusters into Rancher
Once a project has Rancher integration enabled, virtual clusters within that project are eligible to be synced into Rancher. You can enable virtual cluster import into Rancher during the virtual cluster creation step, or by enabling this feature on existing virtual clusters.
- During Virtual Cluster Creation
- On Existing Virtual Cluster
- From the Projects Navigator in the left hand pane, switch to the desired Project and click on Virtual Clusters. Then click .
- In the popup, optionally select the virtual cluster template, then click the button.
- Click the Rancher configuration tab and slide the Add to Rancher toggle to enabled.
- Finish configuring anything else you'd like on your virtual cluster, then click.
- From the Projects Navigator in the left hand pane, switch to the desired Project and click on Virtual Clusters
- Find your desired virtual cluster in the virtual cluster list and slide the Add to Rancher toggle to enabled.
You can disable the Rancher integration per virtual cluster or per project 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.
rancher
required object
RancherIntegration holds information about Rancher Integration
rancher
required object enabled
required boolean false
Enabled indicates if the Rancher Project Integration is enabled for this project.
enabled
required boolean false projectRef
required object
ProjectRef defines references to rancher project, required for syncMembers and syncVirtualClusters.syncMembers
projectRef
required object importVirtualClusters
required object
ImportVirtualClusters defines settings to import virtual clusters to Rancher on creation
importVirtualClusters
required object roleMapping
required object
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 syncMembers
required object
SyncMembers defines settings to sync Rancher project members to the loft project
syncMembers
required object enabled
required boolean true
Enabled indicates whether to sync rancher project members to the loft project.
enabled
required boolean true roleMapping
required object
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