Simple RKE2  Install

Photo by Growtika on Unsplash

Simple RKE2 Install

RKE2 is a Kubernetes distribution from the rancher just like RKE and K3S, to know more about the difference between these distributions please go through the link.

RKE2 provides an installation script that is a convenient way to install it as a service on systemd based systems. This script is available at https://get.rke2.io.

Let's consider we are creating 3 node RKE2 cluster, 1 master and 2 worker nodes:

To install the RKE2 server master node:

curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=server sh - 

# start and enable for restarts - 
systemctl enable rke2-server.service 
systemctl start rke2-server.service

Here is what the Ubuntu version should look like:

rke_install.jpg

Let's validate everything worked as expected. Run a systemctl status rke2-server and make sure it is active.

rke_status.jpg

Perfect! Now we can start talking Kubernetes. We need to symlink the kubectl cli on master that gets installed from RKE2.

# simlink all the things - kubectl
ln -s $(find /var/lib/rancher/rke2/data/ -name kubectl) /usr/local/bin/kubectl

# add kubectl conf
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml 

# check node status
kubectl  get node

For those that are not too familiar with k8s, the config file is what kubectl uses to authenticate to the api service. If you want to use a workstation, jump box, or any other machine you will want to copy /etc/rancher/rke2/rke2.yaml. You will want to modify the file to change the ip address. We will need one more file from master, aka the server, the agent join token. Copy /var/lib/rancher/rke2/server/node-token, we will need it for the agent install.

Side note on Tokens. RKE2 uses the TOKEN as a way to authenticate the agent to the server service. This is a much better system than "trust on first use". The goal of the token process is to setup a control plane Mutual TLS (mtls) certificate termination.

RKE2 Agent Install on worker nodes:

The agent install is very similar to the server install. Except that we need an agent config file before starting.

# we add INSTALL_RKE2_TYPE=agent
curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=agent sh -

# create config file
mkdir -p /etc/rancher/rke2/ 

# change the ip to reflect your master ip
echo "server: https://$MASTER_IP:9345" > /etc/rancher/rke2/config.yaml

# change the Token to the one from master /var/lib/rancher/rke2/server/node-token 
echo "token: $TOKEN" >> /etc/rancher/rke2/config.yaml

# enable and start
systemctl enable rke2-agent.service
systemctl start rke2-agent.service

What should this look like:

rke_agent

Rinse and repeat. Run the same install commands on the other remaining worker node. Next we one can validate all the nodes are playing nice by running kubectl get node -o wide on master node.