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

  1. SSH into each of the two control-plane nodes.
  2. Install RKE2:
    curl -sfL https://get.rke2.io | sh -
    systemctl enable rke2-server.service
    systemctl start rke2-server.service
    
  3. 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

  1. SSH into the worker node.
  2. 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
    
  3. 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>
    
  4. 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

  1. Verify the Rancher pods:

    kubectl get pods -n cattle-system
    
  2. 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.


References