RKE2 v1.32 Deployment via Rancher Manager

3 min read
Table of contents

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
Hostname | at-rke2-custom-1 |
Operating System | Ubuntu 22.04 (Jammy) |
vCPU | 2 |
Memory | 4 GB |
Disk | 40 GB |
Network | 172.20.20.85 |
- Worker Node
Hostname | at-rke2-custom-2 |
Operating System | Ubuntu 22.04 (Jammy) |
vCPU | 2 |
Memory | 4 GB |
Disk | 40 GB |
Network | 172.20.20.86 |
Provisioning Cluster via Rancher Manager
- 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
- Update and upgrade packages
# exec on all nodes
apt-get update -y && apt-get upgrade -y
- Disable swap
# exec on all nodes
systemctl disable --now swap.target
swapoff -a
- 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
- 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
- Create Custom Cluster
- Set Cluster Configuration
- Registration master node (at-rke2-custom-1)
- Registration worker node (at-rke2-custom-2)
- Cluster start auto-provisioning after roles fulfilled with at least 1 node
- 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
- Custer provisioning done
- 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-
- Verification
- 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
