Feature Availability
RKE2 provisioning is controlled by therke2 feature flag:
pkg/features/feature.go:71-76
RKE2 Architecture
Cluster Components
RKE2 clusters provisioned by Rancher consist of:- Control Plane Nodes: Run Kubernetes API server, scheduler, and controller manager
- ETCD Nodes: Distributed database for cluster state (can be co-located with control plane)
- Worker Nodes: Run application workloads
Provisioning Flow
The provisioning process uses the CAPR (Cluster API Provider Rancher) framework:- Cluster Creation: Define cluster specification with
provisioning.cattle.io/v1API - Machine Provisioning: Node drivers create infrastructure VMs
- Bootstrap: Install RKE2 on nodes via system agent
- Cluster Configuration: Apply machine global config and chart values
- Ready State: Cluster becomes available for workloads
pkg/controllers/capr/controllers.go:38-61
Configuration Options
Cluster Specification
Key configuration fields for RKE2 clusters:pkg/apis/provisioning.cattle.io/v1/cluster_types.go:11-99
Machine Global Configuration
ThemachineGlobalConfig section accepts any RKE2 configuration option that would normally be placed in /etc/rancher/rke2/config.yaml:
- Networking: CNI selection (canal, calico, cilium)
- ETCD: Snapshot schedules, S3 backup configuration
- Security: Pod Security Admission, SELinux
- Services: Disable components, custom arguments
pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:22-27
Machine Pools
Machine pools define groups of nodes with common configuration: Required Fields:name: Unique identifier for the poolmachineConfigRef: Reference to node driver machine config
quantity: Number of nodes (ignored if autoscaling enabled)etcdRole: Run ETCD (must have min 1 node if enabled)controlPlaneRole: Run control plane (must have min 1 node if enabled)workerRole: Run workloadslabels: Kubernetes labels for nodestaints: Kubernetes taints for nodes
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:170-349
Upgrade Strategy
Control how nodes are upgraded during cluster updates:pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:81-112
Step-by-Step Provisioning Guide
Create Cloud Credentials
Store credentials for your infrastructure provider in Rancher.Navigate to Cluster Management → Cloud Credentials → CreateCredentials are stored as secrets in format:
namespace:secret-nameReference: pkg/apis/provisioning.cattle.io/v1/cluster_types.go:12-18Define Machine Configuration
Create a machine configuration for your node driver (e.g., Amazonec2Config, AzureConfig).Machine configs specify:
- Instance type/size
- Network configuration
- Storage volumes
- SSH keys
- Tags/labels
pkg/controllers/capr/machineprovision/args.go:80-202Monitor Provisioning
Track cluster creation progress:
- Provisioning: Infrastructure nodes being created
- Bootstrapping: RKE2 installation in progress
- Configuring: Applying cluster configuration
- Active: Cluster ready for workloads
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:483-530Advanced Configuration
ETCD Snapshots
Configure automatic ETCD backups:pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:57-60
Machine Selector Configuration
Apply configuration to nodes matching labels:pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:29-34
Private Registry Configuration
Use private container registries:pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:51-55
Machine Health Checks
Rancher automatically creates MachineHealthChecks for RKE2 clusters:- NodeStartupTimeout: Maximum time for node to join (default: 10 minutes)
- UnhealthyNodeTimeout: Time before marking node unhealthy
- MaxUnhealthy: Number of unhealthy nodes tolerated before remediation
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:283-316
Autoscaling
Enable cluster autoscaling for worker pools (Rancher Prime feature):pkg/apis/provisioning.cattle.io/v1/cluster_types.go:271-281
Troubleshooting
Check Machine Status
View machine provisioning status:View Provisioning Logs
Check machine provision job logs:Common Issues
Cloud Credential Errors: Verify credentials have required permissions for:- VM creation/deletion
- Network configuration
- Storage volume management
pkg/controllers/capr/machineprovision/args.go:223-257
Next Steps
Machine Pools
Advanced machine pool configuration
ETCD Snapshots
Backup and restore cluster state
Cluster Upgrades
Upgrade RKE2 cluster versions
K3s Provisioning
Lightweight alternative to RKE2