How to Install Rancher 2.6.9 and Deploy a Kubernetes Cluster on Ubuntu
This step‑by‑step guide shows how to prepare two Ubuntu 22.04 servers, configure Docker and system settings, install Rancher 2.6.9 via Docker, and use Rancher’s UI to create and launch a functional Kubernetes master‑node and worker‑node cluster.
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, the other as a worker node. Time synchronization between the servers is required.
Pre‑operations
Change hostnames
Kubernetes does not allow duplicate hostnames, so set unique names:
<code>hostnamectl set-hostname master-1</code>on 192.168.10.43 and
<code>hostnamectl set-hostname node-1</code>Disable swap
Swap must be disabled for Kubernetes to run correctly:
<code>sed -ri 's/.swap./#&/' /etc/fstab</code>Configure Docker registry mirrors
Edit
/etc/docker/daemon.json(create the file if it does not exist) with the following content:
<code>{
"registry-mirrors": [
"https://ung2thfc.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}</code>Restart Docker to apply the configuration:
<code>systemctl restart docker</code>Optionally reboot the servers to ensure all changes take effect.
Install Rancher
Rancher is a UI management layer for Kubernetes. Deploy it with Docker on the master host (192.168.10.43):
<code>docker run -d --restart=unless-stopped \
--name=rancher \
-p 80:80 -p 443:443 \
--privileged \
rancher/rancher:v2.6.9</code>Monitor the installation progress:
<code>docker logs --tail 30 -f rancher</code>When the container is ready, open
http://<IP>in a browser to see the Rancher UI.
Retrieve the initial admin password:
<code>docker logs rancher 2>&1 | grep "Bootstrap Password:"</code>After logging in, proceed to create a Kubernetes cluster.
Install Kubernetes via Rancher
In the Rancher UI, create a new cluster and choose the "Custom" option. Give the cluster a name and accept the default settings.
Select the components for the master node (Etcd and Control Plane). Rancher generates a
docker runcommand; execute it on the master host (192.168.10.43) to deploy the master node. Repeat the generated command on additional hosts if multiple masters are needed.
For worker nodes, deselect Etcd and Control Plane, then run the provided
docker runcommand on each worker host (e.g., 192.168.10.42).
After the containers are up, the cluster will show one master and one worker node:
Test the cluster
Create a simple Nginx deployment via the Rancher UI, expose port 80, and then access
http://<IP>:30080in a browser to see the Nginx welcome page.
The guide covers environment preparation, system configuration, Rancher installation, Kubernetes cluster creation, and a basic workload test.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.