Last active
February 28, 2024 08:43
-
-
Save zackbradys/2614752a15148a413ffe6f2f5ea05a09 to your computer and use it in GitHub Desktop.
Effortless, Easy, and Efficient installation steps of Rancher Kubernetes Engine 2 (RKE2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- RKE2 SERVER NODES (CONTROL PLANE) --- | |
### Apply System Settings | |
cat << EOF >> /etc/sysctl.conf | |
### Modified System Settings | |
vm.swappiness=0 | |
vm.panic_on_oom=0 | |
vm.overcommit_memory=1 | |
kernel.panic=10 | |
kernel.panic_on_oops=1 | |
vm.max_map_count = 262144 | |
net.ipv4.ip_local_port_range=1024 65000 | |
net.core.somaxconn=10000 | |
net.ipv4.tcp_tw_reuse=1 | |
net.ipv4.tcp_fin_timeout=15 | |
net.core.somaxconn=4096 | |
net.core.netdev_max_backlog=4096 | |
net.core.rmem_max=16777216 | |
net.core.wmem_max=16777216 | |
net.ipv4.tcp_max_syn_backlog=20480 | |
net.ipv4.tcp_max_tw_buckets=400000 | |
net.ipv4.tcp_no_metrics_save=1 | |
net.ipv4.tcp_rmem=4096 87380 16777216 | |
net.ipv4.tcp_syn_retries=2 | |
net.ipv4.tcp_synack_retries=2 | |
net.ipv4.tcp_wmem=4096 65536 16777216 | |
net.ipv4.neigh.default.gc_thresh1=8096 | |
net.ipv4.neigh.default.gc_thresh2=12288 | |
net.ipv4.neigh.default.gc_thresh3=16384 | |
net.ipv4.tcp_keepalive_time=600 | |
net.ipv4.ip_forward=1 | |
fs.inotify.max_user_instances=8192 | |
fs.inotify.max_user_watches=1048576 | |
EOF | |
sysctl -p > /dev/null 2>&1 | |
### Install Packages | |
yum install -y iptables container-selinux iptables libnetfilter_conntrack libnfnetlink libnftnl policycoreutils-python-utils cryptsetup | |
yum install -y nfs-utils; yum install -y iscsi-initiator-utils; yum install -y zip zstd tree jq | |
### Modify Settings | |
echo "InitiatorName=$(/sbin/iscsi-iname)" > /etc/iscsi/initiatorname.iscsi && systemctl enable --now iscsid | |
systemctl stop firewalld; systemctl disable firewalld; systemctl stop nm-cloud-setup; systemctl disable nm-cloud-setup; systemctl stop nm-cloud-setup.timer; systemctl disable nm-cloud-setup.timer | |
echo -e "[keyfile]\unmanaged-devices=interface-name:cali*;interface-name:flannel*" > /etc/NetworkManager/conf.d/rke2-canal.conf & systemctl restart NetworkManager | |
### Create the RKE2 Directory | |
mkdir -p /etc/rancher/rke2/ | |
### Create the RKE2 Configuration File | |
cat << EOF >> /etc/rancher/rke2/config.yaml | |
token: rke2SecurePassword | |
EOF | |
### Download the RKE2 Control/Server Binary | |
curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=v1.26 INSTALL_RKE2_TYPE=server sh - | |
### Start the RKE2 Control/Server Service | |
systemctl enable rke2-server.service && systemctl start rke2-server.service | |
### server(s): rke2-cp-01 | |
### Symlink kubectl and containerd | |
sudo ln -s /var/lib/rancher/rke2/data/v1*/bin/kubectl /usr/bin/kubectl | |
sudo ln -s /var/run/k3s/containerd/containerd.sock /var/run/containerd/containerd.sock | |
### Update your paths in bashrc | |
cat << EOF >> ~/.bashrc | |
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml | |
export PATH=$PATH:/var/lib/rancher/rke2/bin:/usr/local/bin/ | |
alias k=kubectl | |
EOF | |
source ~/.bashrc | |
### Verify status with kubectl | |
kubectl get nodes | |
--- RKE2 AGENT NODES (WORKERS) | |
### Apply System Settings | |
cat << EOF >> /etc/sysctl.conf | |
### Modified System Settings | |
vm.swappiness=0 | |
vm.panic_on_oom=0 | |
vm.overcommit_memory=1 | |
kernel.panic=10 | |
kernel.panic_on_oops=1 | |
vm.max_map_count = 262144 | |
net.ipv4.ip_local_port_range=1024 65000 | |
net.core.somaxconn=10000 | |
net.ipv4.tcp_tw_reuse=1 | |
net.ipv4.tcp_fin_timeout=15 | |
net.core.somaxconn=4096 | |
net.core.netdev_max_backlog=4096 | |
net.core.rmem_max=16777216 | |
net.core.wmem_max=16777216 | |
net.ipv4.tcp_max_syn_backlog=20480 | |
net.ipv4.tcp_max_tw_buckets=400000 | |
net.ipv4.tcp_no_metrics_save=1 | |
net.ipv4.tcp_rmem=4096 87380 16777216 | |
net.ipv4.tcp_syn_retries=2 | |
net.ipv4.tcp_synack_retries=2 | |
net.ipv4.tcp_wmem=4096 65536 16777216 | |
net.ipv4.neigh.default.gc_thresh1=8096 | |
net.ipv4.neigh.default.gc_thresh2=12288 | |
net.ipv4.neigh.default.gc_thresh3=16384 | |
net.ipv4.tcp_keepalive_time=600 | |
net.ipv4.ip_forward=1 | |
fs.inotify.max_user_instances=8192 | |
fs.inotify.max_user_watches=1048576 | |
EOF | |
sysctl -p > /dev/null 2>&1 | |
### Create the RKE2 Directory | |
mkdir -p /etc/rancher/rke2/ | |
### Create the RKE2 Configuration File | |
cat << EOF >> /etc/rancher/rke2/config.yaml | |
server: https://10.0.0.15:9345 | |
token: rke2SecurePassword | |
EOF | |
### Download the RKE2 Worker/Agent Binary | |
curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=v1.26 INSTALL_RKE2_TYPE=agent sh - | |
### Start the RKE2 Worker/Agent Service | |
systemctl enable rke2-agent.service && systemctl start rke2-agent.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super, thank you!