#!/bin/bash# Checkifuserisrootif [ "$UID"-ne0 ]; thenecho"You are not the root user."exit1fiecho"You are the root user."# Checkifk3s-killall.shexistsin/usr/local/binif [ -f"/usr/local/bin/k3s-killall.sh" ]; thenecho"Executing k3s-killall.sh..."/usr/local/bin/k3s-killall.shelseecho"k3s-killall.sh does not exist in /usr/local/bin."fi# Checkifk3s-uninstall.shexistsin/usr/local/binif [ -f"/usr/local/bin/k3s-uninstall.sh" ]; thenecho"Executing k3s-uninstall.sh..."/usr/local/bin/k3s-uninstall.shelseecho"k3s-uninstall.sh does not exist in /usr/local/bin."fiaptinstalliptablesiptables-save|awk'/^[*]/ { print $1 } /COMMIT/ { print $0; }'|sudoiptables-restoreiptables-Siptables-Fupdate-alternatives--setiptables/usr/sbin/iptables-legacyupdate-alternatives--setip6tables/usr/sbin/ip6tables-legacyreboot
#!/bin/bash# Checkifuserisrootif [ "$UID"-ne0 ]; thenecho"You are not the root user."exit1fiecho"You are the root user."# Checkifk3s-killall.shexistsin/usr/local/binif [ -f"/usr/local/bin/k3s-killall.sh" ]; thenecho"Executing k3s-killall.sh..."/usr/local/bin/k3s-killall.shelseecho"k3s-killall.sh does not exist in /usr/local/bin."fi# Checkifk3s-agent-uninstall.shexistsin/usr/local/binif [ -f"/usr/local/bin/k3s-agent-uninstall.sh" ]; thenecho"Executing k3s-agent-uninstall.sh..."/usr/local/bin/k3s-agent-uninstall.shelseecho"k3s-agent-uninstall.sh does not exist in /usr/local/bin."fiaptinstalliptablesiptables-save|awk'/^[*]/ { print $1 } /COMMIT/ { print $0; }'|sudoiptables-restoreiptables-Siptables-Fupdate-alternatives--setiptables/usr/sbin/iptables-legacyupdate-alternatives--setip6tables/usr/sbin/ip6tables-legacyreboot
#!/bin/bash# Checkifuserisrootif [ "$UID"-ne0 ]; thenecho"You are not the root user."exit1fiecho"You are the root user."# Checkifrancherd-killall.shexistsin/usr/local/binif [ -f"/usr/local/bin/rancherd-killall.sh" ]; thenecho"Executing rancherd-killall.sh..."/usr/local/bin/rancherd-killall.shelseecho"rancherd-killall.sh does not exist in /usr/local/bin."fi# Checkifrancherd-uninstall.shexistsin/usr/local/binif [ -f"/usr/local/bin/rancherd-uninstall.sh" ]; thenecho"Executing rancherd-uninstall.sh..."/usr/local/bin/rancherd-uninstall.shelseecho"rancherd-uninstall.sh does not exist in /usr/local/bin."fiaptinstalliptablesiptables-save|awk'/^[*]/ { print $1 } /COMMIT/ { print $0; }'|sudoiptables-restoreiptables-Siptables-Fupdate-alternatives--setiptables/usr/sbin/iptables-legacyupdate-alternatives--setip6tables/usr/sbin/ip6tables-legacyreboot
Add cgroup entries into the cmdline.txt on each nodes that is running on ARM processor.
1
sudo vim /boot/cmdline.txt
Add at the end of the line that starts with console= the below entries:
1
cgroup_memory=1cgroup_enable=memory
Save the file and exit.
Reboot the server
1
sudo reboot
Install k3s v1.21.1+k3s1 securely without the traefik on a master node
1
curl -sfL https://get.k3s.io |INSTALL_K3S_VERSION="v1.21.1+k3s1"INSTALL_K3S_EXEC="--disable traefik"K3S_KUBECONFIG_MODE="644" sh -s -
Check the status of k3s
1
2
systemctl status k3s
systemctl is-enabled k3s
Copy the token
1
sudo cat /var/lib/rancher/k3s/server/node-token
Copy IP address of the master node
1
hostname -I | awk '{ print $1 }'
Install k3s v1.21.1+k3s1 on worker nodes
1
2
curl -sfL https://get.k3s.io |INSTALL_K3S_VERSION="v1.21.1+k3s1"K3S_TOKEN="<YOUR_TOKEN>"K3S_URL="https://<MASTER_NODE_URL>:6443"K3S_NODE_NAME="worker1" sh -
curl -sfL https://get.k3s.io |INSTALL_K3S_VERSION="v1.21.1+k3s1"K3S_TOKEN="<YOUR_TOKEN>"K3S_URL="https://<MASTER_NODE_URL>:6443"K3S_NODE_NAME="worker2" sh -
The sample below uses the NGINX ingress controller to establish a deployment and expose it. Because SSL will be utilized by default and produce an error for a nonexistent certificate, it’s critical to pay attention to the annotation nginx.ingress.kubernetes.io/ssl-redirect: “false”.
The domain name that is used is another crucial factor. I’m going to use the domain name test.localhost, but you should obviously change it to your own and direct it to your k3s instance node.
Create a file called my-example.yaml and use the following syntax to implement this example for Ingress testing: