Create a cluster using Fleet

This section will guide you through creating a cluster that utilizes ClusterClass using a GitOps workflow with Fleet.

This guide uses the examples repository.

Prerequisites

Configure Rancher Manager

Configure your Fleet repository

To simplify the process of cluster provisioning, we will be using a series of pre-configured examples 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. An applications folder for additional apps that can be deployed using Fleet (CNI, CSI, CPI).

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

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

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

The cluster definitions will 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).

There are 2 options to provide the configuration. The first is using the Rancher Manager UI and the second is by applying some YAML to your cluster. Both are covered below.

Import Cluster and ClusterClass Definitions

  • Using the Rancher Manager UI

  • Manually using kubectl

  1. Go to Rancher Manager

  2. Select Continuous Delivery from the menu: sidebar

  3. Select fleet-local as the namespace from the top right namespace

  4. Select Git Repos from the sidebar

  5. Click Add Repository

  6. Enter clusters as the name

  7. Get the HTTPS clone URL from your git repo git clone url

  8. Add the URL into the Repository URL field

  9. Change the branch name to main

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

    Fleet paths configuration

    examples/clusterclasses/docker/rke2
    examples/applications/cni/calico
    examples/applications/lb/docker
    examples/clusters/docker/rke2
  11. Click Next

  12. Click Create

  13. Click on the clusters name

  14. Watch the resources become ready

  15. Select Cluster Management from the menu

  16. Check your cluster has been imported

  1. Get the HTTPS clone URL from your git repo

  2. Create a new file called repo.yaml

  3. Add the following contents to the new file:

    apiVersion: fleet.cattle.io/v1alpha1
    kind: GitRepo
    metadata:
      name: clusters
      namespace: fleet-local
    spec:
      branch: main
      repo: https://github.com/rancher/turtles.git
      paths:
        - examples/clusterclasses/docker/rke2
        - examples/applications/cni/calico
        - examples/applications/lb/docker
        - examples/clusters/docker/rke2
      targets: []
  4. Apply the file to the Rancher Manager cluster using kubectl:

    kubectl apply -f repo.yaml
  5. Go to Rancher Manager

  6. Select Continuous Delivery from the sidebar

  7. Select fleet-local as the namespace from the top right

  8. Select Git Repos from the sidebar

  9. Click on the clusters name

  10. Watch the resources become ready

  11. Select Cluster Management from the menu

  12. Check your cluster has been imported