
What's BEST for Beginners Kubernetes NodePort or LoadBalancer?
CodeWithChandra
This guide will help you quickly install a cluster with default options. Installing Rancher RKE2 involves setting up the RKE2 Kubernetes cluster and then deploying the Rancher management server on top of it. Here are the steps-by-step commands featured in my video. For ALL Nodes (3 Control Plane + 1 Worker): ------------------------------------------- These commands are needed on all 4 nodes. sudo apt update && sudo apt upgrade -y sudo apt install -y curl wget gnupg2 software-properties-common sudo timedatectl set-ntp true sudo swapoff -a sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab sudo modprobe br_netfilter sudo modprobe overlay 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 sudo sysctl --system ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Installation of RKE2 on Control Nodes ------------------------------------- For Control Plane Nodes (3 nodes): curl -sfL https://get.rke2.io | sudo sh - sudo systemctl enable rke2-server.service ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Installation of RKE2 on Worker Nodes ------------------------------------ For Worker Node (1 node): curl -sfL https://get.rke2.io | sudo sh - sudo systemctl enable rke2-agent.service ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Config File For Control Node 1 - "scooby" (192.168.50.88) --------------------------------------------------------- sudo mkdir -p /etc/rancher/rke2/ && sudo sh -c 'cat > /etc/rancher/rke2/config.yaml' <<'EOF' tls-san: - CTRL_NODE1_IP - CTRL_NODE2_IP - CTRL_NODE3_IP node-ip: CTRL_NODE1_IP cluster-cidr: 10.42.0.0/16 service-cidr: 10.43.0.0/16 EOF sudo systemctl start rke2-server.service sudo cat /var/lib/rancher/rke2/server/node-token Config File For Control Node 2 - "scrapy" (192.168.50.64) --------------------------------------------------------- sudo mkdir -p /etc/rancher/rke2/ && sudo sh -c 'cat > /etc/rancher/rke2/config.yaml' <<'EOF' server: https://192.168.50.88:9345 token: ####YOURTOKEN#### tls-san: - CTRL_NODE1_IP - CTRL_NODE2_IP - CTRL_NODE3_IP node-ip: CTRL_NODE2_IP cluster-cidr: 10.42.0.0/16 service-cidr: 10.43.0.0/16 EOF sudo systemctl start rke2-server.service Config File For Control Node 3 - "shaggy" (192.168.50.90) --------------------------------------------------------- sudo mkdir -p /etc/rancher/rke2/ && sudo sh -c 'cat > /etc/rancher/rke2/config.yaml' <<'EOF' server: https://192.168.50.88:9345 token: ####YOURTOKEN#### tls-san: - CTRL_NODE1_IP - CTRL_NODE2_IP - CTRL_NODE3_IP node-ip: CTRL_NODE3_IP cluster-cidr: 10.42.0.0/16 service-cidr: 10.43.0.0/16 EOF sudo systemctl start rke2-server.service Config File For Worker Node - "velma" (192.168.50.86) ----------------------------------------------------- sudo mkdir -p /etc/rancher/rke2/ && sudo sh -c 'cat > /etc/rancher/rke2/config.yaml' <<'EOF' server: https://192.168.50.88:9345 token: ####YOURTOKEN#### node-ip: 192.168.50.86 EOF sudo systemctl start rke2-agent.service sudo systemctl status rke2-agent.service ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Verification ------------ After all nodes are joined, you can verify with: sudo ln -s /var/lib/rancher/rke2/bin/kubectl /usr/local/bin/kubectl export KUBECONFIG=/etc/rancher/rke2/rke2.yaml kubectl get nodes kubectl get pods -A ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Installing Rancher Management UI Into Your RKE2 Cluster ------------------------------------------------------- Install Rancher via Helm (run these commands on only ONE control plane node!) curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash helm repo add rancher-latest https://releases.rancher.com/server-charts/latest helm repo add jetstack https://charts.jetstack.io helm repo update kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.crds.yaml helm install cert-manager jetstack/cert-manager \ --namespace cert-manager \ --create-namespace \ --version v1.14.5 kubectl -n cert-manager wait --for=condition=Ready pods --all --timeout=300s helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --create-namespace \ --set hostname=rancher.########YOURDOMAIN########.com\ --set replicas=3 \ --set bootstrapPassword=rabi123 ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Verification (Run on the same node): ------------------------------------- kubectl -n cattle-system get pods kubectl -n cattle-system get svc ◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆◇◆◇◆◇◇◆ Testing On Web Browser ---------------------- # Edit Windows Host file 192.168.50.88 rancher.########YOURDOMAIN########.com # Open Web Browser and enter https://rancher.########YOURDOMAIN########.com # Rancher setup Enter the "bootstrapPassword". After that, click on "Log in with local User" button. "`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._,-'"`-._, #kubernetes #fypシ