Create & Import Your First Cluster

This section will guide you through creating your first cluster and importing it into Rancher Manager. Two alternative methods for cluster provisioning are presented: using a GitOps workflow with Fleet and manually applying the manifests via kubectl.

Prerequisites

Provision a CAPI Workload Cluster

  • GitOps using Fleet

  • Manually using kubectl

Configure your Fleet repository

To simplify the process of cluster provisioning, in this tutorial we will be using a pre-configured example that you can find in the repository https://github.com/rancher/turtles/tree/main/examples. By inspecting the contents of this repository, you will find:

  1. A clusterclasses folder with a bunch of ClusterClass examples.

  2. An applications folder with a set of resources used for installing cluster dependencies such as CNIs via Fleet.

  3. A clusters/docker/rke2 folder with an example of a Docker cluster definition.

    If you prefer, you can create your own Fleet repository using the same base structure.

Use Rancher UI to add your Fleet repository

Now the cluster definitions are committed to a git repository they can be used to provision the clusters. To do this they will need to be imported into the Rancher Manager cluster (which is also acting as a Cluster API management cluster) using the Continuous Delivery feature (which uses Fleet).

  1. Go to Rancher Manager

  2. Select Continuous Delivery from the menu:

    sidebar

  3. Select App Bundles from the submenu:

    App Bundles

  4. Select fleet-local as the namespace from the top right and then click on the Create App Bundle button:

    Create App Bundle

  5. Select Git Repos as the App Bundle type

  6. In Step 1 of the App Bundle creation flow, give the new bundle a name and description

  7. In Step 2 of the App Bundle creation flow, set the repository URL to the HTTPS URL of the Fleet repo. You can find and copy the URL using GitHub:

    git clone url
  8. Change the branch name to main

  9. Add the following paths to specify which directories to deploy:

    examples/clusterclasses/docker/rke2
    examples/applications/lb/docker
    examples/clusters/docker/rke2

    Fleet paths configuration

  10. Click Next to move to Step 3 and ensure that the App Bundle will be deployed to the local cluster

  11. Click Next again to move to Step 4 and then click Create to complete creation of this App Bundle

  12. Wait for the App Bundle state to become active, at which point the cluster has been provisioned successfully

  13. Select Cluster Management from the menu

  14. Check your cluster has been imported

Apply the cluster resources

To create the cluster using kubectl, run the following commands:

  1. Open a terminal and apply the ClusterClass and related templates:

    kubectl apply -f https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/examples/clusterclasses/docker/rke2/clusterclass-docker-rke2.yaml
  2. Apply the load balancer configuration:

    kubectl apply -f https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/examples/applications/lb/docker/configmap.yaml
  3. Create the cluster:

    kubectl apply -f https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/examples/clusters/docker/rke2/cluster.yaml
  4. Watch the resources become ready:

    kubectl get clusters -w
  5. Select Cluster Management from the menu

  6. Check your cluster has been imported

Next Steps: Wait for the cluster to appear in the Rancher Dashboard

The cluster provisioned in this tutorial contains the cluster-api.cattle.io/rancher-auto-import label. This label will instruct Turtles to automatically import the cluster into Rancher. For more information please refer to Rancher Cluster Registration.