I was looking for an alternative to k3sup method to install a k3s cluster.( Refer this link on how to setup k3s using k3sup.)
Most of the content below is based from the quick start guide here - https://docs.k3s.io/quick-start
Generate a token that will be used to join additional nodes to the kubernetes cluster":
openssl rand -hex 10 > k3s_secret.txt
Install the first control plane node: curl -sfL https://get.k3s.io | K3S_TOKEN=
cat k3s_secret.txt sh -s - server --cluster-init
k3sadmin@k3s-control1:~$ curl -sfL https://get.k3s.io | K3S_TOKEN=`cat k3s_secret.txt` sh -s - server --cluster-init
[INFO] Finding release for channel stable
[INFO] Using v1.28.6+k3s2 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Validate if the node is up: sudo kubectl get nodes
k3sadmin@k3s-control1:~$ sudo kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3s-control1 Ready control-plane,etcd,master 14m v1.28.6+k3s2
Copy the token to the other nodes:
scp -v k3s_secret.txt k3sadmin@k3s-control2:/home/k3sadmin
scp -v k3s_secret.txt k3sadmin@k3s-control3:/home/k3sadmin
Install and join the second node: curl -sfL https://get.k3s.io | K3S_TOKEN=
cat k3s_secret.txt sh -s - server --server https://k3s-control1:6443
k3sadmin@k3s-control2:~$ curl -sfL https://get.k3s.io | K3S_TOKEN=`cat k3s_secret.txt` sh -s - server --server https://k3s-control1:6443
[INFO] Finding release for channel stable
[INFO] Using v1.28.6+k3s2 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Install and join the third control plane node: curl -sfL https://get.k3s.io | K3S_TOKEN=
cat k3s_secret.txt sh -s - server --server https://k3s-control1:6443
k3sadmin@k3s-control3:~$ curl -sfL https://get.k3s.io | K3S_TOKEN=`cat k3s_secret.txt` sh -s - server --server https://k3s-control1:6443
[INFO] Finding release for channel stable
[INFO] Using v1.28.6+k3s2 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Validate
k3sadmin@k3s-control1:~$ sudo kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3s-control1 Ready control-plane,etcd,master 22m v1.28.6+k3s2
k3s-control2 Ready control-plane,etcd,master 4m29s v1.28.6+k3s2
k3s-control3 Ready control-plane,etcd,master 72s v1.28.6+k3s2
k3sadmin@k3s-control1:~$ sudo kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 23m
kube-system kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 23m
kube-system metrics-server ClusterIP 10.43.61.109 <none> 443/TCP 23m
kube-system traefik LoadBalancer 10.43.75.94 172.16.1.11,172.16.1.12,172.16.1.13 80:32470/TCP,443:32299/TCP 22m
Cluster Access:
The kubeconfig file is stored at /etc/rancher/k3s/k3s.yaml
Copy the /etc/rancher/k3s/k3s.yaml file from the control node to the jumpbox host under - /home/username/.kube/config
Set the KUBECONFIG environmental variable:
export KUBECONFIG=/home/username/.kube/config