Step 1
Update the server with following command
yum update -y
Step 2
Install Kubernetes before that we need to setup required
kernel modules for that load the follwoing these are all need to be in all node
modprobe br_netfilter
modprobe ip_vs
modprobe ip_vs_rr
modprobe ip_vs_wrr
modprobe ip_vs_sh
modprobe overlay
then add the following module load to start on boot
cat > /etc/modules-load.d/kubernetes.conf << EOF
br_netfilter
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
overlay
EOF
add the following in kernel model
cat > /etc/sysctl.d/kubernetes.conf << EOF
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
enable it with following command
sysctl --system
Step 3
Disable the swap
swapoff -a
sed -e '/swap/s/^/#/g' -i /etc/fstab
Step 4
add the kubernetes repository
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF
install with following command
dnf makecache; dnf install -y kubelet kubeadm kubectl
--disableexcludes=kubernetes
The --disableexcludes=kubernetes flag ensures that packages
from the Kubernetes repository are not excluded during installation.
now enable it and start the services
systemctl enable --now kubelet.service
Step 5
RKE2 installation with follwoing command
curl -sfL https://get.rke2.io | sh -
once it running the script this will install the rke2
in main server create
and the followings
vi /etc/rancher/rke2/config.yaml
token: my-shared-secret
tls-san:
-
my-kubernetes-domain.com
- another-kubernetes-domain.com
once this done need to enable the service and it will
automatically start
systemctl enable --now kubelet.service
Once service is start then export the yaml file and also
need to copy that as follow as
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
mkdir -p ~/.kube
cp /etc/rancher/rke2/rke2.yaml ~/.kube/config
modify the server from https://127.0.0.1:6443 to
https://your cluster ip:6443
now you can try and get the nodes with the following command
kubectl get nodes
it will show the current nodes and it's roles
Step 6
Add the client.
"As RKE2 server nodes by default also run as agents you
can get by with only running server nodes if you have
light user workloads. However if you want to segregate your
control plane and user workloads you should run
agent nodes in your HA cluster as well."
curl -sfL https://get.rke2.io | sh -
for install agent run the follwing command
curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE="agent" sh -
vi /etc/rancher/rke2/config.yaml
add the following details and start the service
server: https://my-kubernetes-domain.com:9345
token: my-shared-secret
systemctl enable --now rke2-server.service
or
systemctl enable --now rke2-agent.service