Rancher on Small RKE2 Cluster
This guide demonstrates how to deploy a small RKE2 cluster with Rancher installed, designed for on-premises environments with three pre-configured servers.
Overview
Small RKE2 Cluster for Rancher
This configuration deploys a lightweight RKE2 cluster consisting of two control-plane nodes and one worker node. It uses NGINX ingress and Rancher for Kubernetes management. This setup is ideal for development and small-scale production environments.
RKE2 Cluster Installation
Prerequisites
- Three servers with at least 4 CPUs and 8 GB of RAM.
- Ubuntu 22.04 or CentOS 8 installed on each server.
- Networking configured to allow communication between nodes.
Step 1: Install RKE2 on Control Plane Nodes
- SSH into each of the two control-plane nodes.
- Install RKE2:
curl -sfL https://get.rke2.io | sh - systemctl enable rke2-server.service systemctl start rke2-server.service
- Copy the
/etc/rancher/rke2/rke2.yaml
file from the first control-plane node to your local machine for kubectl access.
Step 2: Install RKE2 on the Worker Node
- SSH into the worker node.
- Install RKE2 in agent mode:
curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE="agent" sh - systemctl enable rke2-agent.service systemctl start rke2-agent.service
- Join the worker to the cluster by setting the server address and token in
/etc/rancher/rke2/config.yaml
:server: https://<control-plane-ip>:9345 token: <cluster-token>
- Restart the RKE2 agent:
systemctl restart rke2-agent.service
Ingress NGINX Deployment
Deploy the NGINX ingress controller using Helm:
Create the Namespace
kubectl create namespace ingress-nginx
Helm Chart Deployment
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.service.type=LoadBalancer
Rancher Deployment
Create the Namespace
kubectl create namespace cattle-system
Helm Chart Deployment
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm repo update
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=rancher.your-domain.com \
--set ingress.tls.source=letsEncrypt \
--set letsEncrypt.email=admin@your-domain.com \
--set letsEncrypt.environment=production
Testing and Validation
Accessing Rancher
Verify the Rancher pods:
kubectl get pods -n cattle-system
Access Rancher via the hostname you specified:
https://rancher.your-domain.com
Testing NGINX Ingress
Deploy a sample application and verify ingress access using the LoadBalancer endpoint.