SingleNode RKE cluster installation

In this tutorial i will  demonstrate how to install a singlenode RKE that will be managed from rancher UI

pre requisites :

Linux VM in my case it was ubuntu 20.04
CPU: 8
RAM: 20GB
DISK: 150GB
virtualization enabled

Right, lets dive in to it….

Host Preparation

1. Configure the hostnames for your one node cluster, add the relevant entries to host VM hostfile:
NOTE: that will be used later by the RKE.

    echo '<YOUR HOST IP> <YOUR DNS NAME>' | sudo tee -a /etc/hosts

2. Next install Docker:
NOTE: the version is not random.

    sudo curl https://releases.rancher.com/install-docker/23.0.sh | sh

3. Add a user account that can use the Docker Socket:

    export RKE_ADMIN_USER=rke-admin; sudo useradd -m -G docker -s /bin/bash -c "Rancher Kubernetes Admin user" $RKE_ADMIN_USER

4. Validate Docker Socket is accusable:

    export RKE_ADMIN_USER=rke-admin; sudo su - $RKE_ADMIN_USER -c "docker version"

5. Generate SSH key:

 a.  export RKE_ADMIN_KEY=rke-admin-key
    b.  ssh-keygen -f $RKE_ADMIN_KEY

6. Allow rke-admin user login with the previously generated key:

    sudo su -c "umask 077; mkdir -p ~$RKE_ADMIN_USER/.ssh; cat /home/rke/stmp/$RKE_ADMIN_KEY.pub >> ~$RKE_ADMIN_USER/.ssh/authorized_keys; chown -R $RKE_ADMIN_USER:$RKE_ADMIN_USER ~$RKE_ADMIN_USER/.ssh"

RKE Install

1. Download RKE, rename the binary and move it to /usr/local/bin:

 a.  curl -LO https://github.com/rancher/rke/releases/download/v1.4.9/rke_linux-amd64
 b.  mv rke_linux-amd64 rke
 c.  chmod +x rke
 d.  mv rke /usr/local/bin
 e.  which rke
    f.  rke --version

2. Create a cluster config:

rke config - name cluster.yml

 rke@rke-virtual-machine:~/stmp$ rke config - name cluster.yml
 [+] Cluster Level SSH Private Key Path [~/.ssh/id_rsa]: /home/rke/stmp/rke-admin-key #this is the key you created earlyer.
 [+] Number of Hosts [1]:
 [+] SSH Address of host (1) [none]: 192.168.66.206 
 [+] SSH Port of host (1) [22]:
 [+] SSH Private Key Path of host (192.168.66.206) [none]: /home/rke/stmp/rke-admin-key
 [+] SSH User of host (192.168.66.206) [ubuntu]: rke-admin
 [+] Is host (192.168.66.206) a Control Plane host (y/n)? [y]: y
 [+] Is host (192.168.66.206) a Worker host (y/n)? [n]: y
 [+] Is host (192.168.66.206) an etcd host (y/n)? [n]: y
 [+] Override Hostname of host (192.168.66.206) [none]: node01.local
 [+] Internal IP of host (192.168.66.206) [none]:
 [+] Docker socket path on host (192.168.66.206) [/var/run/docker.sock]:
 [+] Network Plugin Type (flannel, calico, weave, canal, aci) [canal]: flannel
 [+] Authentication Strategy [x509]:
 [+] Authorization Mode (rbac, none) [rbac]:
 [+] Kubernetes Docker image [rancher/hyperkube:v1.26.6-rancher1]:
 [+] Cluster domain [cluster.local]: rke.rancher # this is the DNS you added to hosts file.
 [+] Service Cluster IP Range [10.43.0.0/16]:
 [+] Enable PodSecurityPolicy [n]: n
 [+] Cluster Network CIDR [10.42.0.0/16]:
 [+] Cluster DNS Service IP [10.43.0.10]:
 [+] Add addon manifest URLs or YAML files [no]:
 rke@rke-virtual-machine:~/stmp$

3. Deploy RKE

    rke up

4. Cluster is created and the ‘kube_config_cluster.yaml’ is created too, now let’s create a config for the unborn kubectl:

 mkdir -p ~/.kube; cp -p ./kube_config_cluster.yml ~/.kube/config

5. Install Kubectl:

 a.  curl -LO https://dl.k8s.io/release/v1.26.0/bin/linux/amd64/kubectl
 b.  chmod +x ./kubectl
    c.  sudo mv ./kubectl /usr/local/bin/kubectl

6. Install HELM:

 a.  curl -O https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
 b.  bash ./get-helm-3
 c.  helm version

Rancher Install

1. Add rancher HELM repo:

    helm repo add rancher-stable https://releases.rancher.com/server-charts/stable

2. Create namespace for Rancher:

    k create ns cattle-system

3. Install cert manager:
NOTE: pay attention to version.

 a.  export RKE_HOSTNAME=rke.rancher
 b.  export RKE_ADMIN_PASSWORD=some_heavy_pass
 c.  helm install rancher rancher-stable/rancher \
    --namespace cattle-system \
    --set hostname=${RKE_HOSTNAME} \
       --set bootstrapPassword=${RKE_ADMIN_PASSWORD}
Now navigate to https://rke.rancher
NOTE: if you are accessing from another machine in the same network update the hosts file.