Rancher Install
using VirtualBox, vagrant
Prerequisites
At least 4GB of free RAM
Note
Vagrant will require plugins to create VirtualBox VMs. Install them with the following commands:
vagrant plugin install vagrant-vboxmanagevagrant plugin install vagrant-vbguestConfiguration
my local ip address
192.168.129.106.
Configuration Files
below code is bootstrap provision script for all VMs.
#!/bin/bash
# Enable ssh password authentication
echo "[TASK 1] Enable ssh password authentication"
sed -i 's/^PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
systemctl reload sshd
# Set Root password
echo "[TASK 2] Set root password"
echo -e "kubeadmin\nkubeadmin" | passwd root >/dev/null 2>&1
# Set Rancher
apt-get update && apt-get install -y ca-certificates curl gnupg lsb-release
mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
apt-get install -y vim net-tools
cat <<EOF > /etc/docker/daemon.json
{
"insecure-registries" : [ "192.168.129.106:5001" ]
}
EOF
systemctl daemon-reload && systemctl restart dockerbelow Vagrantfile is generate 5 VMs(1 VM is for rancher, 4 VM is for k8s).
Prepare at least 4GB of memory for Rancher.
VM network's range is 192.168.56.0/24.
VM Information
rancher
2
6
192.168.56.10
Rancher
node1
2
2
192.168.56.111
k8s Master
node2
2
2
192.168.56.112
k8s Master
node3
2
2
192.168.56.113
k8s Worker
node4
2
2
192.168.56.114
k8s Worker
Empty VM List

Build VMs
build VMs. this command is take a few minutes.
Generated VM List

Repository in Host
In host machine, run docker registry.
after run registry, see below command:
Run Rancher
Rancher web
connect to rancher web (http:192.168.56.10) via web browser
http:192.168.56.10) via web browser
check container id and find password
Set new password and continue

Rancher main page

Create New Cluster
Create new Cluster
click create new cluster and select Custom.
Custom: use existing nodes and create a cluster using RKE


set Cluster Name and scroll down.
Cloud provider is External (Out-of-tree) and Next.

Add Nodes to Cluster
Add Cluster - Custom
Click
Show advanced options

Show advanced options

node role
node1(192.168.56.111), node2(192.168.56.112) is master(etcd, control plane).
node3(192.168.56.113), node4(192.168.56.114) is worker(worker)
in node1 (select only etcd, control plane and copy command)
in node2 (select only etcd, control plane and copy command)
in node3 (de-select etcd, control plane and select only worker and copy command)
in node4 (de-select etcd, control plane and select only worker and copy command)
Provisioning Cluster
provisioning cluster

about 15 minutes later. create cluster is finished.

nodes in cluster

References
Last updated