August 10, 2025

Rancher RKE 2 Deployment

Rancher Logo

RKE2 Installation Guide (Ubuntu, 3 Nodes: 1 Master, 2 Workers)

## Prerequisites

- Ubuntu 20.04+ on all nodes
- SSH access to all nodes
- Unique hostnames and static IPs
- Sudo privileges

## Node Roles

| Hostname   | Role    | IP Address      |
|------------|---------|-----------------|
| master-1   | Master  | `192.168.1.10`  |
| worker-1   | Worker  | `192.168.1.11`  |
| worker-2   | Worker  | `192.168.1.12`  |

## Pre-Configuration (All Nodes)

```bash

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget vim
sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab
sudo modprobe br_netfilter
echo 'net.bridge.bridge-nf-call-iptables=1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf

sudo sysctl -p

```

## Install RKE2 (Master Node)

```bash
curl -sfL https://get.rke2.io | sudo sh -
sudo systemctl enable rke2-server.service
sudo systemctl start rke2-server.service

```

### Get Join Token

```bash
sudo cat /var/lib/rancher/rke2/server/node-token
```

## Install RKE2 (Worker Nodes)

```bash
curl -sfL https://get.rke2.io | sudo sh -
sudo mkdir -p /etc/rancher/rke2/
echo "server: https://192.168.1.10:9345" | sudo tee /etc/rancher/rke2/config.yaml
echo "token: <MASTER_NODE_TOKEN>" | sudo tee -a /etc/rancher/rke2/config.yaml
sudo systemctl enable rke2-agent.service
sudo systemctl start rke2-agent.service
```

## Post-Configuration (Master Node)

```bash
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
kubectl get nodes
```

## Notes

- Replace IPs and hostnames as needed.
- Open required ports in firewall (9345, 6443, etc.).
- For more info: [RKE2 Docs](https://docs.rke2.io/)

## Configure Kubeconfig on Windows 11

1. **Download Kubeconfig File**

    - Copy `/etc/rancher/rke2/rke2.yaml` from the master node to your Windows machine (e.g., using WinSCP or `scp`):

      ```powershell
      scp user@192.168.1.10:/etc/rancher/rke2/rke2.yaml C:\Users\<YourUser>\.kube\config
      ```

2. **Edit Kubeconfig File**

    - Open `C:\Users\<YourUser>\.kube\config` in a text editor.
    - Change the `server:` address from `localhost` to the master node IP, e.g.:
      ```
      server: https://192.168.1.10:6443
      ```

3. **Install kubectl**

    - Download [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/) and add it to your PATH.

    - Verify installation:
      ```powershell
      kubectl version --client
      kubectl get nodes
      ```

4. **Install Helm**

    - Download [Helm](https://helm.sh/docs/intro/install/#from-script) for Windows.
    - Extract and add `helm.exe` to your PATH.
    - Verify installation:
      ```powershell
      helm version
      ```

5. **Test Connectivity**

    - Run:
      ```powershell
      kubectl get pods --all-namespaces
      helm list -A
      ```

**Tip:** Ensure your Windows machine can reach the master node IP and required ports are open. 

0 comments: