Cloud Native 6 min read

Step-by-Step Guide to Install Rancher and Build a Kubernetes Cluster on Ubuntu

This tutorial walks you through preparing two Ubuntu servers, configuring Docker, installing Rancher 2.6.9, deploying a Kubernetes master and worker nodes via Rancher’s UI, and validating the cluster with an Nginx workload, all with detailed commands and screenshots.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step-by-Step Guide to Install Rancher and Build a Kubernetes Cluster on Ubuntu

Environment

Ubuntu 22.04.2 LTS

Docker 24.0.2

2 GB RAM or more

CPU 2 cores or more

Rancher 2.6.9

Two Ubuntu servers (192.168.10.43 and 192.168.10.42) are prepared: one as the Kubernetes master node and the other as a worker (node) node. Ensure the system clocks are precisely synchronized across the LAN.

Pre‑setup

Change hostnames

Kubernetes requires unique hostnames, so set them first:

On 192.168.10.43: hostnamectl set-hostname master-1 On 192.168.10.42:

hostnamectl set-hostname node-1

Disable swap

Swap must be disabled for a stable Kubernetes installation:

sed -ri 's/.swap./#&/' /etc/fstab

Configure Docker registry mirrors

Create or edit /etc/docker/daemon.json with the following content to speed up image pulls:

{
    "registry-mirrors": [
        "https://ung2thfc.mirror.aliyuncs.com",
        "https://registry.docker-cn.com",
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn"
    ]
}

Restart Docker to apply the changes: systemctl restart docker Optionally reboot the servers to ensure all settings take effect.

Install Rancher

Rancher is a UI management layer for Kubernetes; it does not replace the cluster itself. Deploy Rancher via Docker on the master server (192.168.10.43):

docker run -d --restart=unless-stopped \
  --name=rancher \
  -p 80:80 -p 443:443 \
  --privileged \
  rancher/rancher:v2.6.9

Monitor the installation progress: docker logs --tail 30 -f rancher When the UI becomes reachable, open a browser at http://<IP>. Retrieve the initial admin password:

docker logs rancher 2>&1 | grep "Bootstrap Password:"

Install Kubernetes via Rancher

In the Rancher UI, create a new cluster using the custom option, give it a name, and proceed with the defaults.

Select Etcd and Control Plane components for the master node and run the generated docker run command on 192.168.10.43. Repeat the command on additional hosts if multiple masters are needed.

Deploy worker nodes by deselecting Etcd and Control Plane, then run the provided docker run command on 192.168.10.42 (or other hosts).

After the nodes are up, you should see a one‑master‑one‑worker cluster:

Test the Cluster

Create a simple Nginx deployment through the Rancher UI, expose port 80 as 30080, and apply the workload.

After the pods are running, access http://<IP>:30080 in a browser to see the Nginx welcome page, confirming the cluster works.

This guide covers the environment setup, Rancher installation, Kubernetes cluster creation, and a basic validation workload. Further Kubernetes usage is beyond the scope of this article.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeDockerKubernetesDevOpsCluster DeploymentUbunturancher
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.