What is K3s?
K3s is a fully compliant Kubernetes distribution with the following characteristics:- Lightweight: Single binary under 100 MB
- Simple: Easy to install, manage, and upgrade
- Secure: Reasonable defaults with secure-by-default configuration
- Low Resource: Minimal CPU and memory requirements
K3s vs RKE2
Both distributions use the same provisioning API (provisioning.cattle.io/v1), but differ in:
| Feature | K3s | RKE2 |
|---|---|---|
| Target Use Case | Edge, IoT, Development | Production, Compliance |
| Binary Size | ~70 MB | ~200 MB |
| Default CNI | Flannel | Canal |
| Hardening | Standard | CIS Hardened |
| FIPS 140-2 | No | Yes |
| Configuration Path | /etc/rancher/k3s/ | /etc/rancher/rke2/ |
pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:22-27
Provisioning Architecture
K3s provisioning uses the same CAPR (Cluster API Provider Rancher) controllers as RKE2:- Machine Provision: Create infrastructure nodes via node drivers
- Bootstrap Controller: Install K3s via system agent
- RKE Planner: Configure K3s on nodes
- Machine Node Lookup: Associate machines with Kubernetes nodes
pkg/controllers/capr/controllers.go:38-61
Configuration Options
Basic K3s Cluster
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:11-99
K3s-Specific Settings
K3s configuration options inmachineGlobalConfig:
Disable Built-in Components:
pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:22-27
Use Cases
1. Edge Computing
K3s excels in edge deployments:- Low Resource Footprint: Run on small devices
- SQLite Backend: No external database required
- ARM Support: Native support for ARM64/ARM architectures
2. Development Environments
Quick cluster provisioning for development:- Fast Deployment: Minimal components, quick startup
- Single Node: All roles on one machine
- Easy Reset: Simple to recreate
3. CI/CD Pipelines
Ephemeral clusters for testing:- Fast Provisioning: Quick cluster creation/deletion
- Lightweight: Minimal overhead for test workloads
- Reproducible: Consistent environments
4. IoT Deployments
Kubernetes at the edge:- Low Power: Efficient on battery-powered devices
- Small Footprint: Limited storage requirements
- Offline Operation: Works without constant connectivity
Step-by-Step Provisioning
Select Kubernetes Version
Choose a K3s version (format:
v1.28.5+k3s1):- K3s versions are distinguished by the
+k3ssuffix - Available versions shown in Rancher UI cluster creation
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:20-24Configure Machine Pools
Define your node pools:Minimal Single-Node:Production HA Setup:Reference:
pkg/apis/provisioning.cattle.io/v1/cluster_types.go:144-149Apply Cluster Configuration
Create the cluster:Or use Rancher UI: Cluster Management → Create → Custom
Lightweight Deployment Strategies
Single-Node Cluster
Minimal configuration for development or edge:External Database
Use external database instead of embedded ETCD:Agent-Only Nodes
Scale with lightweight worker nodes:pkg/apis/provisioning.cattle.io/v1/cluster_types.go:198-210
Machine Configuration Examples
Low-Resource Configuration
For edge or development:Production Configuration
For production workloads:pkg/controllers/capr/machineprovision/args.go:288-336
Advanced Features
High Availability
HA K3s with embedded ETCD:Custom CNI
Replace default Flannel with Calico:pkg/apis/rke.cattle.io/v1/cluster_configuration_types.go:13-19
Secrets Encryption
Enable secrets encryption at rest:Performance Tuning
Resource Limits
Optimize for small devices:Disable Unused Features
Reduce overhead:Troubleshooting
Check K3s Service Status
On a cluster node:View Machine Logs
Common Issues
Single Node Not Ready: Ensure node has all three roles (etcd, controlPlane, worker) Out of Memory: Reduce max-pods or disable unused components Slow Performance: Check if sufficient CPU/memory allocated Reference: Machine provisioning troubleshooting atpkg/controllers/capr/machineprovision/args.go:80-202
Migration from RKE2
To migrate from RKE2 to K3s:- Export workloads from RKE2 cluster
- Create new K3s cluster with same Kubernetes version
- Update configuration paths (
/etc/rancher/k3sinstead of/etc/rancher/rke2) - Redeploy workloads to K3s cluster
- Update DNS/load balancer to point to K3s cluster
Next Steps
RKE2 Provisioning
Production-ready alternative to K3s
Machine Pools
Configure node groups
Edge Computing
Deploy K3s at the edge
Cluster Upgrades
Upgrade K3s versions