Create RKE2 Cluster on Ubuntu

  1. Install required packages on all VM/nodes

    #set up Docker's apt repository sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update -y sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo apt-get install -y iscsi-initiator-utils iptables sudo systemctl enable docker --now sudo systemctl enable open-iscsi --now sudo systemctl enable iscsid --now sudo apt-get update -y sudo mkdir /etc/NetworkManager/conf.d/ sudo nano /etc/NetworkManager/conf.d/rke2-canal.conf [keyfile] unmanaged-devices=interface-name:cali*;interface-name:flannel* sudo apt-get update sudo apt-get install network-manager sudo systemctl enable NetworkManager sudo systemctl start NetworkManager sudo systemctl reload NetworkManager sudo nano /etc/sysctl.d/90-rke2.conf net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1
  2. Server node installation on Master node only.

    sudo su curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=server sh - sudo mkdir -p /etc/rancher/rke2 sudo nano /etc/rancher/rke2/config.yaml #content of config.yaml token: draft-token systemctl enable rke2-server.service systemctl start rke2-server.service ln -s $(find /var/lib/rancher/rke2/data/ -name kubectl) /usr/local/bin/kubectl export KUBECONFIG=/etc/rancher/rke2/rke2.yaml kubectl get node
  3. Worker node installation

    sudo su curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE=agent sh - sudo mkdir -p /etc/rancher/rke2 sudo nano /etc/rancher/rke2/config.yaml #content of config.yaml server: https://<server>:9345 token: draft-token systemctl enable rke2-agent.service systemctl start rke2-agent.service kubectl get node
  4. Deploy software required for RKE2.