All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How to quick setup lightweight k3s kubernetes on 2 or more VM/VDS/VPS/dedicated servers
How to quick setup lightweight k3s kubernetes on 2 or more VM/VDS/VPS/dedicated servers
Tutorial by:
Summary:
Ever wondered how to easily setup free kubernetes on VDS/VPS? We walk you through how to do this practically for any VDS/VPS or dedicated server with root access. For practical reasons we are using CharityHost.org VDS with public IP connections for simplicity purposes. It is possible to create a 2+ node k3s kubernetes cluster that are loadbalanced with our managed loadbalancer connecting through our Public or Private network.
Requirements:
- Basic knowledge of kubernetes
- Basic/intermediate knowledge on Linux OS and ssh
- 1 or more root access servers on a private or public network
- Reference all requirements needed for k3s here: https://docs.k3s.io/installation/requirements
Setup VM's
- For this tutorial we are using 2 x Debian 12 with 1 vCPU 2 GB ram 55 GB SSD
- In CharityHost.org we created the 2 hosts with server names: k3s-01.spectrohost.com and k3s-02.spectrohost.com (spectrohost.com is an externally managed and publicly resolvable domain for simplicity purposes)
- We add A records on the public domain DNS zone pointing to each server IP for
k3s-01.spectrohost.com and k3s-02.spectrohost.com - Once those are VM are deployed , A records resolve, and you are ready you would proceed with the k3s first node installation if you just want all communication to go through public addresses, or make sure you have private addressing on the same network on your VM's as well. (At CharityHost.org this is by sending a support ticket request to add Private IP addresses to each VM)
Prepare your VM's
Note: On CharityHost.org there is a simple script
Login as root to k3s-01 node.
ssh -l root k3s-01.spectrohost.com
Run updates and restart for best practice patching to start:
apt-get update apt-get upgrade -y shutdown -hr now
Once the VM is up again, login as root via ssh again:
ssh -l root k3s-01.spectrohost.com
Disable UFW firewall if active or reference k3s requirements for required open ports and adjust your firewall accordingly:
ufw disable
Note: CharityHost.org VDS includes a Firewall you can manage for your VDS to secure connections on public and private links.
Repeat these 4 steps above on all VM that will join the k3s kubernetes cluster as nodes.
Install k3s on the first VM node to be the Master node:
Quick-start Install k3s on the k3s-01.spectrohost.com for the first master node:
Note: This can also be done automatically running a "Recipe" for k3s installation by connecting to the client area then accessing the virtualizor VDS panel "Installation" menu):curl -sfL https://get.k3s.io | sh -
It will result in output like this:
[INFO] systemd: Starting k3s
Check the node with kubectl cli:
kubectl get node
Expect output like this:
NAME STATUS ROLES AGE VERSION k3s-01.spectroweb.com Ready control-plane,master 86s v1.30.4+k3s1
While still connected, get the Node Token from your first node (master node) and copy it:
cat /var/lib/rancher/k3s/server/node-token
Logout and then login to each additional VM via ssh to connect it to the first master node and add them to the k3s cluster as agents:
ssh -l root k3s-02.spectrohost.com
Attention, this command includes the node-token you got in step 3 above. Past your node token replacing and replace the k3s-01.spectrohost.com with your actual k3s resolvable A record for the 1st node (or however suitable, use the public or private IP address) in the following command.
curl -sfL https://get.k3s.io | K3S_URL=https://k3s-01.spectrohost.com:6443 K3S_TOKEN= sh -
Expect the tail end of the output to be like this:
[INFO] Host iptables-save/iptables-restore tools not found [INFO] Host ip6tables-save/ip6tables-restore tools not found [INFO] systemd: Starting k3s-agent
Verify both nodes are online, the ks-01 master node and the ks-02 agent worker node. Login to ks-01 via ssh and run command:
kubectl get nodes
Expect 2 nodes to be listed as ready:
NAME STATUS ROLES AGE VERSION k3s-01.spectroweb.com Ready control-plane,master 21m v1.30.4+k3s1 k3s-02.spectroweb.com Ready <none> 4m39s v1.30.4+k3s1
And that's all there is to installing a 2+ node kubernetes k3s cluster. Futher tutorials and research would be needed to walk through the lifecycle processes for a kubernetes containerized application deployment.
Thank you!
Feedback welcomed!
References:
Comments
I think you should enjoy the weekend,
I saw several of your ads in the last 24 hours.
It's good to post tutorials, but putting in a little self-promotion is like shouting buy me, be patient, sales will come by themselves, show that you have something to offer and you will see results.
@nohavps Will chill. thanks!