RKE2 v1.32 Deployment via Rancher Manager

In this article I will show you how to deploy RKE2 cluster via Rancher Manager. Creating an production-ready RKE2 clusters through Rancher is as straightforward as filling out a web form - select your infrastructure provider, choose your Kubernetes version, configure node pools, and click deploy. Rancher handles all the underlying complexity of bootstrapping, networking, and security configuration.

So, let's get started…

Environment

  • Rancher Manager: https://rancher.at.lab (deployment refer this article)

  • Master Node

Hostnameat-rke2-custom-1
Operating SystemUbuntu 22.04 (Jammy)
vCPU2
Memory4 GB
Disk40 GB
Network172.20.20.85
  • Worker Node
Hostnameat-rke2-custom-2
Operating SystemUbuntu 22.04 (Jammy)
vCPU2
Memory4 GB
Disk40 GB
Network172.20.20.86

Provisioning Cluster via Rancher Manager

  1. Mapping hosts
# exec on all nodes
nano /etc/hosts
---
172.20.20.67 rancher.at.lab

172.20.20.85 at-rke2-custom-1 at-rke2-custom-1.at.lab
172.20.20.86 at-rke2-custom-2 at-rke2-custom-2.at.lab
  1. Update and upgrade packages
# exec on all nodes
apt-get update -y && apt-get upgrade -y
  1. Disable swap
# exec on all nodes
systemctl disable --now swap.target
swapoff -a
  1. Enable containerd modules
# exec on all nodes
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
  1. Configure kernel settings
# exec on all nodes
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

sysctl --system
  1. Create Custom Cluster

  1. Set Cluster Configuration

  1. Registration master node (at-rke2-custom-1)

  1. Registration worker node (at-rke2-custom-2)

  1. Cluster start auto-provisioning after roles fulfilled with at least 1 node

  1. Fix waiting for cluster agent to connect, rancher not exposed to public

# exec on at-rke2-custom-1
apt-get install -y apt-transport-https ca-certificates curl gnupg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
chmod 644 /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubectl

cat<<EOF >> ~/.bashrc
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
EOF
source ~/.bashrc

kubectl edit deployment cattle-cluster-agent -n cattle-system
---
      dnsPolicy: ClusterFirstWithHostNet
      hostNetwork: true

  1. Custer provisioning done

  1. Delete taint in master node
# exec on at-rke2-custom-1
kubectl taint nodes at-rke2-custom-1 node-role.kubernetes.io/control-plane-
kubectl taint nodes at-rke2-custom-1 node-role.kubernetes.io/etcd-
  1. Verification

  1. Operational test
# exec on at-rke2-custom-1
kubectl create deployment nginx-rke2-custom --image=nginx --replicas=1
kubectl expose deployment nginx-rke2-custom --port=80 --target-port=80 
kubectl create ingress nginx-rke2-custom --class=nginx --rule="nginx-rke2-custom.at.lab/*=nginx-rke2-custom:80"

nano /etc/hosts
---
172.20.20.85 nginx-rke2-custom.at.lab

curl http://nginx-rke2-custom.at.lab

Thank You.

0
Subscribe to my newsletter

Read articles from Muhammad Alfian Tirta Kusuma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Muhammad Alfian Tirta Kusuma
Muhammad Alfian Tirta Kusuma