This guide shows how to build a highly available, three-node Rancher RKE2 Kubernetes cluster by hand. All three servers run the control plane and embedded etcd. The steps above give the basic sequence. The sections below explain each stage, fix several commands that fail or are out of date, and add the firewall ports, verification checks and troubleshooting steps you need to get a working cluster.
https://gist.github.com/devops-school/d9dfa33093499cbde0be46418ee646c4What you are building
RKE2 (also called RKE Government) is Rancher's Kubernetes distribution. It focuses on security and compliance. Each server node runs the API server, scheduler, controller manager and an embedded etcd member. The cluster in this guide has three server nodes, so etcd keeps quorum when any one node fails. Three nodes tolerate one failure. Always use an odd number of servers.
The first server initialises the cluster. The second and third servers join it through the supervisor port 9345 on a fixed registration address. In the example above, that address is the DNS name rancher.apex.dell.com. Every node uses the same shared token.
| Item | Example value | Purpose |
|---|---|---|
| Node 1 | rke2node1.apex.dell.com | Initialises the cluster |
| Nodes 2 and 3 | rke2node2 / rke2node3 | Join as additional servers |
| Registration address | rancher.apex.dell.com | DNS name or load balancer in front of the servers |
| Shared token | Long random string | Authenticates nodes joining the cluster |
Prerequisites and required ports
- Three Linux hosts on a supported distribution, such as SLES, RHEL-compatible or Ubuntu. Each needs at least 2 CPUs and 4 GB RAM, and SSD storage is strongly recommended for etcd.
- A unique hostname on every node. Alternatively, set
node-nameinconfig.yaml. Duplicate names stop a node from joining. - Time synchronised on every node with chrony or NTP. Clock skew breaks etcd and TLS.
- A DNS record or load balancer for the registration address that resolves to node 1 before the other nodes join.
- Root access on every node.
Instead of disabling the firewall completely, you can open only the ports RKE2 needs between the nodes. These are the ports for a default installation, which uses the Canal CNI:
| Port | Protocol | Used by |
|---|---|---|
| 6443 | TCP | Kubernetes API server |
| 9345 | TCP | RKE2 supervisor (node registration) |
| 10250 | TCP | kubelet |
| 2379-2381 | TCP | etcd client, peer and metrics |
| 8472 | UDP | Canal/Flannel VXLAN |
| 9099 | TCP | Canal health checks |
| 30000-32767 | TCP | NodePort services |
Note: If you use a CNI other than Canal, such as Cilium or Calico, check that CNI's own port requirements as well.
Corrected commands from the example
Most of the steps above work as written. A few lines will fail or mislead. Here are the corrected versions.
Installing a specific version. In the original, |\ escapes the space after the pipe. The shell then tries to run a command whose name starts with a space, so the install fails. Put the variable directly before sh. Version strings look like v1.xx.y+rke2r1. Check the RKE2 releases page for the exact value you want.
# latest stable release
curl -sfL https://get.rke2.io | sh -
# pinned version (replace with a real release tag)
curl -sfL https://get.rke2.io | INSTALL_RKE2_VERSION="v1.xx.y+rke2r1" sh -
# or follow a release channel
curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=stable sh -Code language: PHP (php)
Disabling swap permanently. swapoff -a turns swap off only until the next reboot. swap.target is a static unit, so systemctl disable on it usually has no effect. Comment out the swap entries in /etc/fstab instead:
swapoff -a
sed -i.bak '/\sswap\s/ s/^/#/' /etc/fstab
free -h # Swap line should show 0BCode language: PHP (php)
Where to start nodes 2 and 3. The original says to run systemctl enable --now rke2-server.service "on the first node" for the second and third nodes. That is wrong. Run it on node 2 and on node 3, one node at a time.
Checking cluster health. kubectl get componentstatuses has been deprecated since Kubernetes 1.19 and gives unreliable results. Use the API server readiness endpoint and pod status instead. The verification section below shows how.
AppArmor. RKE2 runs with AppArmor enabled, so you do not need to disable it. The RKE2 documentation does recommend turning off firewalld, or opening the ports in the table above. If NetworkManager is active, configure it to ignore the CNI interfaces.
Complete configuration for each node
First, generate a strong token once and reuse it on all three nodes. Do not use my-shared-secret in a real cluster.
openssl rand -hex 32
Node 1 uses /etc/rancher/rke2/config.yaml. It has no server: line, because node 1 bootstraps the cluster:
token: <paste-generated-token>
node-name: rke2node1 # optional if hostnames are already unique
tls-san:
- rancher.apex.dell.com
- rke2node1.apex.dell.com
- rke2node2.apex.dell.com
- rke2node3.apex.dell.comCode language: CSS (css)
Nodes 2 and 3 use the same /etc/rancher/rke2/config.yaml path, plus the server: line. Change node-name on each node.
server: https://rancher.apex.dell.com:9345
token: <paste-generated-token>
node-name: rke2node2 # rke2node3 on the third node
tls-san:
- rancher.apex.dell.com
- rke2node1.apex.dell.com
- rke2node2.apex.dell.com
- rke2node3.apex.dell.comCode language: PHP (php)
tls-san adds extra names to the API server certificate. That lets clients connect through the shared DNS name or a load balancer without certificate errors. Every name or IP you plan to use in a kubeconfig must be in this list.
Note: If you do not set token on node 1, RKE2 generates one. You can read it from /var/lib/rancher/rke2/server/node-token and copy it into the config files on nodes 2 and 3.
Starting and joining the servers
- On node 1, run
systemctl enable --now rke2-server.service. The first start pulls images and can take several minutes. - Watch progress with
journalctl -u rke2-server -funtil the API server is up and node 1 showsReady. - Point the registration DNS name at node 1, or add node 1 to the load balancer for ports 9345 and 6443.
- On node 2, run
systemctl enable --now rke2-server.service. Wait untilkubectl get nodesshows itReady. - Repeat on node 3. Joining one server at a time keeps etcd membership changes safe.
- Add nodes 2 and 3 to the round-robin DNS record or load balancer pool so the registration address survives the loss of node 1.
Verifying the cluster
On any server, set up kubectl and check the cluster. The kubectl binary is written to /var/lib/rancher/rke2/bin the first time the service starts, so this step only works after the server is running.
export PATH=$PATH:/var/lib/rancher/rke2/bin
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
kubectl get nodes -o wide
kubectl get --raw='/readyz?verbose'
kubectl get pods -ACode language: JavaScript (javascript)
Healthy output shows all three nodes with STATUS set to Ready, each with control-plane and etcd roles. The /readyz check should end with readyz check passed. Every pod in kube-system should be Running or Completed.
To manage the cluster from a workstation, copy /etc/rancher/rke2/rke2.yaml. In the copy, change server: https://127.0.0.1:6443 to https://rancher.apex.dell.com:6443. Keep the file private, because it holds cluster-admin credentials.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
Node 2 or 3 hangs at start, with connection refused on 9345 in the logs | Firewall, or the DNS name not resolving to a running server | Open 9345/6443 and test with curl -k https://rancher.apex.dell.com:9345/ping |
token CA hash does not match or unauthorized | Different token on the joining node | Use exactly the same token as node 1 |
duplicate hostname error | Two nodes share a hostname | Set unique hostnames or node-name |
| x509 error when using kubectl remotely | Name not in tls-san | Add the name and restart rke2-server on every server |
Node stays NotReady | CNI pods failing or VXLAN port blocked | Check kubectl get pods -n kube-system and open UDP 8472 |
If a join fails and you need to start that node again from scratch, run the uninstall script on it: /usr/local/bin/rke2-uninstall.sh, or /opt/rke2/bin/rke2-uninstall.sh on systems where /usr/local is read-only. Then repeat the steps.
Best practices
- Pin the RKE2 version on all nodes so they stay identical, and upgrade one server at a time.
- Put a TCP load balancer for 9345 and 6443 in front of the servers. It is more reliable than round-robin DNS.
- Keep the etcd snapshots that RKE2 takes automatically and copy them off the nodes. They are stored under
/var/lib/rancher/rke2/server/db/snapshots. - Add worker nodes with
rke2-agent.serviceand the sameserverandtokensettings, so the servers can be kept for the control plane. - Keep
/etc/rancher/rke2/config.yamland the token out of public repositories.
Frequently asked questions
How many server nodes does an RKE2 HA cluster need?
At least three, and always an odd number, because embedded etcd needs a majority to keep quorum. Three servers tolerate the loss of one node.
What is port 9345 used for in RKE2?
It is the RKE2 supervisor port. New server and agent nodes use it to register with the cluster. It must be reachable on the registration address from every joining node.
Where is the kubeconfig file for RKE2?
RKE2 writes it to /etc/rancher/rke2/rke2.yaml on each server. It points to 127.0.0.1:6443, so before using it remotely, change the server address to a name listed in tls-san.
Do I have to disable firewalld to run RKE2?
The RKE2 documentation recommends disabling firewalld. If your security policy requires a host firewall, you can instead open the required ports between nodes: 6443, 9345, 10250, 2379-2381, UDP 8472 and the NodePort range.
Why does kubectl get componentstatuses show errors on RKE2?
The componentstatuses API has been deprecated since Kubernetes 1.19 and does not reliably report the health of modern control planes. Use kubectl get --raw='/readyz?verbose' and kubectl get pods -A instead.
Related tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals
A valuable addition would be guidance on post-installation cluster validation. Successfully bringing up a three-node RKE2 cluster is only the beginning; it’s equally important to verify node readiness, network communication, DNS resolution, storage functionality, and workload scheduling before considering the cluster production-ready. Establishing a standard health-check checklist after installation can help identify configuration issues early and reduce troubleshooting effort later.