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
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 | 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_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
 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]: 
 [+] SSH Port of host (1) [22]:
 [+] SSH Private Key Path of host ( [none]: /home/rke/stmp/rke-admin-key
 [+] SSH User of host ( [ubuntu]: rke-admin
 [+] Is host ( a Control Plane host (y/n)? [y]: y
 [+] Is host ( a Worker host (y/n)? [n]: y
 [+] Is host ( an etcd host (y/n)? [n]: y
 [+] Override Hostname of host ( [none]: node01.local
 [+] Internal IP of host ( [none]:
 [+] Docker socket path on host ( [/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 []:
 [+] Enable PodSecurityPolicy [n]: n
 [+] Cluster Network CIDR []:
 [+] Cluster DNS Service IP []:
 [+] Add addon manifest URLs or YAML files [no]:

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
 b.  chmod +x ./kubectl
    c.  sudo mv ./kubectl /usr/local/bin/kubectl

6. Install HELM:

 a.  curl -O
 b.  bash ./get-helm-3
 c.  helm version

Rancher Install

1. Add rancher HELM repo:

    helm repo add rancher-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.