Rancher Provisioning Internals
o deeply understand Rancher’s Cluster API (CAPI) integration, its v1/v2/v3 provisioning system, and how to debug provisioning issues, let's break this down step-by-step:
๐ง 1. Rancher Provisioning Internals Overview
Rancher supports multiple versions of cluster provisioning mechanisms internally, and each represents different architecture and capability changes over time:
๐ v1 Provisioning (Legacy - RKE1)
-
Used for: Rancher-managed clusters using RKE1 (Rancher Kubernetes Engine v1)
-
Implemented via:
Cluster,NodeTemplate,NodePoolCRDs -
Provisioning handled by: Rancher controller logic, not based on Cluster API
-
Where:
/v3/clusterAPI -
Cloud Drivers: Node drivers using Docker Machine (
rancher/machine)
๐ Debug:
-
Check logs of
rancherpod -
Look at
Cluster,NodePool, andNodeTemplatevia Rancher API or kubectl -
SSH and Docker Machine logs
๐ v2 Provisioning (CAPI-based – RKE2/K3s – Rancher 2.5+)
-
Used for: Rancher-managed clusters using RKE2 or K3s
-
Implemented via: Cluster API (CAPI) style resource hierarchy
-
Custom CRDs:
-
Cluster -
MachineDeployment→MachineSet→Machine -
RKECluster,RKEControlPlane,RKEBootstrap,MachineConfig
-
-
API Group:
provisioning.cattle.io/v1 -
Machine driver moved to:
rancher/system-agent, and provisioning handled by Fleet and CAPI
๐ Debug:
-
Check
cattle-cluster-agent,rancher-system-agent, andrancherpod logs -
Inspect CRDs:
-
Check the
planstatus inmachineinventory,machineinventoryselector, andmachineinventorybindingif Elemental is involved -
Events:
kubectl get events -A | grep <cluster-name>
๐ v3 Provisioning (Rancher 2.7+ – Cluster API Native)
-
Goal: Full Cluster API standard support with better plugability (more like upstream CAPI clusters)
-
Introduced with: Enhanced multi-cloud, bare-metal, and edge provisioning
-
Provisioning via:
Cluster APIupstream-compatible resources directly, notprovisioning.cattle.io
๐ ️ CRDs used:
-
Native
Clusterfromcluster.x-k8s.io -
MachineDeployment,Machine,KubeadmConfig,InfrastructureProviderCRs -
capi-<provider>components likecapi-aws,capi-vsphere,capi-openstack, etc.
๐ Debug:
-
Use upstream CAPI tools:
-
clusterctl describe cluster <name> -
kubectl get machines.cluster.x-k8s.io -A
-
-
Events and logs from the CAPI controllers
-
Rancher UI still wraps this but doesn't abstract away everything
๐ง What is CAPI in Rancher?
CAPI is an upstream Kubernetes project for declarative Kubernetes cluster lifecycle management. Rancher leverages and extends it with:
-
Bootstrap provider: RKE2Bootstrap or RKE1Bootstrap
-
Infrastructure provider: RancherMachineProviderConfig or external (AWS, vSphere)
-
Cluster & Control Plane CRDs
-
Integration with Fleet and System Agent for orchestration
Rancher Cluster Provisioning Debugging Guide (v2 & v3)
๐ Troubleshooting Flowchart (Text-Based)
[Start]
|
v
[1. Cluster stuck in "Provisioning"/"Waiting"]
|
v
[2. Get Cluster CRD Status]
|
v
kubectl get clusters.provisioning.cattle.io -A
kubectl describe cluster <name> -n <namespace>
|
v
[3. Check associated control plane + bootstrap + infra CRDs]
|
+--> kubectl get rkecontrolplanes -A
+--> kubectl get rkemachinepools -A
+--> kubectl get machineconfigs -A
|
v
[4. Check MachineDeployments and Machines]
|
+--> kubectl get machinedeployments.cluster.x-k8s.io -A
+--> kubectl get machines.cluster.x-k8s.io -A
|
v
[5. Check Plan Delivery / Agent Sync]
|
+--> kubectl get plan -A
+--> kubectl describe plan <name>
+--> kubectl logs -n cattle-system -l app=rancher-system-agent -f
|
v
[6. Check Cluster Agent Communication]
|
+--> kubectl logs -n cattle-system -l app=cattle-cluster-agent -f
|
v
[7. Check Fleet GitOps Bundle Errors]
|
+--> kubectl get bundles -A
+--> kubectl describe bundle <name>
|
v
[8. Check MachineInventory and Registration Tokens]
|
+--> kubectl get machineinventory -A
+--> kubectl get machinetemplate -A
|
v
[End or Loop to Specific Failing CRD]๐งช Sample Troubleshooting Script
# Set cluster namespace (usually cluster name in lowercase with random suffix)
CLUSTER_NS="fleet-default" # or find it dynamically using get clusters.provisioning.cattle.io
# 1. Get high-level cluster info
kubectl get clusters.provisioning.cattle.io -A
kubectl describe cluster <cluster-name> -n $CLUSTER_NS
# 2. Get CAPI cluster info (for v3 provisioning)
kubectl get cluster.cluster.x-k8s.io -A
# 3. Control plane and bootstrap components
kubectl get rkecontrolplanes -A
kubectl get rkemachinepools -A
kubectl get machineconfigs -A
# 4. Machine deployments and machines
kubectl get machinedeployments.cluster.x-k8s.io -A
kubectl get machines.cluster.x-k8s.io -A
kubectl describe machine <name> -n $CLUSTER_NS
# 5. Check Plan CRD
kubectl get plan -A
kubectl describe plan <plan-name>
# 6. Agent logs (machine plan application)
kubectl logs -n cattle-system -l app=rancher-system-agent -f
# 7. Cluster agent logs (communication)
kubectl logs -n cattle-system -l app=cattle-cluster-agent -f
# 8. Rancher manager logs
kubectl logs -n cattle-system -l app=rancher -f
# 9. Fleet GitOps troubleshooting
kubectl get bundles -A
kubectl describe bundle <bundle-name>
kubectl get gitrepos -A
# 10. Machine inventory and registration (esp. for Elemental)
kubectl get machineinventory -A
kubectl get machineinventorybinding -A
kubectl get machinetemplate -A๐งฐ Optional Tools
๐ Cluster API CLI: clusterctl
# Install
brew install clusterctl
# Describe cluster and see what is failing
clusterctl describe cluster <cluster-name> -n <namespace>๐งผ Common Cleanup Commands
# Delete stuck cluster
kubectl delete clusters.provisioning.cattle.io <cluster-name> -n $CLUSTER_NS --force --grace-period=0
# Force delete machine CRD
kubectl delete machine <name> -n <namespace> --force --grace-period=0✅ Summary by Provisioning Version
| Version | Engine | CRD Group | Notes |
|---|---|---|---|
| v1 | RKE1 | management.cattle.io/v3 | Legacy Docker Machine |
| v2 | RKE2 | provisioning.cattle.io/v1 | Rancher CAPI-style provisioning |
| v3 | RKE2 | cluster.x-k8s.io | Full upstream CAPI-native support |