Create & import a cluster using CAPI providers
This guide goes over the process of creating and importing CAPI clusters with a selection of the officially certified providers.
Keep in mind that most Cluster API Providers are upstream projects maintained by the Kubernetes open-source community.
Prerequisites
-
AWS
-
GCP GKE
-
Docker RKE2/Kubeadm
-
vSphere RKE2/Kubeadm
-
Rancher Manager cluster with Rancher Turtles installed
-
Cluster API Providers: you can find a guide on how to install a provider using the
CAPIProvider
resource here-
Infrastructure provider for AWS, this is an example of AWS provider installation, follow the provider documentation if some options need to be customized:
--- apiVersion: v1 kind: Namespace metadata: name: capa-system --- apiVersion: v1 kind: Secret metadata: name: aws namespace: capa-system type: Opaque stringData: AWS_B64ENCODED_CREDENTIALS: xxx --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: aws namespace: capa-system spec: type: infrastructure
-
If using RKE2 or Kubeadm, it’s required to have Bootstrap/Control Plane provider for RKE2(installed by default) or Bootstrap/Control Plane provider for Kubeadm, example of Kubeadm installation:
--- apiVersion: v1 kind: Namespace metadata: name: capi-kubeadm-bootstrap-system --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: kubeadm-bootstrap namespace: capi-kubeadm-bootstrap-system spec: name: kubeadm type: bootstrap --- apiVersion: v1 kind: Namespace metadata: name: capi-kubeadm-control-plane-system --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: kubeadm-control-plane namespace: capi-kubeadm-control-plane-system spec: name: kubeadm type: controlPlane
-
-
Rancher Manager cluster with Rancher Turtles installed
-
Cluster API Providers: you can find a guide on how to install a provider using the
CAPIProvider
resource here-
Infrastructure provider for GCP, this is an example of GCP provider installation, follow the provider documentation if some options need to be customized:
export GCP_B64ENCODED_CREDENTIALS=$( cat /path/to/gcp-credentials.json | base64 | tr -d '\n' )
--- apiVersion: v1 kind: Namespace metadata: name: capg-system --- apiVersion: v1 kind: Secret metadata: name: gcp namespace: capg-system type: Opaque stringData: GCP_B64ENCODED_CREDENTIALS: "${GCP_B64ENCODED_CREDENTIALS}" --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: gcp namespace: capg-system spec: type: infrastructure
-
-
You can follow the installation guide here
-
Rancher Manager cluster with Rancher Turtles installed
-
Cluster API Providers: you can find a guide on how to install a provider using the
CAPIProvider
resource here-
Infrastructure provider for vSphere, this is an example of vSphere provider installation, follow the provider documentation if some options need to be customized:
--- apiVersion: v1 kind: Namespace metadata: name: capv-system --- apiVersion: v1 kind: Secret metadata: name: vsphere namespace: capv-system type: Opaque stringData: VSPHERE_USERNAME: xxx VSPHERE_PASSWORD: xxx --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: vsphere namespace: capv-system spec: type: infrastructure
-
Bootstrap/Control Plane provider for RKE2(installed by default) or Bootstrap/Control Plane provider for Kubeadm, example of Kubeadm installation:
--- apiVersion: v1 kind: Namespace metadata: name: capi-kubeadm-bootstrap-system --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: kubeadm-bootstrap namespace: capi-kubeadm-bootstrap-system spec: name: kubeadm type: bootstrap --- apiVersion: v1 kind: Namespace metadata: name: capi-kubeadm-control-plane-system --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider metadata: name: kubeadm-control-plane namespace: capi-kubeadm-control-plane-system spec: name: kubeadm type: controlPlane
-
Create Your Cluster Definition
-
AWS EC2 RKE2
-
AWS EC2 Kubeadm
-
Docker RKE2
-
Docker Kubeadm
-
vSphere RKE2
-
vSphere Kubeadm
-
AWS EKS
-
GCP GKE
-
You can follow the installation guide here
-
You can follow the installation guide here
-
You can follow the installation guide here
-
You can follow the installation guide here
Before creating a vSphere+RKE2 workload cluster, it is required to have a VM template with the necessary RKE2 binaries and dependencies. The template should already include RKE2 binaries if operating in an air-gapped environment, following the tarball method. You can find additional configuration details in the CAPRKE2 repository.
To generate the YAML for the cluster, do the following:
export CLUSTER_NAME=cluster1
export NAMESPACE=capi-clusters
export CONTROL_PLANE_MACHINE_COUNT=1
export WORKER_MACHINE_COUNT=1
export VSPHERE_USERNAME: "<username>"
export VSPHERE_PASSWORD: "<password>"
export VSPHERE_SERVER: "10.0.0.1"
export VSPHERE_DATACENTER: "SDDC-Datacenter"
export VSPHERE_DATASTORE: "DefaultDatastore"
export VSPHERE_NETWORK: "VM Network"
export VSPHERE_RESOURCE_POOL: "*/Resources"
export VSPHERE_FOLDER: "vm"
export VSPHERE_TEMPLATE: "ubuntu-1804-kube-v1.17.3"
export CONTROL_PLANE_ENDPOINT_IP: "192.168.9.230"
export VSPHERE_TLS_THUMBPRINT: "..."
export EXP_CLUSTER_RESOURCE_SET: "true"
export VSPHERE_SSH_AUTHORIZED_KEY: "ssh-rsa AAAAB3N..."
export CPI_IMAGE_K8S_VERSION: "v1.31.0"
export KUBERNETES_VERSION=v1.31.4
-
Open a terminal and run the following:
curl -s https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/test/e2e/data/cluster-templates/vsphere-rke2.yaml | envsubst > cluster1.yaml
-
View cluster1.yaml and examine the resulting YAML file. You can make any changes you want as well.
The Cluster API quickstart guide contains more detail. Read the steps related to this section here.
-
Create the cluster using kubectl
kubectl create namespace ${NAMESPACE} kubectl apply -f cluster1.yaml
Before creating a vSphere+kubeadm workload cluster, it is required to have a VM template with the necessary kubeadm binaries and dependencies. The template should already include kubeadm, kubelet, and kubectl if operating in an air-gapped environment, following the image-builder project. You can find additional configuration details in the CAPV repository.
A list of published machine images (OVAs) is available here.
To generate the YAML for the cluster, do the following:
export CLUSTER_NAME=cluster1
export NAMESPACE=capi-clusters
export CONTROL_PLANE_MACHINE_COUNT=1
export WORKER_MACHINE_COUNT=1
export VSPHERE_USERNAME: "<username>"
export VSPHERE_PASSWORD: "<password>"
export VSPHERE_SERVER: "10.0.0.1"
export VSPHERE_DATACENTER: "SDDC-Datacenter"
export VSPHERE_DATASTORE: "DefaultDatastore"
export VSPHERE_NETWORK: "VM Network"
export VSPHERE_RESOURCE_POOL: "*/Resources"
export VSPHERE_FOLDER: "vm"
export VSPHERE_TEMPLATE: "ubuntu-1804-kube-vxxx"
export CONTROL_PLANE_ENDPOINT_IP: "192.168.9.230"
export VSPHERE_TLS_THUMBPRINT: "..."
export EXP_CLUSTER_RESOURCE_SET: "true"
export VSPHERE_SSH_AUTHORIZED_KEY: "ssh-rsa AAAAB3N..."
export CPI_IMAGE_K8S_VERSION: "v1.31.0"
export KUBERNETES_VERSION=v1.31.4
-
Open a terminal and run the following:
curl -s https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/test/e2e/data/cluster-templates/vsphere-kubeadm.yaml | envsubst > cluster1.yaml
-
View cluster1.yaml and examine the resulting YAML file. You can make any changes you want as well.
The Cluster API quickstart guide contains more detail. Read the steps related to this section here.
-
Create the cluster using kubectl
kubectl create namespace ${NAMESPACE} kubectl apply -f cluster1.yaml
To generate the YAML for the cluster, do the following:
export CLUSTER_NAME=cluster1
export NAMESPACE=capi-clusters
export WORKER_MACHINE_COUNT=1
export KUBERNETES_VERSION=v1.31.4
-
Open a terminal and run the following:
curl -s https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/test/e2e/data/cluster-templates/aws-eks-mmp.yaml | envsubst > cluster1.yaml
-
View cluster1.yaml and examine the resulting YAML file. You can make any changes you want as well.
The Cluster API quickstart guide contains more detail. Read the steps related to this section here.
-
Create the cluster using kubectl
kubectl create namespace ${NAMESPACE} kubectl apply -f cluster1.yaml
To generate the YAML for the cluster, do the following:
export CLUSTER_NAME=cluster1
export NAMESPACE=capi-clusters
export GCP_PROJECT=cluster-api-gcp-project
export GCP_REGION=us-east4
export GCP_NETWORK_NAME=default
export WORKER_MACHINE_COUNT=1
-
Open a terminal and run the following:
curl -s https://raw.githubusercontent.com/rancher/turtles/refs/heads/main/test/e2e/data/cluster-templates/gcp-gke.yaml | envsubst > cluster1.yaml
-
View cluster1.yaml and examine the resulting YAML file. You can make any changes you want as well.
The Cluster API quickstart guide contains more detail. Read the steps related to this section here.
-
Create the cluster using kubectl
kubectl create namespace ${NAMESPACE} kubectl apply -f cluster1.yaml
After your cluster is provisioned, you can check functionality of the workload cluster using
Remember that clusters are namespaced resources. These examples provision clusters in the |
Mark Namespace or Cluster for Auto-Import
To automatically import a CAPI cluster into Rancher Manager, there are 2 options:
-
Label a namespace so all clusters contained in it are imported.
-
Label an individual cluster definition so that it’s imported.
Labeling a namespace:
export NAMESPACE=default
kubectl label namespace $NAMESPACE cluster-api.cattle.io/rancher-auto-import=true
Labeling an individual cluster definition:
export CLUSTER_NAME=cluster1
export NAMESPACE=default
kubectl label cluster.cluster.x-k8s.io -n $NAMESPACE $CLUSTER_NAME cluster-api.cattle.io/rancher-auto-import=true